Giter VIP home page Giter VIP logo

computer-vision-synthetic-data-generation's Introduction

Synthetic Data Generation for Object Detection and Instance Segmentation

Output Example

This code allows you to create a synthetic data-set, for Instance Segmentation or Object Detection. The data_generation.py script outputs data in LabelMe format, which can also be converted to other formats like the COCO JSON format.

Installation

  1. Clone the repository git clone https://github.com/TannerGilbert/Object-Detection-Synthetic-Data-Generation

  2. Install dependencies

    cd Object-Detection-Synthetic-Data-Generation
    pip3 install -r requirements.txt
    

Creating input data

Before you can start generating your synthetic data-set, you'll have to get some input images. You'll need to kinds of input images:

  • Foreground images
  • Background images

For background images, you can take some pictures or download them from the internet (no additional processing needed). For the foreground images, you'll have to take pictures of the object and then remove the image's background.

I recommend labeling a few images with LabelMe and then run my create_input_images_from_labelme.py script to extract the objects. For more information check out create_input_images_with_labelme.md.

You can also make use of a tool look Photoshop or GIMP.

Generating images

To generate images, run the data_generation.py script.

usage: data_generation.py [-h] --input_dir INPUT_DIR --output_dir OUTPUT_DIR
                          [--augmentation_path AUGMENTATION_PATH]
                          --image_number IMAGE_NUMBER
                          [--max_objects_per_image MAX_OBJECTS_PER_IMAGE]
                          [--image_width IMAGE_WIDTH]
                          [--image_height IMAGE_HEIGHT]

Synthetic Image Generator

optional arguments:
  -h, --help            show this help message and exit
  --input_dir INPUT_DIR
                        Path to the input directory. It must contain a
                        backgrounds directory and a foregrounds directory
  --output_dir OUTPUT_DIR
                        The directory where images and label files will be
                        placed
  --augmentation_path AUGMENTATION_PATH
                        Path to albumentations augmentation pipeline file
  --image_number IMAGE_NUMBER
                        Number of images to create
  --max_objects_per_image MAX_OBJECTS_PER_IMAGE
                        Maximum number of objects per images
  --image_width IMAGE_WIDTH
                        Width of the output images
  --image_height IMAGE_HEIGHT
                        Height of the output images

Example: python data_generation.py --input_dir input/ --output_dir output/ --image_number 50

Converting output into other formats

If the LabelMe format doesn't work for you, you can convert the data into another format.

Convert to COCO

You can convert the JSON files created by labelme to COCO using the labelme2coco.py file created by Github user Tony607.

Inspired by / Based on

computer-vision-synthetic-data-generation's People

Contributors

tannergilbert avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.