1. 程式人生 > >深度學習之目標檢測object_detection程式碼實現

深度學習之目標檢測object_detection程式碼實現

基於tensorflow的object_detection框架和slim框架,實現一個目標檢測系統:

一:資料及準備

1.資料標註,使用labelImg對資料集進行標註,生成對應的xml檔案

2.使用create_pet_tf_record.py指令碼生成tfrecord檔案,訓練集train和驗證集val

3.labels_items.txt設定物體類別

5.隨機選擇測試圖片test.jpg

6.models/research/object_detection/samples/configs/ssd_mobilenet_v1_pets.config下config檔案,修改符合要求

二:訓練

執行train.py,出現各種問題,可能與tensorflow版本有關,

python ./object_detection/train.py --train_dir=$train_dir --pipeline_config_path=$pipeline_config_path

驗證:執行eval.py

python ./object_detection/eval.py --checkpoint_dir=$checkpoint_dir --eval_dir=$eval_dir --pipeline_config_path=$pipeline_config_path

匯出模型:執行export_inference_graph.py

python ./object_detection/export_inference_graph.py --input_type image_tensor --pipeline_config_path $pipeline_config_path --trained_checkpoint_prefix $train_dir/model.ckpt-$current  --output_directory $output_dir/exported_graphs

inference:

python ./inference.py --output_dir=$output_dir --dataset_dir=$dataset_dir

輸出測試結果圖片