darknet優化經驗-AlexeyAB大神經驗

darknet優化經驗

主要來自於:AlexeyAB 版本darknetgit

1. AlexeyAB改進項

  • 提供window支持github

  • 相較於原版pjreddie版本darknet提高了訓練速度web

  • 添加了二值化網絡,XNOR(bit) ,速度快,準確率稍低https://github.com/AlexeyAB/darknet/blob/master/cfg/yolov3-tiny_xnor.cfgjson

  • 提高7%經過將卷積層和BN層合併爲一個(*_*)不太懂。網絡

  • 多GPU訓練提高dom

  • 修補了[reorg]層ide

  • 添加了mAP, IOU,Precision-Recall計算測試

    darknet detector map...優化

  • 能夠在訓練過程當中畫loss圖像

  • 添加了根據本身數據集的anchor生成

  • 提高視頻檢測,網絡攝像頭,opencv相關問題

  • 提出了一個INT8的網絡,提高了檢測速度,可是準確率稍有降低

    https://github.com/AlexeyAB/yolo2_light

2. Linux下編譯選項

  • GPU=1 to build with CUDA to accelerate by using GPU (CUDA should be in /usr/local/cuda)
  • CUDNN=1 to build with cuDNN v5-v7 to accelerate training by using GPU (cuDNN should be in /usr/local/cudnn)
  • CUDNN_HALF=1 to build for Tensor Cores (on Titan V / Tesla V100 / DGX-2 and later) speedup Detection 3x, Training 2x
  • OPENCV=1 to build with OpenCV 3.x/2.4.x - allows to detect on video files and video streams from network cameras or web-cams
  • DEBUG=1 to bould debug version of Yolo
  • OPENMP=1 to build with OpenMP support to accelerate Yolo by using multi-core CPU
  • LIBSO=1 to build a library darknet.so and binary runable file uselib that uses this library. Or you can try to run so LD_LIBRARY_PATH=./:$LD_LIBRARY_PATH ./uselib test.mp4 How to use this SO-library from your own code - you can look at C++ example: https://github.com/AlexeyAB/darknet/blob/master/src/yolo_console_dll.cpp or use in such a way: LD_LIBRARY_PATH=./:$LD_LIBRARY_PATH ./uselib data/coco.names cfg/yolov3.cfg yolov3.weights test.mp4

3. 訓練經驗

  • 首先對數據集進行檢錯,使用提供的以下庫進行檢測:

https://github.com/AlexeyAB/Yolo_mark

  • 何時中止訓練

    • avg loss再也不降低的時候

    • 一般每一個類須要2000-4000次迭代訓練便可

    • 防止過擬合:須要在Early stopping point中止訓練

      使用如下命令:

      darknet.exe detector map...

      建議訓練的時候帶上-map,能夠畫圖

      loss_chart_map_chart

4. 提高檢測效果

  • random=1能夠設置適應多分辨率

  • 提高分辨率:416--> 608等必須是32倍數

  • 從新計算你的數據集的anchor:(注意設置的時候計算問題)

    darknet.exe detector calc_anchors data/obj.data -num_of_clusters 9 -width 416 -height 416

  • 檢查數據集經過https://github.com/AlexeyAB/Yolo_mark

  • 數據集最好每一個類有2000張圖片,至少須要迭代2000*類的個數

  • 數據集最好有沒有標註的對象,即負樣本,對應空的txt文件,最好有多少樣本就設計多少負樣本。

  • 對於一張圖有不少個樣本的狀況,使用max=200屬性(yolo層或者region層)

  • for training for small objects - set layers = -1, 11 instead of https://github.com/AlexeyAB/darknet/blob/6390a5a2ab61a0bdf6f1a9a6b4a739c16b36e0d7/cfg/yolov3.cfg#L720 and set stride=4 instead of https://github.com/AlexeyAB/darknet/blob/6390a5a2ab61a0bdf6f1a9a6b4a739c16b36e0d7/cfg/yolov3.cfg#L717

  • 訓練數據須要知足如下條件:

    • train_network_width * train_obj_width / train_image_width ~= detection_network_width * detection_obj_width / detection_image_width
    • train_network_height * train_obj_height / train_image_height ~= detection_network_height * detection_obj_height / detection_image_height
  • 爲了加速訓練,能夠作fine-tuning而不是從頭開始訓練,設置stopbackward=1在網絡的結束部分(以####做爲分割)

  • 在訓練完之後,進行目標檢測的時候,能夠提升網絡的分辨率,以便恰好檢測小目標。

    • 不須要從新訓練,須要使用原先低分辨率的權重,測用更高分辨率。
    • 爲了獲得更高的檢測效果,能夠提高分辨率至608*608甚至832*832

5. 總結

爲了小目標:

  • 提高分辨率
  • 在測試時候提高分辨率
  • 數據集添加跟正樣本數量同樣多的負樣本
  • 數據集每一個類至少2000張,訓練迭代次數2000*classes個數
  • 設置本身數據集的anchor

6. AlexeyAB大神改進

  • web-cam版本:

./darknet detector demo ... -json_port 8070 -mjpeg_port 8090

  • 計算mAP, F1, IoU, Precision-Recall

./darknet detector map ...

  • 展現map-loss曲線(須要opencv)

./darknet detector train cfg/voc.data cfg/yolo.cfg -dont_show -mjpeg_port 8090 -map

  • 計算聚類產生的anchor

./darknet detector calc_anchors data/voc.data -num_of_clusters 12 -width 608 -height 608

  • 分離前部基礎網絡

./darknet partial cfg/darknet19_448.cfg darknet19_448.weights darknet19_448.conv.23 23

  • 測試opencv

./darknet imtest data/eagle.jpg

  • 閾值設置

-thresh 0

相關文章
相關標籤/搜索