brew install socat
- Download and install xquartz https://www.xquartz.org/
- Setting
open -a XQuartz
then config “allow connections from network clients” is checked “on” on Security tab of Preferences (Source: https://cntnr.io/running-guis-with-docker-on-mac-os-x-a14df6a76efc) docker-compose pull
sh run
or
docker-compose run --rm app python app/app.py
after start socat & XQuartz
or
sh run python app/detect.py
to run a custom command
sh run python app/detect.py
sh run darknet detect cfg/yolo.cfg yolo.weights data/dog.jpg
sh run darknet detector demo cfg/coco.data cfg/yolo.cfg yolo.weights app/storage/sample.mp4
sh run darknet detector test cfg/voc.data cfg/tiny-yolo-voc.cfg tiny-yolo-voc.weights data/dog.jpg
sh run darknet detector demo cfg/voc.data cfg/tiny-yolo-voc.cfg tiny-yolo-voc.weights app/storage/sample.mp4
Learn more: https://pjreddie.com/darknet/yolo/#train-voc
-
Get The Pascal VOC Data Download files and unzip to
train
folder -
Generate Labels for VOC
docker-compose run --rm app bash -c "cd app/train && python voc_label.py"
-
Modify Cfg for Pascal Data I updated the config file in train/cfg/voc.data and volume it into docker
-
Download Pretrained Convolutional Weights Download file to
train
folder I've downloaded already darknet19_448.conv.23 file to /darknet -
Train The Model
docker-compose run --rm app ./darknet detector train app/train/cfg/voc.data cfg/yolo-voc.cfg darknet19_448.conv.23
- Train from a checkpoint
docker-compose run --rm app ./darknet detector train app/train/cfg/voc.data cfg/yolo-voc.cfg app/train/backup/yolo-voc.backup
- Example some detect
sh run darknet detect app/train/cfg/yolo-voc.cfg app/train/backup/yolo-voc.backup app/train/test.jpg -thresh 0.9
sh run darknet detect cfg/yolo.cfg yolo.weights app/train/test.jpg
sh run darknet detect cfg/yolo.cfg app/train/backup/yolo-voc_400.weights app/train/test.jpg
Learn more: https://timebutt.github.io/static/how-to-train-yolov2-to-detect-custom-objects/
- Prepare dataset for training Use crawler to search image from google
docker-compose run --rm se npm install
docker-compose run --rm -T se node crawler
- Run BBox Tool to label image
sh run bblt
- Name folder with 001, 002, .. respectively with class
- Subfolder in Examples, Images, Labels with 001, 002, .. is required
- See more in tutorial
- BBox only see images with '.JPEG' ext
rename 's/\.jpeg/\.jpg/' *.jpeg && rename 's/\.jpg/\.JPEG/' *.jpg
Rename from jpeg to JPEG
- Run convert format from BBox to Yolo
docker-compose run --rm app bash -c "cd app/train && python bblt2yolo.py"
The output is a folder named Labels/voc// what list bounding box of objects in txt files. Copy the files to your Images// folder. We will have images and txt file in same together
- Spliting for training set and test set
docker-compose run --rm app bash -c "cd app/train && python split.py"
The output is 2 txt file: train.txt and test.txt. Name is itself explanation
-
Configuration yolo Configed them in cfg/object*
-
Run train
docker-compose run --rm app ./darknet detector train app/train/cfg/obj.data app/train/cfg/obj.cfg darknet19_448.conv.23
Or continue train from a checkpoint
docker-compose run --rm app ./darknet detector train app/train/cfg/obj.data app/train/cfg/obj.cfg app/train/backup/obj.backup
- Test
sh run darknet detector test app/train/cfg/obj.data app/train/cfg/obj.cfg app/train/backup/obj.backup app/train/Images/001/1-0.jpeg -thresh 0.9
có 1 vài output quan trọng trong quá trình train:
- Region Avg IOU: 0.164715 càng tiến về 1 càng tốt, tức là tỉ lệ giao hợp càng gần 100% càng tốt
- 426.823456 avg: trung bình lỗi càng thấp càng tốt, 0.060730 avg, you can stop training
- kết quả sau khi train nằm trong folder backup định nghĩa trong config, ở trường hợp của mình là sau mỗi 100 iteration thì nó backup 1 lần để làm checkpoint