junxnone / aiwiki

AI Wiki
https://junxnone.github.io/aiwiki
18 stars 2 forks source link

Tools Darknet AlexeyAB #261

Open junxnone opened 5 years ago

junxnone commented 5 years ago

Reference

Brief

git clone https://github.com/AlexeyAB/darknet
cd darknet
make

Test

wget https://pjreddie.com/media/files/yolov3.weights
./darknet detector test ./cfg/coco.data ./cfg/yolov3.cfg ./yolov3.weights
Total BFLOPS 65.864
Loading weights from ./yolov3.weights...
 seen 64
Done!
Enter Image Path: data/horses.jpg
data/horses.jpg: Predicted in 12600.076000 milli-seconds.
horse: 88%
horse: 99%
horse: 96%
horse: 99%
Not compiled with OpenCV, saving to predictions.png instead
prediction image

Build Config

可以编译 darknet 前通过修改 Makefile 添加如下支持

-GPU=0
-CUDNN=0
+GPU=1
+CUDNN=1
-OPENMP=0
+OPENMP=1

Train with Pascal VOC

Prepare Config

wget http://pjreddie.com/media/files/darknet53.conv.74 
cd build/darknet/x64/data/voc/
wget http://pjreddie.com/media/files/VOCtrainval_11-May-2012.tar
wget http://pjreddie.com/media/files/VOCtrainval_06-Nov-2007.tar
wget http://pjreddie.com/media/files/VOCtest_06-Nov-2007.tar
tar vxf VOCtrainval_11-May-2012.tar
tar vxf VOCtrainval_06-Nov-2007.tar
tar vxf VOCtest_06-Nov-2007.tar
python3 voc_label.py
cat 2007_train.txt 2007_val.txt 2012_*.txt>train.txt
- batch=1
- subdivisions=1
+ batch=64
+ subdivisions=64

1 for Testing, 64 for Training

mixup=1
cutmix=1
mosaic=1
blur=1
-train  = /home/pjreddie/data/voc/train.txt
-valid  = /home/pjreddie/data/voc/2007_test.txt
+train  = ./build/darknet/x64/data/voc/train.txt
+valid  = ./build/darknet/x64/data/voc/2007_test.txt
 names = data/voc.names
-backup = /home/pjreddie/backup/
+backup = ./backup/
darknet detector calc_anchors data/your.data -num_of_clusters 9 -width 416 -height 416

Training cmd

./darknet detector train cfg/voc.data cfg/yolov3-voc.cfg darknet53.conv.74 -gpus 0,1,2,3 -map \
-dont_show -mjpeg_port 8090 

image

Stop and restart the train with saved weights

./darknet detector train cfg/voc.data cfg/yolov3-voc.cfg  \
backup/yolov3-voc_1008.weights \
-gpus 0,1,2,3 -map \
-dont_show -mjpeg_port 8090 
image
YOLOv3 mAP@0.5IOU@416

Test

OpenVINO



# Tips
- YOLOv3 和 YOLOv3-SPP 都是用一样的 [pre-trained weights - darknet53.conv.74](https://pjreddie.com/media/files/darknet53.conv.74)
- YOLO labels format `class x y width height` - 相对于 `width/height` 的值 (0.0, 1.0]
  - 转换方法 - [voc_label.py](https://github.com/AlexeyAB/darknet/blob/master/scripts/voc_label.py#L12)
junxnone commented 4 years ago

junxnone/tech-io#54