Image-to-Image Editing
Image-to-Image Editing
🎨 Data Designer Tutorial: Image-to-Image Editing
📚 What you'll learn
This notebook shows how to chain image generation columns: first generate animal portraits from text, then edit those generated images by adding accessories and changing styles—all without loading external datasets.
- 🖼️ Text-to-image generation: Generate images from text prompts
- 🔗 Chaining image columns: Use
ImageContextto pass generated images to a follow-up editing column - 🎲 Sampler-driven diversity: Combine sampled accessories and settings for varied edits
This tutorial uses an autoregressive model (one that supports both text-to-image and image-to-image generation via the chat completions API). Diffusion models (DALL·E, Stable Diffusion, etc.) do not support image context—see Tutorial 5 for text-to-image generation with diffusion models.
Prerequisites: This tutorial uses OpenRouter with the Flux 2 Pro model. Set
OPENROUTER_API_KEYin your environment before running.
If this is your first time using Data Designer, we recommend starting with the first notebook in this tutorial series.
📦 Import Data Designer
data_designer.configprovides the configuration API.DataDesigneris the main interface for generation.
⚙️ Initialize the Data Designer interface
We initialize Data Designer without arguments here—the image model is configured explicitly in the next cell.
🎛️ Define an image model
We need an autoregressive model that supports both text-to-image and image-to-image generation via the chat completions API. This lets us generate images from text and then pass those images as context for editing.
- Use
ImageInferenceParamsso Data Designer treats this model as an image generator. - Image-specific options are model-dependent; pass them via
extra_body.
Note: This tutorial uses the Flux 2 Pro model via OpenRouter. Set
OPENROUTER_API_KEYin your environment.
🏗️ Build the configuration
We chain two image generation columns:
- Sampler columns — randomly sample animal types, accessories, settings, and art styles
- First image column — generate an animal portrait from a text prompt
- Second image column with context — edit the generated portrait using
ImageContext
[18:02:45] [INFO] ✅ Validation passed
🔁 Preview: quick iteration
In preview mode, generated images are stored as base64 strings in the dataframe. Use this to iterate on your prompts, accessories, and sampler values before scaling up.
[18:02:45] [INFO] 🧐 Preview generation in progress
[18:02:45] [INFO] |-- 🔒 Jinja rendering engine: secure
[18:02:45] [INFO] ✅ Validation passed
[18:02:45] [INFO] ⛓️ Sorting column configs into a Directed Acyclic Graph
[18:02:45] [INFO] Skipping model health checks because DATA_DESIGNER_SKIP_MODEL_HEALTH_CHECKS=1
[18:02:45] [INFO] ⚡ Using async task-queue preview
[18:02:45] [INFO] 🖼️ image model config for column 'animal_portrait'
[18:02:45] [INFO] |-- model: 'black-forest-labs/flux.2-pro'
[18:02:45] [INFO] |-- model alias: 'image-model'
[18:02:45] [INFO] |-- model provider: 'openrouter'
[18:02:45] [INFO] |-- inference parameters:
[18:02:45] [INFO] | |-- generation_type=image
[18:02:45] [INFO] | |-- max_parallel_requests=4
[18:02:45] [INFO] | |-- extra_body={'height': 512, 'width': 512}[18:02:45] [INFO] 🖼️ image model config for column 'edited_portrait'
[18:02:45] [INFO] |-- model: 'black-forest-labs/flux.2-pro'
[18:02:45] [INFO] |-- model alias: 'image-model'
[18:02:45] [INFO] |-- model provider: 'openrouter'
[18:02:45] [INFO] |-- inference parameters:
[18:02:45] [INFO] | |-- generation_type=image
[18:02:45] [INFO] | |-- max_parallel_requests=4
[18:02:45] [INFO] | |-- extra_body={'height': 512, 'width': 512}[18:02:45] [INFO] ⚡️ Async generation: 2 column(s) (column 'animal_portrait', column 'edited_portrait'), 4 tasks across 1 row group(s)
[18:02:45] [INFO] 🚀 (1/1) Dispatching with 2 records
[18:02:45] [INFO] 🎲 (1/1) Preparing samplers to generate 2 records across 4 columns
[18:02:53] [INFO] 📊 Progress [8.0s]:
[18:02:53] [INFO] |-- 🐥 column 'animal_portrait': 1/2 (50%) 0.1 rec/s
[18:02:53] [INFO] |-- 🌧️ column 'edited_portrait': 0/2 (0%) 0.0 rec/s
[18:03:05] [INFO] 📊 Progress [20.0s]:
[18:03:05] [INFO] |-- 🐔 column 'animal_portrait': 2/2 (100%) 0.1 rec/s
[18:03:05] [INFO] |-- ⛅ column 'edited_portrait': 1/2 (50%) 0.1 rec/s
[18:03:06] [INFO] 📊 Progress [20.6s]:
[18:03:06] [INFO] |-- 🐔 column 'animal_portrait': 2/2 (100%) 0.1 rec/s
[18:03:06] [INFO] |-- ☀️ column 'edited_portrait': 2/2 (100%) 0.1 rec/s
[18:03:06] [INFO] ✅ Async generation complete [20.6s]: 4 ok, 0 failed across 2 column(s)
[18:03:06] [INFO] 📊 Model usage summary:
[18:03:06] [INFO] |-- model: black-forest-labs/flux.2-pro
[18:03:06] [INFO] |-- tokens: input=9210, output=12288, reasoning=0, total=21498, tps=1043
[18:03:06] [INFO] |-- requests: success=4, failed=0, total=4, rpm=11
[18:03:06] [INFO] |-- images: total=4
[18:03:06] [INFO] 📐 Measuring dataset column statistics:
[18:03:06] [INFO] |-- 🎲 column: 'animal'
[18:03:06] [INFO] |-- 🎲 column: 'accessory'
[18:03:06] [INFO] |-- 🎲 column: 'setting'
[18:03:06] [INFO] |-- 🎲 column: 'art_style'
[18:03:06] [INFO] |-- 🖼️ column: 'animal_portrait'
[18:03:06] [INFO] |-- 🖼️ column: 'edited_portrait'
[18:03:06] [INFO] 🍾 Preview complete!
Generated Columns ┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓ ┃ Name ┃ Value ┃ ┡━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┩ │ animal │ rabbit │ ├───────────────────────────────┼────────────────────────────────────────────────────────────────────────────┤ │ accessory │ a knitted beanie │ ├───────────────────────────────┼────────────────────────────────────────────────────────────────────────────┤ │ setting │ a tropical beach at sunset │ ├───────────────────────────────┼────────────────────────────────────────────────────────────────────────────┤ │ art_style │ a photorealistic style │ └───────────────────────────────┴────────────────────────────────────────────────────────────────────────────┘ Images ┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓ ┃ Name ┃ Preview ┃ ┡━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┩ │ animal_portrait │ [0] <base64, 1630548 chars> │ ├────────────────────────────────────────┼───────────────────────────────────────────────────────────────────┤ │ edited_portrait │ [0] <base64, 1685892 chars> │ └────────────────────────────────────────┴───────────────────────────────────────────────────────────────────┘
Generated Columns ┏━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓ ┃ Name ┃ Value ┃ ┡━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┩ │ animal │ dog │ ├──────────────────────────┼─────────────────────────────────────────────────────────────────────────────────┤ │ accessory │ a red bow tie │ ├──────────────────────────┼─────────────────────────────────────────────────────────────────────────────────┤ │ setting │ a photo studio with soft lighting │ ├──────────────────────────┼─────────────────────────────────────────────────────────────────────────────────┤ │ art_style │ a Disney Pixar 3D render │ └──────────────────────────┴─────────────────────────────────────────────────────────────────────────────────┘ Images ┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓ ┃ Name ┃ Preview ┃ ┡━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┩ │ animal_portrait │ [0] <base64, 1627676 chars> │ ├────────────────────────────────────────┼───────────────────────────────────────────────────────────────────┤ │ edited_portrait │ [0] <base64, 1358768 chars> │ └────────────────────────────────────────┴───────────────────────────────────────────────────────────────────┘
| animal | accessory | setting | art_style | animal_portrait | edited_portrait | |
|---|---|---|---|---|---|---|
| 0 | rabbit | a knitted beanie | a tropical beach at sunset | a photorealistic style | [iVBORw0KGgoAAAANSUhEUgAABAAAAAMACAIAAAA12IJaA... | [iVBORw0KGgoAAAANSUhEUgAABAAAAAMACAIAAAA12IJaA... |
| 1 | dog | a red bow tie | a photo studio with soft lighting | a Disney Pixar 3D render | [iVBORw0KGgoAAAANSUhEUgAABAAAAAMACAIAAAA12IJaA... | [iVBORw0KGgoAAAANSUhEUgAABAAAAAMACAIAAAA12IJaA... |
🔎 Compare original vs edited
Let's display the generated animal portraits next to their edited versions.
============================================================ Record 0: rabbit wearing a knitted beanie Setting: a tropical beach at sunset, Style: a photorealistic style ============================================================ 📷 Generated portrait:
🎨 Edited version:
============================================================ Record 1: dog wearing a red bow tie Setting: a photo studio with soft lighting, Style: a Disney Pixar 3D render ============================================================ 📷 Generated portrait:
🎨 Edited version:
🆙 Create at scale
In create mode, images are saved to disk in images/<column_name>/ folders with UUID filenames. The dataframe stores relative paths. ImageContext auto-detection handles this transparently—generated file paths are resolved to base64 before being sent to the model for editing.
[18:03:06] [INFO] OpenTelemetry metrics available at http://127.0.0.1:9464/metrics
[18:03:06] [INFO] 🎨 Creating Data Designer dataset
[18:03:06] [INFO] |-- 🔒 Jinja rendering engine: secure
[18:03:06] [INFO] ✅ Validation passed
[18:03:06] [INFO] ⛓️ Sorting column configs into a Directed Acyclic Graph
[18:03:06] [INFO] Skipping model health checks because DATA_DESIGNER_SKIP_MODEL_HEALTH_CHECKS=1
[18:03:06] [INFO] ⚡ Using async task-queue builder
[18:03:06] [INFO] 🖼️ image model config for column 'animal_portrait'
[18:03:06] [INFO] |-- model: 'black-forest-labs/flux.2-pro'
[18:03:06] [INFO] |-- model alias: 'image-model'
[18:03:06] [INFO] |-- model provider: 'openrouter'
[18:03:06] [INFO] |-- inference parameters:
[18:03:06] [INFO] | |-- generation_type=image
[18:03:06] [INFO] | |-- max_parallel_requests=4
[18:03:06] [INFO] | |-- extra_body={'height': 512, 'width': 512}[18:03:06] [INFO] 🖼️ image model config for column 'edited_portrait'
[18:03:06] [INFO] |-- model: 'black-forest-labs/flux.2-pro'
[18:03:06] [INFO] |-- model alias: 'image-model'
[18:03:06] [INFO] |-- model provider: 'openrouter'
[18:03:06] [INFO] |-- inference parameters:
[18:03:06] [INFO] | |-- generation_type=image
[18:03:06] [INFO] | |-- max_parallel_requests=4
[18:03:06] [INFO] | |-- extra_body={'height': 512, 'width': 512}[18:03:06] [INFO] ⚡️ Async generation: 2 column(s) (column 'animal_portrait', column 'edited_portrait'), 10 tasks across 1 row group(s)
[18:03:06] [INFO] 🚀 (1/1) Dispatching with 5 records
[18:03:06] [INFO] 🎲 (1/1) Preparing samplers to generate 5 records across 4 columns
[18:03:14] [INFO] 📊 Progress [7.7s]:
[18:03:14] [INFO] |-- 🥚 column 'animal_portrait': 1/5 (20%) 0.1 rec/s
[18:03:14] [INFO] |-- 🚶 column 'edited_portrait': 0/5 (0%) 0.0 rec/s
[18:03:25] [INFO] 📊 Progress [19.2s]:
[18:03:25] [INFO] |-- 🐔 column 'animal_portrait': 5/5 (100%) 0.3 rec/s
[18:03:25] [INFO] |-- 🚶 column 'edited_portrait': 0/5 (0%) 0.0 rec/s
[18:03:32] [INFO] 📊 Progress [25.8s]:
[18:03:32] [INFO] |-- 🐔 column 'animal_portrait': 5/5 (100%) 0.2 rec/s
[18:03:32] [INFO] |-- 🚗 column 'edited_portrait': 3/5 (60%) 0.1 rec/s
[18:03:38] [INFO] 📊 Progress [31.5s]:
[18:03:38] [INFO] |-- 🐔 column 'animal_portrait': 5/5 (100%) 0.2 rec/s
[18:03:38] [INFO] |-- 🚀 column 'edited_portrait': 5/5 (100%) 0.2 rec/s
[18:03:38] [INFO] ✅ Async generation complete [31.5s]: 10 ok, 0 failed across 2 column(s)
[18:03:38] [INFO] 📊 Model usage summary:
[18:03:38] [INFO] |-- model: black-forest-labs/flux.2-pro
[18:03:38] [INFO] |-- tokens: input=23015, output=30720, reasoning=0, total=53735, tps=1688
[18:03:38] [INFO] |-- requests: success=10, failed=0, total=10, rpm=18
[18:03:38] [INFO] |-- images: total=10
[18:03:38] [INFO] 📐 Measuring dataset column statistics:
[18:03:38] [INFO] |-- 🎲 column: 'animal'
[18:03:38] [INFO] |-- 🎲 column: 'accessory'
[18:03:38] [INFO] |-- 🎲 column: 'setting'
[18:03:38] [INFO] |-- 🎲 column: 'art_style'
[18:03:38] [INFO] |-- 🖼️ column: 'animal_portrait'
[18:03:38] [INFO] |-- 🖼️ column: 'edited_portrait'
| animal | accessory | setting | art_style | animal_portrait | edited_portrait | |
|---|---|---|---|---|---|---|
| 0 | rabbit | a red bow tie | a tropical beach at sunset | a pop art poster | ['images/animal_portrait/8b52c8ce-3bdf-48e0-a2... | ['images/edited_portrait/d60feb5f-fe20-4849-a7... |
| 1 | fox | a knitted beanie | a red carpet event | a Disney Pixar 3D render | ['images/animal_portrait/d608e518-6105-4e51-bf... | ['images/edited_portrait/7a3ad06c-bf7b-4982-a8... |
| 2 | dog | a flower crown | a cozy living room | a photorealistic style | ['images/animal_portrait/2d50c171-4bbf-4d44-a2... | ['images/edited_portrait/a751b750-ca3d-4aa9-92... |
| 3 | panda | a knitted beanie | a photo studio with soft lighting | a pop art poster | ['images/animal_portrait/c4841d13-bb8a-49b8-a3... | ['images/edited_portrait/666e8159-658c-4d77-9e... |
| 4 | cat | a red bow tie | a holiday card backdrop with snowflakes | a Disney Pixar 3D render | ['images/animal_portrait/e61c3129-95c4-4bfc-8a... | ['images/edited_portrait/92a053a1-24bf-4a94-90... |
============================================================ Record 0: rabbit wearing a red bow tie Setting: a tropical beach at sunset, Style: a pop art poster ============================================================ 📷 Generated portrait:
🎨 Edited version:
============================================================ Record 1: fox wearing a knitted beanie Setting: a red carpet event, Style: a Disney Pixar 3D render ============================================================ 📷 Generated portrait:
🎨 Edited version:
============================================================ Record 2: dog wearing a flower crown Setting: a cozy living room, Style: a photorealistic style ============================================================ 📷 Generated portrait:
🎨 Edited version:
============================================================ Record 3: panda wearing a knitted beanie Setting: a photo studio with soft lighting, Style: a pop art poster ============================================================ 📷 Generated portrait:
🎨 Edited version:
============================================================ Record 4: cat wearing a red bow tie Setting: a holiday card backdrop with snowflakes, Style: a Disney Pixar 3D render ============================================================ 📷 Generated portrait:
🎨 Edited version:
⏭️ Next steps
- Experiment with different autoregressive models for image generation and editing
- Try more creative editing prompts (style transfer, background replacement, artistic filters)
- Combine image generation with text generation (e.g., generate captions using an LLM-Text column with
ImageContext) - Chain more than two image columns for multi-step editing pipelines
Related tutorials:
- The basics: samplers and LLM text columns
- Providing images as context: image-to-text with VLMs
- Generating images: text-to-image generation with diffusion models