Code copied from https://github.com/pjreddie/darknet with the following additions:
added_scripts/create_txt_data.py
for creating .txt files for each trainig/test image
added_scripts/create_data.py
for creating one .txt-file with path to the training/test images
cfg/yolo-voc20-fox.cfg
configuration file for the network.
cfg/cropped_fox.names
contains the names for all classes to be trained. Only "fox" for now
cfg/cropped_fox.data
contains information on where the training data is located and where to store the weights
git clone https://github.com/idaswe/darknet
cd darknet
- copy images from http://iter.at/yolo-data to
data/logoso you get this structure:
darknet/data/logo/cropped_fox/train
darknet/data/logo/cropped_fox/test
darknet/data/logo/cropped_fox/few-tests
The folder few-tests is only used after training to test wheter the network works as expected
- YOLOv2 requires one .txt file per image, looking like this:
<class> <centerX> <centerY> <width> <height>
Make these files:
darknet/added_scripts$ python create_txt_data.py
You need to run this script twice, one for training and one for test (change from training to test in the file)
- YOLO needs to know where the training- and test data is. Generate two files,
darknet/cfg/cropped_fox_train.txt and darknet/cfg/cropped_fox_test.txt:
darknet/added_scripts$ python create_data.py
You'll need to run this script twice, (change train to test in the file)
- Have a look at
cfg/yolo-voc20-fox.cfgto see how the network is structured. During training, batch should be 64 and subdivision 8, but when testing the network they should both be set to 1. If you're training multiple classes, set filters (line 224) to be (#classes + 5) * 5, and classes (line 230) to be #classes
- Have a look at
cfg/cropped_fox.namesandcfg/cropped_fox.data
- change
exapmles/detector.cline 138 to save more weights than only each 10.000 batch
- Compile darknet:
darknet$ make(if you're using GPU and CUDNN, change line 1 and 2)
darknet$ mkdir backup/cropped_fox(this is the folder we've pointed at in cfg/cropped_fox.data)
- Train the network:
darknet$ ./darknet detector train cfg/cropped_fox.data cfg/yolo-voc20-fox.cfg
- Waiiit
- Test the network:
darknet$ ./darknet detector test cfg/cropped_fox.data cfg/yolo-voc20-fox.cfg <path_to_weights> <path_to_image>