Environment
- OS: Windows 7 Professional
- Processor: Intel Xeon CPU
- System type: 64 bits OS
- GPU: NVIDIA GeForce GTX 750 Ti. Intel GPU does not support CUDA so you can only use the CPU mode
- Project Folder: YOLO_images_script
Install labelImg
- Clone labelImg repository with the command git clone https://github.com/tzutalin/labelImg.git
- Open Anaconda3(64-bit)| Anaconda Prompt(Anaconda3) from the start menu
- Execute command conda install pyqt=5
- Change directory to labelImg folder
- Execute command pyrcc5 -o libs/resources.py resources.qrc
- Execute command python labelImg.py
Collect images
- Create folder YOLO_images_script\train_images
- Create folder YOLO_images_script\val_images
- Collect 50 images
- Place 40 images to train_images folder
- Place 10 images to val_images folder
Label it
- Open labelImg
- Click open dir button
- Click Create\nRectBox button
- Select the region for label on the image
- Click save button
- Click Next Image button to label next image
Generate train.txt and val.txt
- Create folder YOLO_images_script\data
- Move train_images and val_images to YOLO_images_script\data
- Create folder YOLO_images_script\data\train_labels
- Move data\train_images*.txt to data\train_labels
- Execute YOLO_images_script.generate.py to create train.txt and val.txt
- Create KD.names file. Order is important
- KuLi
- DuLanTe
- Create KD.data file.
- classes= 2
- train = data/train.txt
- valid = data/val.txt
- names = data/KD.names
- backup = backup/
- Move train_images, train_labels, val_images, train.txt, val.txt, KD.data, KD.names to darknet\data
- Copy darknet\cfg\yolov3.cfg as darknet\cfg\yolov3-KD.cfg_train. If your GPU less than 2GB, you can use tiny-yolo.cfg. If your GPU greater than 4GB use yolov3.cfg.
- How to know my GPU memory size?
- Execute command dxdiag
- Click display tab. You can see Approx. Total Memory.
- Modify yolov3-KD.cfg_train file
- line 3: batch=16→ using 16 images for every training step
- line 4: subdivisions=16→ the batch will be divided by 16
- line 603: set filters=(classes + 5)*3 → in our case filters=21
- line 610: set classes=2 → the number of categories we want to detect
- line 689: set filters=(classes + 5)*3 → in our case filters=21
- line 696: set classes=2 → the number of categories we want to detect
- line 776: set filters=(classes + 5)*3 → in our case filters=21
- line 783: set classes=2 → the number of categories we want to detect
- If you use tiny-yolo.cfg, you can modify
- line 3: batch=16→ using 16 images for every training step
- line 4: subdivisions=16→ the batch will be divided by 16
- line 127: set filters=(classes + 5)*3 → in our case filters=21
- line 135: set classes=2 → the number of categories we want to detect
- line 171: set filters=(classes + 5)*3 → in our case filters=21
- line 177: set classes=2 → the number of categories we want to detect
- Move yolov3-KD.cfg_test and yolov3-KD.cfg_train to darknet\cfg
- Download darknet53.conv.74 and place it to darknet\
- Build your dataset with the command darknet.exe detector train data/KD.data cfg/yolov3-KD.cfg_train darknet53.conv.74. If you run this command on CPU, you will feel very slowly.
- If you get an error message CUDA Error:out of memory, try to modify darknet\cfg\yolov3-tiny.cfg
- Training how long? Then manual(Ctrl+C) stop it. If you train again, it will restart the training process.
- Thousand images : average loss error Approx 0.06
- Hundred images: average loss error Approx 0.6
- Test command darknet.exe detector test data/KD.data cfg/yolov3-tiny-KD.cfg backup/yolov3-tiny-KD_last.weights data/test1.jpg -thresh 0.5
Reference
- YOLO3 darknet训练自己的数据
- JustTryItNow/YOLO_images_script
- GitHub - tzutalin/labelImg: LabelImg is a graphical image annotation tool and label object bounding boxes in images
- How to train YOLOv2 to detect custom objects
- How to train YOLOv3 to detect custom objects
- Keras控們的福音-使用低階GPU來訓練模型
- how-to-improve-object-detection
- 訓練YOLOv2時出現cuda error:out of memory
- 建立自己的YOLO辨識模型 – 以柑橘辨識為例
- 如何快速完成YOLO V3訓練與預測
如果你覺得這篇文章很有用,可以請我喝杯咖啡,讓我提供更多優質文章給您。感謝所有支持的朋友。
Vere Perrot 資訊人.科技人.行銷人,現為軟體分析師。定位自己為網路觀察家,永遠保持好奇心與熱情,學習跨領域新事物,希望最終能成為一個全方位的人。 Mail: vereperrot@gmail.com
沒有留言:
張貼留言