luxonis / datadreamer

Creation of annotated datasets from scratch using Generative AI and Foundation Computer Vision models
Apache License 2.0
77 stars 5 forks source link

DataDreamer

License Open In Colab Project Video Blog Post

DataDreamer examples

πŸš€ Quickstart

To generate your dataset with custom classes, you need to execute only two commands:

pip install datadreamer
datadreamer --class_names person moon robot

🌟 Overview

DataDreamer is an advanced toolkit engineered to facilitate the development of edge AI models, irrespective of initial data availability. Distinctive features of DataDreamer include:

πŸ“œ Table of contents

πŸ› οΈ Features

πŸ’» Installation

There are two ways to install the datadreamer library:

Using pip:

To install with pip:

pip install datadreamer

Using Docker (for Linux/Windows):

Pull Docker Image from GHCR:

docker pull ghcr.io/luxonis/datadreamer:latest

Or build Docker Image from source:

# Clone the repository
git clone https://github.com/luxonis/datadreamer.git
cd datadreamer

# Build Docker Image
docker build -t datadreamer .

Run Docker Container (assuming it's GHCR image, otherwise replace ghcr.io/luxonis/datadreamer:latest with datadreamer)

Run on CPU:

docker run --rm -v "$(pwd):/app" ghcr.io/luxonis/datadreamer:latest --save_dir generated_dataset --device cpu

Run on GPU, make sure to have nvidia-docker installed:

docker run --rm --gpus all -v "$(pwd):/app" ghcr.io/luxonis/datadreamer:latest --save_dir generated_dataset --device cuda

These commands mount the current directory ($(pwd)) to the /app directory inside the container, allowing you to access files from your local machine.

βš™οΈ Hardware Requirements

To ensure optimal performance and compatibility with the libraries used in this project, the following hardware specifications are recommended:

πŸ“‹ Usage

The datadreamer/pipelines/generate_dataset_from_scratch.py (datadreamer command) script is a powerful tool for generating and annotating images with specific objects. It uses advanced models to both create images and accurately annotate them with bounding boxes for designated objects.

Run the following command in your terminal to use the script:

datadreamer --save_dir <directory> --class_names <objects> --prompts_number <number> [additional options]

or using a .yaml config file

datadreamer --config <path-to-config>

🎯 Main Parameters

πŸ”§ Additional Parameters

πŸ€– Available Models

Model Category Model Names Description/Notes
Prompt Generation Mistral-7B-Instruct-v0.1 Semantically rich prompts
TinyLlama-1.1B-Chat-v1.0 Tiny LM
Simple random generator Joins randomly chosen object names
Image Generation SDXL-1.0 Slow and accurate (1024x1024 images)
SDXL-Turbo Fast and less accurate (512x512 images)
SDXL-Lightning Fast and accurate (1024x1024 images)
Image Annotation OWLv2 Open-Vocabulary object detector
CLIP Zero-shot-image-classification

πŸ’‘ Example

datadreamer --save_dir path/to/save_directory --class_names person moon robot --prompts_number 20 --prompt_generator simple --num_objects_range 1 3 --image_generator sdxl-turbo

or using a .yaml config file (if arguments are provided with the config file in the command, they will override the ones in the config file):

datadreamer --save_dir path/to/save_directory --config configs/det_config.yaml

This command generates images for the specified objects, saving them and their annotations in the given directory. The script allows customization of the generation process through various parameters, adapting to different needs and hardware configurations.

See /configs folder for some examples of the .yaml config files.

πŸ“¦ Output

The dataset comprises two primary components: images and their corresponding annotations, stored as JSON files.


save_dir/
β”‚
β”œβ”€β”€ image_1.jpg
β”œβ”€β”€ image_2.jpg
β”œβ”€β”€ ...
β”œβ”€β”€ image_n.jpg
β”œβ”€β”€ prompts.json
└── annotations.json

πŸ“ Annotations Format

  1. Detection Annotations (detection_annotations.json):
{
  "image_path": {
    "boxes": [[x_min, y_min, x_max, y_max], ...],
    "labels": [label_index, ...]
  },
  ...
  "class_names": ["class1", "class2", ...]
}
  1. Classification Annotations (classification_annotations.json):
{
  "image_path": {
    "labels": [label_index, ...]
  },
  ...
  "class_names": ["class1", "class2", ...]
}

⚠️ Limitations

While the datadreamer library leverages advanced Generative models to synthesize datasets and Foundation models for annotation, there are inherent limitations to consider:

Despite these limitations, the datasets created by datadreamer provide a valuable foundation for developing and training models, especially for edge computing scenarios where data availability is often a challenge. The synthetic and annotated data should be seen as a stepping stone, granting a significant head start in the model development process.

πŸ“„ License

This project is licensed under the Apache License, Version 2.0 - see the LICENSE file for details.

The above license does not cover the models. Please see the license of each model in the table above.

πŸ™ Acknowledgements

This library was made possible by the use of several open-source projects, including Transformers, Diffusers, and others listed in the requirements.txt.

SD-XL 1.0 License SDXL-Turbo License