深度學習之多目標檢測與跟蹤

支持用自己的數據訓練模型。

TensorFlow實現,包含了以下部分:

  • YOLOv3架構
  • 權重轉換器 (Weight Converter)
  • 基礎版Demo
  • GPU和CPU上都支持非極大抑制 (Non-Maximum Suppression)
  • 訓練pipeline
  • COCO mAP計算

快速開始:

四個步驟,速速上車。

1.複製這個文件:

$ git clone https://github.com/YunYang1994/tensorflow-yolov3.git

2.在使用代碼前,先安裝一些依賴項:

$ cd tensorflow-yolov3
$ pip install -r ./docs/requirements.txt

3.把加載好的COCO權重導出爲TF checkpoint (yolov3.ckpt) 和 frozen graph (yolov3_gpu_nms.pb) 。

如果你沒有yolov3.weights的話,去下載,然後放到./checkpoint目錄下。下載地址是:
https://github.com/YunYang1994/tensorflow-yolov3/releases/download/v1.0/yolov3.weights

$ python convert_weight.py --convert --freeze

4.然後,./checkpoint目錄下就會出現一些.pb文件。現在可以跑Demo腳本了:

$ python nms_demo.py
$ python video_demo.py # if use camera, set video_path = 0

拿自己的數據集訓練:

快速訓練

這個Demo就是給大家一個粗略的感受,感受YOLOv3的訓練過程到底是怎樣的。

python core/convert_tfrecord.py把你的圖集轉成TFRecords

$ python core/convert_tfrecord.py --dataset /data/train_data/quick_train_data/quick_train_data.txt  --tfrecord_path_prefix /data/train_data/quick_train_data/tfrecords/quick_train_data
$ python quick_train.py  # start training

訓練COCO數據集

如果還沒下載COCO2017數據集,請前往: http://cocodataset.org/

再把數據集放到./data/train_data/COCO裏面。

$ cd data/train_data/COCO
$ wget http://images.cocodataset.org/zips/train2017.zip
$ unzip train2017.zip
$ wget http://images.cocodataset.org/annotations/annotations_trainval2017.zip
$ unzip annotations_trainval2017.zip

然後,就要從數據集裏提取一些有用的信息了,比如邊界框,拿這些信息生成你自己的.txt文件。

$ python core/extract_coco.py --dataset_info_path ./data/train_data/COCO/train2017.txt

上面這步得到的文件是./data/train_data/COCO/train2017.txt。拿一張圖舉慄,應該長這樣:

As a result, you will get ./data/train_data/COCO/train2017.txt. Here is an example row for one image:

/home/yang/test/tensorflow-yolov3/data/train_data/train2017/000000458533.jpg 20 18.19 6.32 424.13 421.83 20 323.86 2.65 640.0 421.94
/home/yang/test/tensorflow-yolov3/data/train_data/train2017/000000514915.jpg 16 55.38 132.63 519.84 380.4
# image_path, category_id, x_min, y_min, x_max, y_max, category_id, x_min, y_min, ...

接下來,要把圖像數據集轉成.tfrecord,就是用二進制來保存數據。最後,可以訓練啦。

$ python core/convert_tfrecord.py --dataset ./data/train_data/COCO/train2017.txt  --tfrecord_path_prefix ./data/train_data/COCO/tfrecords/coco --num_tfrecords 100
$ python train.py

COCO評估
如果要看一下模型在COCO上的表現,就這樣做:

$ cd data/train_data/COCO
$ wget http://images.cocodataset.org/zips/test2017.zip
$ wget http://images.cocodataset.org/annotations/image_info_test2017.zip 
$ unzip test2017.zip
$ unzip image_info_test2017.zip

YOLOv3 TensorFlow實現傳送門:
https://github.com/YunYang1994/tensorflow-yolov3

(早就出了的) YOLO v3 PyTorch教程傳送門:
https://github.com/ayooshkathuria/YOLO_v3_tutorial_from_scratch

以上來源於: YOLOv3目標檢測有了TensorFlow實現,可用自己的數據來訓練

方法:
1、實時性,每幀視頻10ms
2、方法,首先深度學習檢測到目標,然後再寫跟蹤算法

http://news.eeworld.com.cn/mp/QbitAI/a59568.jspx
官網:https://pjreddie.com/darknet/yolo/

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