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
[00:35:19] [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.
[00:35:19] [INFO] 📺 Preview generation in progress
[00:35:19] [INFO] |-- 🔒 Jinja rendering engine: secure
[00:35:19] [INFO] ✅ Validation passed
[00:35:19] [INFO] ⛓️ Sorting column configs into a Directed Acyclic Graph
[00:35:19] [INFO] Skipping model health checks because DATA_DESIGNER_SKIP_MODEL_HEALTH_CHECKS=1
[00:35:19] [INFO] ⚡ Using async task-queue preview
[00:35:19] [INFO] 🖼️ image model config for column 'animal_portrait'
[00:35:19] [INFO] |-- model: 'black-forest-labs/flux.2-pro'
[00:35:19] [INFO] |-- model alias: 'image-model'
[00:35:19] [INFO] |-- model provider: 'openrouter'
[00:35:19] [INFO] |-- inference parameters:
[00:35:19] [INFO] | |-- generation_type=image
[00:35:19] [INFO] | |-- max_parallel_requests=4
[00:35:19] [INFO] | |-- extra_body={'height': 512, 'width': 512}[00:35:19] [INFO] 🖼️ image model config for column 'edited_portrait'
[00:35:19] [INFO] |-- model: 'black-forest-labs/flux.2-pro'
[00:35:19] [INFO] |-- model alias: 'image-model'
[00:35:19] [INFO] |-- model provider: 'openrouter'
[00:35:19] [INFO] |-- inference parameters:
[00:35:19] [INFO] | |-- generation_type=image
[00:35:19] [INFO] | |-- max_parallel_requests=4
[00:35:19] [INFO] | |-- extra_body={'height': 512, 'width': 512}[00:35:19] [INFO] ⚡️ Async generation: 2 column(s) (column 'animal_portrait', column 'edited_portrait'), 4 tasks across 1 row group(s)
[00:35:19] [INFO] 🚀 (1/1) Dispatching with 2 records
[00:35:19] [INFO] 🎲 (1/1) Preparing samplers to generate 2 records across 4 columns
[00:35:28] [INFO] 📊 Progress [8.1s]:
[00:35:28] [INFO] |-- 🚗 column 'animal_portrait': 1/2 (50%) 0.1 rec/s
[00:35:28] [INFO] |-- 🐱 column 'edited_portrait': 0/2 (0%) 0.0 rec/s
[00:35:39] [INFO] 📊 Progress [19.4s]:
[00:35:39] [INFO] |-- 🚀 column 'animal_portrait': 2/2 (100%) 0.1 rec/s
[00:35:39] [INFO] |-- 😸 column 'edited_portrait': 1/2 (50%) 0.1 rec/s
[00:35:40] [INFO] 📊 Progress [20.3s]:
[00:35:40] [INFO] |-- 🚀 column 'animal_portrait': 2/2 (100%) 0.1 rec/s
[00:35:40] [INFO] |-- 🦁 column 'edited_portrait': 2/2 (100%) 0.1 rec/s
[00:35:40] [INFO] ✅ Async generation complete [20.3s]: 4 ok, 0 failed across 2 column(s)
[00:35:40] [INFO] 📊 Model usage summary:
[00:35:40] [INFO] |-- model: black-forest-labs/flux.2-pro
[00:35:40] [INFO] |-- tokens: input=9208, output=12288, reasoning=0, total=21496, tps=1060
[00:35:40] [INFO] |-- requests: success=4, failed=0, total=4, rpm=11
[00:35:40] [INFO] |-- images: total=4
[00:35:40] [INFO] 📐 Measuring dataset column statistics:
[00:35:40] [INFO] |-- 🎲 column: 'animal'
[00:35:40] [INFO] |-- 🎲 column: 'accessory'
[00:35:40] [INFO] |-- 🎲 column: 'setting'
[00:35:40] [INFO] |-- 🎲 column: 'art_style'
[00:35:40] [INFO] |-- 🖼️ column: 'animal_portrait'
[00:35:40] [INFO] |-- 🖼️ column: 'edited_portrait'
[00:35:40] [INFO] 🥳 Preview complete!
Generated Columns ┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓ ┃ Name ┃ Value ┃ ┡━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┩ │ animal │ panda │ ├───────────────────────────────────┼────────────────────────────────────────────────────────────────────────┤ │ accessory │ oversized sunglasses │ ├───────────────────────────────────┼────────────────────────────────────────────────────────────────────────┤ │ setting │ a red carpet event │ ├───────────────────────────────────┼────────────────────────────────────────────────────────────────────────┤ │ art_style │ a watercolor painting │ └───────────────────────────────────┴────────────────────────────────────────────────────────────────────────┘ Images ┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓ ┃ Name ┃ Preview ┃ ┡━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┩ │ animal_portrait │ [0] <base64, 1491920 chars> │ ├────────────────────────────────────────┼───────────────────────────────────────────────────────────────────┤ │ edited_portrait │ [0] <base64, 2035008 chars> │ └────────────────────────────────────────┴───────────────────────────────────────────────────────────────────┘
Generated Columns ┏━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓ ┃ Name ┃ Value ┃ ┡━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┩ │ animal │ fox │ ├──────────────────────────┼─────────────────────────────────────────────────────────────────────────────────┤ │ accessory │ a tiny top hat │ ├──────────────────────────┼─────────────────────────────────────────────────────────────────────────────────┤ │ setting │ a photo studio with soft lighting │ ├──────────────────────────┼─────────────────────────────────────────────────────────────────────────────────┤ │ art_style │ a Disney Pixar 3D render │ └──────────────────────────┴─────────────────────────────────────────────────────────────────────────────────┘ Images ┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓ ┃ Name ┃ Preview ┃ ┡━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┩ │ animal_portrait │ [0] <base64, 1883272 chars> │ ├────────────────────────────────────────┼───────────────────────────────────────────────────────────────────┤ │ edited_portrait │ [0] <base64, 1573420 chars> │ └────────────────────────────────────────┴───────────────────────────────────────────────────────────────────┘
| animal | accessory | setting | art_style | animal_portrait | edited_portrait | |
|---|---|---|---|---|---|---|
| 0 | panda | oversized sunglasses | a red carpet event | a watercolor painting | [iVBORw0KGgoAAAANSUhEUgAABAAAAAMACAIAAAA12IJaA... | [iVBORw0KGgoAAAANSUhEUgAABAAAAAMACAIAAAA12IJaA... |
| 1 | fox | a tiny top hat | 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: panda wearing oversized sunglasses Setting: a red carpet event, Style: a watercolor painting ============================================================ 📷 Generated portrait:
🎨 Edited version:
============================================================ Record 1: fox wearing a tiny top hat 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.
[00:35:40] [INFO] OpenTelemetry metrics available at http://127.0.0.1:9464/metrics
[00:35:40] [INFO] 🎨 Creating Data Designer dataset
[00:35:40] [INFO] |-- 🔒 Jinja rendering engine: secure
[00:35:40] [INFO] ✅ Validation passed
[00:35:40] [INFO] ⛓️ Sorting column configs into a Directed Acyclic Graph
[00:35:40] [INFO] Skipping model health checks because DATA_DESIGNER_SKIP_MODEL_HEALTH_CHECKS=1
[00:35:40] [INFO] ⚡ Using async task-queue builder
[00:35:40] [INFO] 🖼️ image model config for column 'animal_portrait'
[00:35:40] [INFO] |-- model: 'black-forest-labs/flux.2-pro'
[00:35:40] [INFO] |-- model alias: 'image-model'
[00:35:40] [INFO] |-- model provider: 'openrouter'
[00:35:40] [INFO] |-- inference parameters:
[00:35:40] [INFO] | |-- generation_type=image
[00:35:40] [INFO] | |-- max_parallel_requests=4
[00:35:40] [INFO] | |-- extra_body={'height': 512, 'width': 512}[00:35:40] [INFO] 🖼️ image model config for column 'edited_portrait'
[00:35:40] [INFO] |-- model: 'black-forest-labs/flux.2-pro'
[00:35:40] [INFO] |-- model alias: 'image-model'
[00:35:40] [INFO] |-- model provider: 'openrouter'
[00:35:40] [INFO] |-- inference parameters:
[00:35:40] [INFO] | |-- generation_type=image
[00:35:40] [INFO] | |-- max_parallel_requests=4
[00:35:40] [INFO] | |-- extra_body={'height': 512, 'width': 512}[00:35:40] [INFO] ⚡️ Async generation: 2 column(s) (column 'animal_portrait', column 'edited_portrait'), 10 tasks across 1 row group(s)
[00:35:40] [INFO] 🚀 (1/1) Dispatching with 5 records
[00:35:40] [INFO] 🎲 (1/1) Preparing samplers to generate 5 records across 4 columns
[00:35:48] [INFO] 📊 Progress [7.8s]:
[00:35:48] [INFO] |-- 🥚 column 'animal_portrait': 1/5 (20%) 0.1 rec/s
[00:35:48] [INFO] |-- 🥚 column 'edited_portrait': 0/5 (0%) 0.0 rec/s
[00:35:56] [INFO] 📊 Progress [16.1s]:
[00:35:56] [INFO] |-- 🐔 column 'animal_portrait': 5/5 (100%) 0.3 rec/s
[00:35:56] [INFO] |-- 🥚 column 'edited_portrait': 0/5 (0%) 0.0 rec/s
[00:36:07] [INFO] 📊 Progress [27.3s]:
[00:36:07] [INFO] |-- 🐔 column 'animal_portrait': 5/5 (100%) 0.2 rec/s
[00:36:07] [INFO] |-- 🐤 column 'edited_portrait': 4/5 (80%) 0.1 rec/s
[00:36:12] [INFO] 📊 Progress [31.7s]:
[00:36:12] [INFO] |-- 🐔 column 'animal_portrait': 5/5 (100%) 0.2 rec/s
[00:36:12] [INFO] |-- 🐔 column 'edited_portrait': 5/5 (100%) 0.2 rec/s
[00:36:12] [INFO] ✅ Async generation complete [31.7s]: 10 ok, 0 failed across 2 column(s)
[00:36:12] [INFO] 📊 Model usage summary:
[00:36:12] [INFO] |-- model: black-forest-labs/flux.2-pro
[00:36:12] [INFO] |-- tokens: input=23024, output=30720, reasoning=0, total=53744, tps=1682
[00:36:12] [INFO] |-- requests: success=10, failed=0, total=10, rpm=18
[00:36:12] [INFO] |-- images: total=10
[00:36:12] [INFO] 📐 Measuring dataset column statistics:
[00:36:12] [INFO] |-- 🎲 column: 'animal'
[00:36:12] [INFO] |-- 🎲 column: 'accessory'
[00:36:12] [INFO] |-- 🎲 column: 'setting'
[00:36:12] [INFO] |-- 🎲 column: 'art_style'
[00:36:12] [INFO] |-- 🖼️ column: 'animal_portrait'
[00:36:12] [INFO] |-- 🖼️ column: 'edited_portrait'
| animal | accessory | setting | art_style | animal_portrait | edited_portrait | |
|---|---|---|---|---|---|---|
| 0 | dog | a knitted beanie | a tropical beach at sunset | a watercolor painting | ['images/animal_portrait/c06f694d-3fb1-4bac-98... | ['images/edited_portrait/678a8f6c-b589-47c7-8c... |
| 1 | panda | a pirate hat and eye patch | a red carpet event | a Disney Pixar 3D render | ['images/animal_portrait/1e978e3c-2836-48cd-a6... | ['images/edited_portrait/06dfa2ce-3289-4259-b0... |
| 2 | rabbit | a monocle and mustache | a red carpet event | a pop art poster | ['images/animal_portrait/adf1b552-9022-4bf5-a3... | ['images/edited_portrait/e466cda8-0f70-4370-94... |
| 3 | dog | a pirate hat and eye patch | a holiday card backdrop with snowflakes | a photorealistic style | ['images/animal_portrait/2aaa83eb-51fe-4e9e-98... | ['images/edited_portrait/d1a4998d-c5f5-4a5a-83... |
| 4 | fox | a pirate hat and eye patch | a cozy living room | a photorealistic style | ['images/animal_portrait/3a37d26c-94d6-4ce5-a9... | ['images/edited_portrait/c76639a3-6bc3-411a-93... |
============================================================ Record 0: dog wearing a knitted beanie Setting: a tropical beach at sunset, Style: a watercolor painting ============================================================ 📷 Generated portrait:
🎨 Edited version:
============================================================ Record 1: panda wearing a pirate hat and eye patch Setting: a red carpet event, Style: a Disney Pixar 3D render ============================================================ 📷 Generated portrait:
🎨 Edited version:
============================================================ Record 2: rabbit wearing a monocle and mustache Setting: a red carpet event, Style: a pop art poster ============================================================ 📷 Generated portrait:
🎨 Edited version:
============================================================ Record 3: dog wearing a pirate hat and eye patch Setting: a holiday card backdrop with snowflakes, Style: a photorealistic style ============================================================ 📷 Generated portrait:
🎨 Edited version:
============================================================ Record 4: fox wearing a pirate hat and eye patch Setting: a cozy living room, Style: a photorealistic style ============================================================ 📷 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