- Install
tensorflow-gpu
by runningconda install -c anaconda tensorflow-gpu
- Install NVIDIA dependencies for using GPU https://gist.github.com/msis/108a74d08f55eed48d8521fa968851ea
- Clone the repo
git clone https://github.com/experiencor/basic-yolo-keras
- Make a
dataset
folder and organize your dataset within it into 4 folders:
- train_image_folder
- train_annot_folder : contains labels in VOC format (.xml)
- valid_image_folder
- valid_annot_folder : contains labels in VOC format (.xml)
- Edit the following fields within
config.json
:
"labels"
: put all the labels that exist in your dataset as a list (e.g. ["boat", "person", "bird"])- add the path to your dataset under
"train/valid_image_folder"
and"train/valid_annot_folder"
"saved_weights_name"
: give a nice name- (Optional)
"architecture"
: select from tiny yolo, full yolo, squeezenet, mobilenet, and inceptionV3
-
Download pretrained weights for backend (tiny yolo, full yolo, squeezenet, mobilenet, and inceptionV3) at: https://1drv.ms/f/s!ApLdDEW3ut5fec2OzK4S4RpT-SU and put the weights in the project's root. Keep the
"pretrained_weights"
field withinconfig.json
EMPTY. -
Generate anchors for your dataset:
python gen_anchors.py -c config.json
Copy the generated anchors printed on the terminal to the "anchors"
setting in config.json
.
- Warm up the network
- Set
warmup_epochs
in config.json to 3. python train.py -c config.json
This process saves the trained weights to the file specified in saved_weights_name
setting.
[Note: if there is a ResourceExhaustedError or MemoryError, try decreasing the "batch_size"
]
- Actual network training
- Set
pretrained_weights
setting inconfig.json
to the warmup weights (whatever insaved_weights_name
). - Set
warmup_epochs
in config.json to 0. python train.py -c config.json
By the end of this process, the code will write the weights of the best model to file best_weights.h5 (or whatever name specified in the setting "saved_weights_name" in the config.json file). The training process stops when the loss on the validation set is not improved in 3 consecutive epochs.
python predict.py -c config.json -w /path/to/best_weights.h5 -i /path/to/image/or/video
It carries out detection on the image and write the image with detected bounding boxes to the same folder.