This is a transformation block that uses DALL-E 3 to generate synthetic data for your Edge Impulse project.
The Studio now has a feature for interacting with Synthetic Data directly from the Studio; and the DALL-E 3 block is available there.
-
Go to a Professional or Enterprise project, choose Data acquisition > Synthetic data.
-
Select the 'DALL-E 3 Synthetic Image Generator' block, fill in your prompt and label, and hit Generate data.
You currently need an OpenAI API Key, see https://platform.openai.com/docs/api-reference/authentication
-
Your synthetic data will show on the right side, for quick evaluation of your prompt.
You can modify this repository and push it as a new custom Synthetic Data transformation block.
-
Install the Edge Impulse CLI.
-
Open a command prompt or terminal, and navigate to this folder.
-
Create a new transformation block:
$ edge-impulse-blocks init ? Choose a type of block: Transformation block ? Choose an option: Create a new block ? Enter the name of your block: Custom DALL-E Image Generator ? Enter the description of your block: Use the DALL-E API to generate new images. ? What type of data does this block operate on? Standalone (runs the container, but no files / data items passed in) ? Which buckets do you want to mount into this block (will be mounted under /mnt/s3fs/BUCKET_NAME, you can change these mount points in the St udio)? ? Would you like to download and load the example repository? no
-
Push the block:
$ edge-impulse-blocks push
-
To show this block in Synthetic Data:
-
You can now access your modified block from Data acquisition > Synthetic data on any enterprise project.
-
Install the dependencies:
pip3 install -r requirements.txt
-
Run the generate script:
OPENAI_API_KEY=sk-... EI_PROJECT_API_KEY=ei_034... python3 transform.py --prompt "A photo of a factory worker wearing a hard hat" --label "hard_hat" --images 3
Replace
sk-...
with a valid OpenAI API Key, and replaceei_034...
with your Edge Impulse API Key (Dashboard > Keys). -
Output is stored both in
output/
and uploaded to your Edge Impulse project.
If you want to build your own custom Synthetic Data block, you'll need to parse the (optional) --synthetic-data-job-id
argument. When uploading data to the ingestion service you need to then pass the value from this argument to the x-synthetic-data-job-id
header. transform.py implements this. This is required so we know which job generated what data, and is used to render the UI on the Synthetic Data page.