- Download the TextRecognitionDataGenerator and place the unzipped folder in this repo (inside
CNN/
). I've added it to my filepath but placed it in the .gitignore as it's not our work.
- Move the
TextRecognitionDataGenerator/TextRecognitionDataGenerator/dicts/
andTextRecognitionDataGenerator/TextRecognitionDataGenerator/fonts/
folders to the same parent folder as shown above.
- Enter
CNN/
and runpython detection_generation.py [keyword]
to generate a detection training set with that specific word. As of now, the training set will be 10,000 images strong. This can be edited viadetection_generation.py
. The training set will be saved indata_generation/pictures
and the corresponding xml files will be stored indata_generation/labels
. This data is not tracked by github.
- We are using the Yolo algorithm for the detection of shop signs.
- Follow this tutorial to install OR
cd
into./darkflow
and runpython3 setup.py build_ext --inplace
- Download ckpt folder and place it into
./darkflow
from here - Download build_graph folder and place it into
./darkflow
from here - Download bin folder and place it into
./darkflow
from here
The steps below assume we want to use tiny YOLO and our dataset has 3 classes
-
Create a copy of the configuration file
tiny-yolo-voc.cfg
and rename it according to your preferencetiny-yolo-voc-3c.cfg
(It is crucial that you leave the originaltiny-yolo-voc.cfg
file unchanged, see below for explanation). -
In
tiny-yolo-voc-3c.cfg
, change classes in the [region] layer (the last layer) to the number of classes you are going to train for. In our case, classes are set to 3.... [region] anchors = 1.08,1.19, 3.42,4.41, 6.63,11.38, 9.42,5.11, 16.62,10.52 bias_match=1 classes=3 coords=4 num=5 softmax=1 ...
-
In
tiny-yolo-voc-3c.cfg
, change filters in the [convolutional] layer (the second to last layer) to num * (classes + 5). In our case, num is 5 and classes are 3 so 5 * (3 + 5) = 40 therefore filters are set to 40.... [convolutional] size=1 stride=1 pad=1 filters=40 activation=linear [region] anchors = 1.08,1.19, 3.42,4.41, 6.63,11.38, 9.42,5.11, 16.62,10.52 ...
-
Change
labels.txt
to include the label(s) you want to train on (number of labels should be the same as the number of classes you set intiny-yolo-voc-3c.cfg
file). In our case,labels.txt
will contain 3 labels.label1 label2 label3
-
Reference the
tiny-yolo-voc-3c.cfg
model when you train.flow --model cfg/tiny-yolo-voc-3c.cfg --load bin/tiny-yolo-voc.weights --train --annotation train/Annotations --dataset train/Images
-
Why should I leave the original
tiny-yolo-voc.cfg
file unchanged?When darkflow sees you are loading
tiny-yolo-voc.weights
it will look fortiny-yolo-voc.cfg
in your cfg/ folder and compare that configuration file to the new one you have set with--model cfg/tiny-yolo-voc-3c.cfg
. In this case, every layer will have the same exact number of weights except for the last two, so it will load the weights into all layers up to the last two because they now contain different number of weights.
-
Run
./flow --model ./cfg/tiny-yolo-voc-<CUSTOM INPUT>.cfg --load bin/tiny-yolo-voc.weights --train --dataset <DATASET DIRECTORY> --annotation <ANNOTATIONS DIRECTORY> --gpu 1.0
-
Run
python yolo_predict.py <DATA_DIRECTORY>
-> This will save the images with the bounding boxes to your desired save_dir or default:./darkflow/predictions/
.