0
点赞
收藏
分享

微信扫一扫

TensorFlow-object detection 目标检测(三)


1 将图片数据转换成TF-Record格式文件 

Pet数据 Generating the Oxford-IIIT Pet TFRecord files.

python dataset_tools/create_pet_tf_record.py \

--label_map_path=object_detection/data/pet_label_map.pbtxt \

--data_dir=H:/pythoncode/Tensorflow/ObjectDetection/data/pets \

--output_dir=H:/pythoncode/Tensorflow/ObjectDetection/data/pets/record



VOC数据 Generating the PASCAL VOC TFRecord files

python dataset_tools/create_pascal_tf_record.py \

--label_map_path=object_detection/data/pascal_label_map.pbtxt \

--data_dir=H:/pythoncode/Tensorflow/ObjectDetection/data/VOCdevkit --year=VOC2012 --set=train \

--output_path=H:/pythoncode/Tensorflow/ObjectDetection/data/VOCdevkit/record/pascal_train.record



python dataset_tools/create_pascal_tf_record.py \

--label_map_path=object_detection/data/pascal_label_map.pbtxt \

--data_dir=H:/pythoncode/Tensorflow/ObjectDetection/data/VOCdevkit --year=VOC2012 --set=val \

--output_path=H:/pythoncode/Tensorflow/ObjectDetection/data/VOCdevkit/record/pascal_val.record

2 配置训练参数 Configuring the Trainer

目录 ..\models\research\object_detection\samples\configs

修改类别数 num_classes: 20



fine_tune_checkpoint: "H:/pythoncode/Tensorflow/ObjectDetection/data/ssd_mobilenet_v1_coco_2017_11_17/model.ckpt"



train_input_reader: {

tf_record_input_reader {

input_path: "H:/pythoncode/Tensorflow/ObjectDetection/data/VOCdevkit/train/pascal_train.record" #训练数据生成的tfrecords文件

}

label_map_path: "H:/pythoncode/Tensorflow/ObjectDetection/data/pascal_label_map.pbtxt" #样本的类别信息

}



eval_input_reader: {

tf_record_input_reader {

input_path: "H:/pythoncode/Tensorflow/ObjectDetection/data/VOCdevkit/val/pascal_val.record" #校验数据生成的tfrecords文件

}

label_map_path: "H:/pythoncode/Tensorflow/ObjectDetection/data/pascal_label_map.pbtxt" #样本的类别信息

shuffle: false

num_readers: 1

}

3 训练Running the Training Job

python train.py \

--logtostderr \

--pipeline_config_path=H:\pythoncode\Tensorflow\ObjectDetection\data\VOCdevkit\ssd_mobilenet_v1_coco.config \

--train_dir=H:\pythoncode\Tensorflow\ObjectDetection\data\VOCdevkit\train_log

4 验证 Running the Evaluation Job

python eval.py \

--logtostderr \

--pipeline_config_path=H:\pythoncode\Tensorflow\ObjectDetection\data\VOCdevkit\ssd_mobilenet_v1_coco.config \

--checkpoint_dir=H:\pythoncode\Tensorflow\ObjectDetection\data\VOCdevkit\train_log \

--eval_dir=H:\pythoncode\Tensorflow\ObjectDetection\data\VOCdevkit\val_log



5 Tensorboard Running Tensorboard

tensorboard --logdir=H:\pythoncode\Tensorflow\ObjectDetection\data\VOCdevkit\train_log


6 导出训练好的模型 Exporting a trained model for inference

python export_inference_graph.py \

--input_type image_tensor \

--pipeline_config_path H:\pythoncode\Tensorflow\ObjectDetection\data\VOCdevkit\ssd_mobilenet_v1_coco.config \

--trained_checkpoint_prefix H:\pythoncode\Tensorflow\ObjectDetection\data\VOCdevkit\train_log\model.ckpt-3538 \

 参考资料:

tensorflow 轻松实现自己的目标检测

举报

相关推荐

0 条评论