This simple repository provides implementation of full-image dataset generator. Resulting synthetic dataset is supposed to be used for CNN (primary single-shot detector) training.
- OpenCV 3.x and higher
Tool works on simple principle of placing objects to the background images on the random positions and can work in two slightly different ways, depending on what type of data is available for your use-case.
Cropped objects (used for classifier training) are placed to the images of background using Poisson blending [1].
Cropped traffic sign placed to the background with (right) and without (left) Poisson blending:
Before transparent objects are placed into background, few effects are applied to synthetically modify appearance of the object. Whether or not are the effects applied is based on chosen probability (reflecting real-time conditions).
List of applied effects:
- Rotation in X, Y, Z axis
- Brightness modification (according to the brightness of the background)
- Gamma correction
- Blur
- Noise (Salt and papper, Gaussian)
- ROI selection
- Resize of the objects
- Hue modification
- Brightness gradient
- Object overlapping
- Flipping (but be aware: some objscts may have different meaning, e.g. left and right arrow, hand, etc.)
Visual representation of most effects applied on the traffic sign separatelly (original image in the top left corner):
Then objects are placed into background:
In general, second approach has better results. Combination of both approaches does not work better. By far the best results have been achieved using combination of many synthetic images in combination with few real labeled images, which keeps training in the right direction.
This tool is using YOLO [2] annotation format:
<object_class> <x> <y> <width> <height>
Both, object oordinates and size are relative - values in the interval (0,1) - to the full image size.
- Place images of the backgrounds (where objects should be placed - in case of the traffic signs, images should originate from the city environment, but cannot contain any of the generated objects - they would miss the annotation and so negativelly bias the training process) to the
data/backgrounds
folder - In case of using transparent objects, place them to the
data/transparent
folder, otherwise to thedata/cropped
folder. Place files of each class to separate folders and save unique class name to theimgClass
file located in the same folder - In the Makefile, select (comment/uncomment) effects you want to be applied
- Type
make
in the root folder - In case of using transparent objects, type
make runt
, otherwisemake runc
- Generated dataset should be in the
out
folder
Video evaluated using model trained on the traffic sign synthetic dataset generated by this tool:
- Load both - selected effects and applied value ranges from the configuration file.
- For more realistic synthetic dataset, perform 3D analyzation of the both background image and object to be placed to the background.
- Further research on synthetic dataset CNN training (i.e. what does bias the training, what improves the overall performance, etc.)