Computer Vision training with synthetic data and multiple GPUs

Published On: October 24th, 2022
Hernan Cafiel
SHARE

One of the main elements for the development of technologies such as Computer Vision is the data. Information is one of the most valuable resources. Therefore, when it comes to training Deep Learning models for objects detection, data collection processes are usually inefficient options due to costs, sensitivity and time to process said information.

So in this article, we will explain how it is possible to generate synthetic data to scale training in multiple GPUs to get optimal results. So, we will show you how we made weapon detection solutions by generating artificial data using a Blender and training models in Amazon Web Service (AWS) to reduce testing time.

What is synthetic data?

Synthetic Data is a digital information that is artificially manufactured to mimic or simulate real-world and it is used to test Machine learning algorithms or to improve the performance of computer vision models.

synthetic data for gun detection model

Why use Synthetic Data? The problem with real data

Machine learning and Computer Vision projects require large types of datasets labeled with real world information.Therefore, the greater the amount of information, the better the performance of the model for training.

However, the process to acquire this data in some cases is difficult and the process of collecting and classifying the information is time consuming. Due to this, new techniques appear to generate synthetic data that have characteristics similar to real data.

When collecting real-world data, it’s necessary to keep in mind to filter out errors, convert files with disparate formats and information privacy.

How to generate synthetic data for trainning deep learning models in Blender?

Blender is a multi- platform software, dedicated to the creation, modeling, lighting, animation and rendering of three-dimensional graphics, capable of generating realistic models with high texturing and details levels, simulating visual images that are almost the same as reality.

Blender Model

For this reason, Blender is the perfect solution to get synthetic data generation. This tool offers a high feature, which gives us the ability to add custom scripts allowing us to control almost all of Blender’s.

To carry out a synthetic sample generation process for object detection, a dataset containing many samples of that object in different light, visual and perspective conditions is required.

Model in differente condition

Once we have defined our object, it is necessary to establish the location of the points of light and the views of the cameras, applying it to different scenes depending on the position of the camera.

Then, in the “Scripting” tab, we will create an algorithm that will take pictures automatically in different positions with different light conditions of our object in each of the previously defined scenes. All these images are labeled with their own metadata.

Data augmentation

Is a Technique to increse the amount of data by adding slightly modified copies of each images. This method increse the diversity of the training set by randomly change the original photo conditions.

In addition to the data augmentation generated by the blender script, also for this project we used Albumentation, a computer vision tool as a Python library to boosts the quality and performance of trained models. This is achieved by adding variations to the image such as: brightness, contrast, saturation, blur, noise and more.

For this weapon classification prototype, we use Albumentation API to improve the amount of guns and knife images. This mean that we collect total amount of 300.000 samples ready for training with multiple GPUs in TensorFlow.

data augmentation

What is TensorFlow?

Before getting into distributed training, it is necessary to know what this training platform tool is about.

TensorFlow is a open source library created by Google, to build end-to-end automatic Machine Learning models. This Platform is capable to build and train Neural Networks to detect and decipher patterns and correlations, analogous to the learning and reasoning used by humans.

Custom Artificial Intelligence Solutions

We provide outsourcing services for custom AI and Computer Vision development solutions.

Artificial Intelligence

Distributed Training with TensorFlow

We had to use a TensorFlow API for training in multiples GPU. With this library you can distribute existing models and codes.

Multi GPU Training TensorFlow

In the previous image, a screenshot of the training of our weapon detector prototype with all 300.000 models is shown, using 8 Nvidia Tesla V100 graphics cards, running on S3 instances in Amazon Web Service (AWS).

With these GPU characteristics, training was achieved in just 40 minutes.

Testing with real model in mobile prototype

Now we will show the weapon classification prototype installed and working on Android phone front face camera with 5 FPS of frame rate.

Results

The weapon recognition results was satisfactory and the scalability of synthetic data generation optained optimal results. Also, using amazon instances for distributed training greatly optimized training times.

These were the results obtained:

  • The number of samples for the dataset was increased, going from 40,000 to 300,000 samples ready for training.
  • The use of multiple Tesla GPUs allowed to reduce and optimize training times, going from hours to just 40 minutes.
  • A prototype was built through an Android application capable of detecting handguns and knives in real time.
  • After performing different training tests, an accuracy of 70% was obtained for the weapon classification.

The use of optimized training methods that we have shown you, making use of multiple GPUs and discovering synthetic data, allows us to accelerate development processes of applications and computer vision solutions for our clients and projects.

If you want to improve the performance of your company with Artificial Intelligence, or you want a team to develop your next custom AI solutions, contact us or schedule a free consultation.

We want to turn your project into reality

Contact us or get free consultation for your software development.

One Comment

  1. Anna November 22, 2022 at 4:44 am - Reply

    Interesting post, thanks for sharing.

Leave A Comment