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
[19:59:34] [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.
[19:59:34] [INFO] 🖼️ Preview generation in progress
[19:59:34] [INFO] |-- 🔒 Jinja rendering engine: secure
[19:59:34] [INFO] ✅ Validation passed
[19:59:34] [INFO] ⛓️ Sorting column configs into a Directed Acyclic Graph
[19:59:34] [INFO] Skipping model health checks because DATA_DESIGNER_SKIP_MODEL_HEALTH_CHECKS=1
[19:59:34] [INFO] ⚡ Using async task-queue preview
[19:59:34] [INFO] 🖼️ image model config for column 'animal_portrait'
[19:59:34] [INFO] |-- model: 'black-forest-labs/flux.2-pro'
[19:59:34] [INFO] |-- model alias: 'image-model'
[19:59:34] [INFO] |-- model provider: 'openrouter'
[19:59:34] [INFO] |-- inference parameters:
[19:59:34] [INFO] | |-- generation_type=image
[19:59:34] [INFO] | |-- max_parallel_requests=4
[19:59:34] [INFO] | |-- extra_body={'height': 512, 'width': 512}[19:59:34] [INFO] 🖼️ image model config for column 'edited_portrait'
[19:59:34] [INFO] |-- model: 'black-forest-labs/flux.2-pro'
[19:59:34] [INFO] |-- model alias: 'image-model'
[19:59:34] [INFO] |-- model provider: 'openrouter'
[19:59:34] [INFO] |-- inference parameters:
[19:59:34] [INFO] | |-- generation_type=image
[19:59:34] [INFO] | |-- max_parallel_requests=4
[19:59:34] [INFO] | |-- extra_body={'height': 512, 'width': 512}[19:59:34] [INFO] ⚡️ Async generation: 2 column(s) (column 'animal_portrait', column 'edited_portrait'), 4 tasks across 1 row group(s)
[19:59:34] [INFO] 🚀 (1/1) Dispatching with 2 records
[19:59:34] [INFO] 🎲 (1/1) Preparing samplers to generate 2 records across 4 columns
[19:59:41] [INFO] 📊 Progress [6.8s]:
[19:59:41] [INFO] |-- 😐 column 'animal_portrait': 1/2 (50%) 0.1 rec/s
[19:59:41] [INFO] |-- 😴 column 'edited_portrait': 0/2 (0%) 0.0 rec/s
[19:59:52] [INFO] 📊 Progress [18.5s]:
[19:59:52] [INFO] |-- 🤩 column 'animal_portrait': 2/2 (100%) 0.1 rec/s
[19:59:52] [INFO] |-- 😐 column 'edited_portrait': 1/2 (50%) 0.1 rec/s
[19:59:53] [INFO] 📊 Progress [18.7s]:
[19:59:53] [INFO] |-- 🤩 column 'animal_portrait': 2/2 (100%) 0.1 rec/s
[19:59:53] [INFO] |-- 🤩 column 'edited_portrait': 2/2 (100%) 0.1 rec/s
[19:59:53] [INFO] ✅ Async generation complete [18.7s]: 4 ok, 0 failed across 2 column(s)
[19:59:53] [INFO] 📊 Model usage summary:
[19:59:53] [INFO] |-- model: black-forest-labs/flux.2-pro
[19:59:53] [INFO] |-- tokens: input=9204, output=12288, reasoning=0, total=21492, tps=1146
[19:59:53] [INFO] |-- requests: success=4, failed=0, total=4, rpm=12
[19:59:53] [INFO] |-- images: total=4
[19:59:53] [INFO] 📐 Measuring dataset column statistics:
[19:59:53] [INFO] |-- 🎲 column: 'animal'
[19:59:53] [INFO] |-- 🎲 column: 'accessory'
[19:59:53] [INFO] |-- 🎲 column: 'setting'
[19:59:53] [INFO] |-- 🎲 column: 'art_style'
[19:59:53] [INFO] |-- 🖼️ column: 'animal_portrait'
[19:59:53] [INFO] |-- 🖼️ column: 'edited_portrait'
[19:59:53] [INFO] 🙌 Preview complete!
Generated Columns ┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓ ┃ Name ┃ Value ┃ ┡━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┩ │ animal │ cat │ ├────────────────────────────────┼───────────────────────────────────────────────────────────────────────────┤ │ accessory │ a monocle and mustache │ ├────────────────────────────────┼───────────────────────────────────────────────────────────────────────────┤ │ setting │ a cozy living room │ ├────────────────────────────────┼───────────────────────────────────────────────────────────────────────────┤ │ art_style │ a Disney Pixar 3D render │ └────────────────────────────────┴───────────────────────────────────────────────────────────────────────────┘ Images ┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓ ┃ Name ┃ Preview ┃ ┡━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┩ │ animal_portrait │ [0] <base64, 1642664 chars> │ ├────────────────────────────────────────┼───────────────────────────────────────────────────────────────────┤ │ edited_portrait │ [0] <base64, 1695436 chars> │ └────────────────────────────────────────┴───────────────────────────────────────────────────────────────────┘
Generated Columns ┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓ ┃ Name ┃ Value ┃ ┡━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┩ │ animal │ fox │ ├────────────────────────────────┼───────────────────────────────────────────────────────────────────────────┤ │ accessory │ a tiny top hat │ ├────────────────────────────────┼───────────────────────────────────────────────────────────────────────────┤ │ setting │ a cozy living room │ ├────────────────────────────────┼───────────────────────────────────────────────────────────────────────────┤ │ art_style │ a Disney Pixar 3D render │ └────────────────────────────────┴───────────────────────────────────────────────────────────────────────────┘ Images ┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓ ┃ Name ┃ Preview ┃ ┡━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┩ │ animal_portrait │ [0] <base64, 1920848 chars> │ ├────────────────────────────────────────┼───────────────────────────────────────────────────────────────────┤ │ edited_portrait │ [0] <base64, 1712764 chars> │ └────────────────────────────────────────┴───────────────────────────────────────────────────────────────────┘
| animal | accessory | setting | art_style | animal_portrait | edited_portrait | |
|---|---|---|---|---|---|---|
| 0 | cat | a monocle and mustache | a cozy living room | a Disney Pixar 3D render | [iVBORw0KGgoAAAANSUhEUgAABAAAAAMACAIAAAA12IJaA... | [iVBORw0KGgoAAAANSUhEUgAABAAAAAMACAIAAAA12IJaA... |
| 1 | fox | a tiny top hat | a cozy living room | 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: cat wearing a monocle and mustache Setting: a cozy living room, Style: a Disney Pixar 3D render ============================================================ 📷 Generated portrait:
🎨 Edited version:
============================================================ Record 1: fox wearing a tiny top hat Setting: a cozy living room, 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.
[19:59:53] [INFO] OpenTelemetry metrics available at http://127.0.0.1:9464/metrics
[19:59:53] [INFO] 🎨 Creating Data Designer dataset
[19:59:53] [INFO] |-- 🔒 Jinja rendering engine: secure
[19:59:53] [INFO] ✅ Validation passed
[19:59:53] [INFO] ⛓️ Sorting column configs into a Directed Acyclic Graph
[19:59:53] [INFO] Skipping model health checks because DATA_DESIGNER_SKIP_MODEL_HEALTH_CHECKS=1
[19:59:53] [INFO] ⚡ Using async task-queue builder
[19:59:53] [INFO] 🖼️ image model config for column 'animal_portrait'
[19:59:53] [INFO] |-- model: 'black-forest-labs/flux.2-pro'
[19:59:53] [INFO] |-- model alias: 'image-model'
[19:59:53] [INFO] |-- model provider: 'openrouter'
[19:59:53] [INFO] |-- inference parameters:
[19:59:53] [INFO] | |-- generation_type=image
[19:59:53] [INFO] | |-- max_parallel_requests=4
[19:59:53] [INFO] | |-- extra_body={'height': 512, 'width': 512}[19:59:53] [INFO] 🖼️ image model config for column 'edited_portrait'
[19:59:53] [INFO] |-- model: 'black-forest-labs/flux.2-pro'
[19:59:53] [INFO] |-- model alias: 'image-model'
[19:59:53] [INFO] |-- model provider: 'openrouter'
[19:59:53] [INFO] |-- inference parameters:
[19:59:53] [INFO] | |-- generation_type=image
[19:59:53] [INFO] | |-- max_parallel_requests=4
[19:59:53] [INFO] | |-- extra_body={'height': 512, 'width': 512}[19:59:53] [INFO] ⚡️ Async generation: 2 column(s) (column 'animal_portrait', column 'edited_portrait'), 10 tasks across 1 row group(s)
[19:59:53] [INFO] 🚀 (1/1) Dispatching with 5 records
[19:59:53] [INFO] 🎲 (1/1) Preparing samplers to generate 5 records across 4 columns
[20:00:00] [INFO] 📊 Progress [6.8s]:
[20:00:00] [INFO] |-- 🌑 column 'animal_portrait': 1/5 (20%) 0.1 rec/s
[20:00:00] [INFO] |-- 🌧️ column 'edited_portrait': 0/5 (0%) 0.0 rec/s
[20:00:06] [INFO] 📊 Progress [12.7s]:
[20:00:06] [INFO] |-- 🌖 column 'animal_portrait': 4/5 (80%) 0.3 rec/s
[20:00:06] [INFO] |-- 🌧️ column 'edited_portrait': 0/5 (0%) 0.0 rec/s
[20:00:13] [INFO] 📊 Progress [20.6s]:
[20:00:13] [INFO] |-- 🌕 column 'animal_portrait': 5/5 (100%) 0.2 rec/s
[20:00:13] [INFO] |-- 🌦️ column 'edited_portrait': 2/5 (40%) 0.1 rec/s
[20:00:22] [INFO] 📊 Progress [29.1s]:
[20:00:22] [INFO] |-- 🌕 column 'animal_portrait': 5/5 (100%) 0.2 rec/s
[20:00:22] [INFO] |-- 🌤️ column 'edited_portrait': 4/5 (80%) 0.1 rec/s
[20:00:22] [INFO] 📊 Progress [29.3s]:
[20:00:22] [INFO] |-- 🌕 column 'animal_portrait': 5/5 (100%) 0.2 rec/s
[20:00:22] [INFO] |-- ☀️ column 'edited_portrait': 5/5 (100%) 0.2 rec/s
[20:00:22] [INFO] ✅ Async generation complete [29.3s]: 10 ok, 0 failed across 2 column(s)
[20:00:22] [INFO] 📊 Model usage summary:
[20:00:22] [INFO] |-- model: black-forest-labs/flux.2-pro
[20:00:22] [INFO] |-- tokens: input=23009, output=30720, reasoning=0, total=53729, tps=1816
[20:00:22] [INFO] |-- requests: success=10, failed=0, total=10, rpm=20
[20:00:22] [INFO] |-- images: total=10
[20:00:22] [INFO] 📐 Measuring dataset column statistics:
[20:00:22] [INFO] |-- 🎲 column: 'animal'
[20:00:22] [INFO] |-- 🎲 column: 'accessory'
[20:00:22] [INFO] |-- 🎲 column: 'setting'
[20:00:22] [INFO] |-- 🎲 column: 'art_style'
[20:00:22] [INFO] |-- 🖼️ column: 'animal_portrait'
[20:00:22] [INFO] |-- 🖼️ column: 'edited_portrait'
| animal | accessory | setting | art_style | animal_portrait | edited_portrait | |
|---|---|---|---|---|---|---|
| 0 | rabbit | a tiny top hat | a photo studio with soft lighting | a photorealistic style | ['images/animal_portrait/9cd94271-099c-4c40-8b... | ['images/edited_portrait/8b5289b0-0e4d-4682-96... |
| 1 | owl | a knitted beanie | a cozy living room | a watercolor painting | ['images/animal_portrait/0a2fce6f-3c6e-40aa-96... | ['images/edited_portrait/4e5fe91c-c8ed-4dad-87... |
| 2 | cat | a knitted beanie | a sunny park | a watercolor painting | ['images/animal_portrait/e3378285-ff3b-48bd-85... | ['images/edited_portrait/a90754e2-7213-4257-87... |
| 3 | dog | a flower crown | a holiday card backdrop with snowflakes | a pop art poster | ['images/animal_portrait/f7cf91a9-1ce0-46a8-8b... | ['images/edited_portrait/98adb879-b16f-47db-96... |
| 4 | cat | a red bow tie | a sunny park | a Disney Pixar 3D render | ['images/animal_portrait/a905ed24-2edf-45c3-a3... | ['images/edited_portrait/2ef2aee0-5373-4563-90... |
============================================================ Record 0: rabbit wearing a tiny top hat Setting: a photo studio with soft lighting, Style: a photorealistic style ============================================================ 📷 Generated portrait:
🎨 Edited version:
============================================================ Record 1: owl wearing a knitted beanie Setting: a cozy living room, Style: a watercolor painting ============================================================ 📷 Generated portrait:
🎨 Edited version:
============================================================ Record 2: cat wearing a knitted beanie Setting: a sunny park, Style: a watercolor painting ============================================================ 📷 Generated portrait:
🎨 Edited version:
============================================================ Record 3: dog wearing a flower crown Setting: a holiday card backdrop with snowflakes, Style: a pop art poster ============================================================ 📷 Generated portrait:
🎨 Edited version:
============================================================ Record 4: cat wearing a red bow tie Setting: a sunny park, 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