TensorFlow-object detection 目标检测(三)

本文地址:https://blog.csdn.net/shanglianlm/article/details/80812849

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 \

    --output_directory H:\pythoncode\Tensorflow\ObjectDetection\data\VOCdevkit\object_detection_graph

 参考资料:

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

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

mingo_敏

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值