/Computer-Vision-Database-Maker

Image database augmentation for object recognition model

Primary LanguagePython

Labelled Database Maker for Computer Vision

The aim of this project was to create a labelled image dataset automatically, rather than by hand, that could be used to train a model for object detection and landmark recognition. This method is a work-around to creating a labelled image dataset by hand, which can be a very long and tedious process.

This particular program generates images of playing cards on various backgrounds, with different positions and perspectives. It keeps track of the bounding box as well as the four corner coordinates of the cards, so that images are automatically labelled when it comes time to train the model.

Results

Here is a sample of the generated database :

These may not look like it, but they are generated images, not pictures taken by hand. You can have a look at /Database for a closer look at these, where you might detect some signs that they are not real.

The associated labels are saved in /XMLs.

I trained an object detection model in conjunction with a shape detection model using dlib 19.19. The trained models' predictions were suprisingly good using real images :

You can see that the positions of the four corners of the card are predicted quite accurately, and the model detects that there is a card on the image. You can have a look at /Results for more test results.

How it works

The program randomly picks a card and a background image from a set of available pictures (/Cards, /Backgrounds). It applies a number of rotation, perspective, and position transformations to the card image while keeping track of the corner and bounding box coordinates. Images are created until the disered sample size is reached.

Example of a card transformation :

Raw Image Transformed Image
Raw Transformed

Running it on your machine

You can use your own card and background images by replacing those in /Cards and /Backgrounds to your own. You will need to use the Dlib python templates (linked in the Results section) to train and test your models. During training, you need to copy and paste the labelled information from /XMLs/Box_points.txt to the corresponding train and test XMLs templates provided.

You will also need the following libraries :

Acknowledgments

Thank you to DeepLearning.ai, Luca Anzalone, Dlib, and many more for inspiration and guidance.