項目:車輛型號檢測

1、生成xml文件:使用car_inference.py

1)配置環境變量

# From project/car_detect/shiyan_output_xml3/models/research

export PYTHONPATH=$PYTHONPATH:`pwd`:`pwd`/slim

2)運行代碼

# From shiyan_output_xml3/models/research

python3 car_inference.py

 

2、使用生成的xml文件和原始圖片生成tfrecord數據

#From project/car_detect

python3 quiz-object-detection/create_data.py --label_map_path=./train_data/labels_items.txt --data_dir=./car_detect_data --output_dir=./

少量圖片沒事,圖片數很大時報錯:

錯誤原因:xml文件沒有寫入標定框信息(因爲類別判定不是car、truck等)和圖片數量沒關係

修改代碼,car_inference.py文件:類別不是car時也要輸出一個標定框(想直接刪除,報錯,顯示找不到改圖片,可能刪了後又調用了)

 

不是車的情況還挺多的

 

有一些直接沒有識別出任何類別,會輸出0.0 0.0 0.0 0.0這種標定框位置

再次運行create_data.py 代碼,還是報錯:

這是因爲生成xml文件的label.txt與create_data.py調用的labels.txt內容對不上。如下奔馳SL級AMG,右側多個r。

 

本地訓練:

3、本地訓練

#models及data所在目錄下

python3 ./models/research/object_detection/train.py --train_dir=./train_dir --pipeline_config_path=./car_detect_data/ssd_mobilenet_v1_pets.config

train_dir爲存放訓練結果的目錄,pipeline_config_path爲訓練所用config配置文件所在路徑

 

4、本地驗證

#models及data所在目錄下

python ./models/research/object_detection/eval.py --checkpoint_dir=./train_dir --eval_dir=./eval_dir --pipeline_config_path=./car_detect_data/ssd_mobilenet_v1_pets.config

checkpoint_dir爲存放訓練結果的目錄,eval_dir爲存放驗證結果的目錄,pipeline_config_path爲config配置文件(與訓練時同一文件)路徑

報錯:

WARNING:root:The following classes have no ground truth examples: [  1   2   3   4   5   6   7   8   9

  File "/home/jason/project/car_detect/models/research/object_detection/utils/object_detection_evaluation.py", line 167, in add_single_ground_truth_image_info
    standard_fields.InputDataFields.groundtruth_classes]
KeyError: 'groundtruth_classes'

參考網址:未完全明白

https://www.cnblogs.com/caffeaoto/p/8758962.html

https://cn.bing.com/search?q=The+following+classes+have+no+ground+truth+example++KeyError%3A+%27groundtruth_classes%27&qs=n&form=QBRE&sp=-1&pq=the+following+classes+have+no+ground+truth+example+keyerror%3A+%27groundtruth_classes%27&sc=0-82&sk=&cvid=84C41FD5453C40D7A29AC307CE7BC016

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章