Dataset is shuffled and split in 2100/450/450 (train/val/test).
Then the images containing tomato bbox (394 such images) in training are upsampled, and final training size is 4061 (1706 without tomatoes + 2355 with tomatoes images).
batch=32
; subdivisions=16
; width=640
; height=640
; momentum=0.9
; decay=0.0005
;
learning_rate=0.001
weights are initialized with darknet53 model trained on Imagenet.
wget https://pjreddie.com/media/files/darknet53.conv.74
to get it.
Error rate on test set = 0.11 with checkpoint in release checkpoint_0.3.
The detection threshold used is 0.15.
Note: Overfitting is not fully attained and better ER is possible with more iterations.
Simply python3 -m pip install .
or python3 -m pip install -r requirements.txt
You need OpenCV >= 2.4 for compiling darknet with opencv2 and be able to compute metrics. (https://docs.opencv.org/3.4/d7/d9f/tutorial_linux_install.html). Check then /usr/include/opencv2.
All images should be by default in ./data/assignment_imgs
img_annotations.json
should be in ./data
label_mapping.csv
should be also in ./data
or you can pass your own paths with --data-dir-path
,
--data-annotations-file_path
,
--labels-mapping-file-path
First transform the data in darknet format:
python3 -m tomato_dataset_tool
You could also upsample tomatoes for your training. Simply run instead:
python3 -m tomato_dataset_tool --upsample
All new files are located in ./data/formated
(including gt text files for classification, i.e. if an image contains
a tomato)
Once it's done, Install darknet:
python3 -m darknet_handler --install
Note: you can pass --gpu
to compile with gpu,
also you can pass --opencv2
to compile with opencv (need for testing and computing metrics)
Training:
python3 -m darknet_handler --train --ckpts-file-path <path>
Testing and look at error rate:
python3 -m darknet_handler --test --ckpts-file-path <path>
It will create preds.txt
in darknet-master directory. Then use compute_metrics.py to get the error rate:
python3 -m compute_metrics --yolo-output-filepath ./darknet-master/preds.txt --gt-filepath ./data/formated/test_gt.txt