Skip to main content
Open in Google Colab This notebook explores how we can use generative AI to create datasets which don’t exist yet. This can be a good starting point for your project if you have not collected or cannot collect the data required. It is important to note the limitations of generative AI still apply here, biases can be introduced through your prompts, results can include “hallucinations” and quality control is important. This example uses the OpenAI API to call the Dall-E image generation tool, it explores both generation and variation but there are other tools such as editing which could also be useful for augmenting an existing dataset. There is also a video version of this tutorial:
We have wrapped this example into a Transformation Block (Enterprise Feature) to make it even easier to generate images and upload them to your organization. See: https://github.com/edgeimpulse/example-transform-Dall-E-images

Local Software Requirements

Set up OpenAI API

First off you will need to set up and Edge Impulse account and create your first project. You will also need to create an API Key for OpenAI: https://platform.openai.com/docs/api-reference/authentication

Generate your first image

The API takes in a prompt, number of images and a size

Generate some variations of this image

The API also has a variations call which takes in an existing images and creates variations of it. This could also be used to modify existing images.

Generate a dataset:

Here we are iterate through a number of images and variations to generate a dataset based on the prompts/labels given.

Plot all the output images:

Images generated from the script

These files can then be uploaded to a project with these commands (run in a separate terminal window):
(run edge-impulse-uploader —clean if you have used the CLI before to reset the target project)

What next?

Now you can use your images to create an image classification model on Edge Impulse. Why not try some other OpenAI calls, ‘edit’ could be used to take an existing image and translate it into different environments or add different humans to increase the variety of your dataset. https://developers.openai.com/api/docs/guides/image-generation