Skip to content

Studio: generate images in Data Recipes with an AI image block - #17208

Open
samihsq wants to merge 9 commits into
unslothai:mainfrom
samihsq:studio-recipes-image-column
Open

samihsq wants to merge 9 commits into
unslothai:mainfrom
samihsq:studio-recipes-image-column

Conversation

@samihsq

@samihsq samihsq commented Nov 9, 2026 •

Copy link
Copy Markdown
Contributor

Problem

Data Recipes can't generate images. Data Designer already has an image column (ImageColumnConfig in the pinned 0.5.4), but Recipe Studio has no block for it, and the backend wouldn't run one anyway:

  • Data Designer only sends model names containing dall-e-, stable-diffusion, sd-, imagen or gpt-image- to /images/generations. Studio's own image models (sdxl-turbo, Z-Image, FLUX) match none of them, so an image column on the local provider goes to /v1/chat/completions and fails with "No image data found".
  • Only llm- columns counted as using a model, so an image-only recipe on the local provider never got the internal key (401) and never checked that a model was loaded.
  • Generated images come back as base64 (preview) or images/<column>/<uuid>.png paths (full run), and both showed up as raw text in the run tables.

Change

AI image block: a new step under AI generation. Its prompt can use other fields like {{ subject }}, and each row gets one image from an image model preset. It wires up like AI text (connecting a preset sets its model, connecting a field adds its reference, renames and deletes stay in sync) and saves, imports and exports with the recipe. AI image in the step sheet AI image dialog
Image model presets: a Model preset gets a Generates: Text / Image switch. Image presets send generation_type: "image" with size, steps and guidance, and AI text steps only list text presets (and the other way around). On the local provider an image preset uses whichever image model is loaded on the Images page. Image preset on the canvas Image preset dialog
Results: generated images show as thumbnails in test runs and full runs, and the download and Hugging Face publish include the images/ folder (both already handled it, nothing produced one before). Test run with thumbnails Full run with thumbnails
Product Photos learning recipe: two category fields (subject, style) and one AI image step, set up for sdxl-turbo (512x512, 1 step, guidance 0). It doesn't need a chat model, so it runs with just an image model loaded. Product Photos recipe

Backend:

  • service.py: wraps Data Designer's is_image_diffusion_model so model names on Studio's local provider go to /images/generations. Every other name keeps the stock check, so cloud gpt-image-1 and chat-route image models behave the same as before. Image columns also count for the "Add a Provider connection block" error.
  • routes/data_recipe/jobs.py: image columns get the internal key, a recipe with a local image column fails early with "No image model loaded. Load one on the Images page, then run the recipe.", and the request gets response_format: b64_json, the loaded model's repo id and a 600 s timeout (Data Designer waits 60 s by default). The enable_thinking injection skips image presets.
  • jsonable.py, worker.py, manager.py: image cells turn into 384 px JPEG thumbnails for the tables, and image columns count toward column progress.

Safety

  • Only columns the recipe declares as image are read as images, so a text column that happens to look like base64 is left alone.
  • Full-run paths are only read inside the dataset's images/ folder: .., absolute paths and symlinks that point outside are left as text, and every read goes through account_path like the existing seed image previews. Anything that won't decode (truncated, not an image, a decompression bomb) stays as text.
  • The local routing marker is only set by the jobs route and is stripped before Data Designer builds the config.

Testing

  • studio/backend/tests/test_data_recipe_image_column.py (12), with real Data Designer against a fake provider:
    • a local image model goes to /images/generations with the rendered prompt, b64_json, size, steps and guidance
    • a cloud model with the same name still goes to chat, and gpt-image-1 still goes to images
    • a full run writes images/photo/*.png, pages show thumbnails, and the JSONL and parquet zips include every image
    • paths outside images/ aren't read
    • several images in one cell show the first with a count
    • undeclared columns aren't touched
    • an image-only recipe without a provider gets the provider error
    • an image-only local recipe gets the key and the loaded model
    • no image model loaded is refused
    • a chat + image recipe explains Keep multiple models loaded
    • image columns count toward progress
  • The other recipe tests (test_data_recipe_*, test_account_recipe_*, test_mcp_tools_recipe.py): 395 passed. The 1 failure is test_github_validate_skips_live_access_with_honest_note, which fails the same way on main on my machine (the GitHub seed plugin isn't installed in my env).
  • Frontend: tests/recipe-studio-image-block.test.ts (7). It covers:
    • the template round trip
    • a second save and reopen
    • mismatched presets refused
    • an empty prompt reported once
    • preset and field connections
    • rename and delete sync
    • thumbnail counts
  • Full npm test: 15,290 pass. The 4 failures are the HTML/TextEdit charset and time zone tests, which fail the same way on main on my machine.
  • npm run typecheck, npm run build, and npm run bundle:check (within budget) all pass. eslint has no findings on changed lines. Prettier is clean on the files that were clean on main. scripts/run_ruff_format.py and ruff check are clean.
  • Ran Studio from the branch on an M-series Mac with stabilityai/sdxl-turbo loaded (MPS, bf16):
    • The Product Photos test run made 4 images in about 20 s.
    • A 100-row full run took 64 s (1.87 rec/s), and the downloaded .jsonl.zip had 100 rows and 100 PNGs (512x512), each row's path pointing at a real file.
    • Adding AI image from the step sheet auto-connects to the only image preset.
    • Check says "Ready to run".
    • Running with the image model unloaded shows the error below.
    • Light theme and a 390 px phone width look fine, with no sideways overflow.

No image model loaded

Check in light theme

AI image dialog at 390 px

Not covered

  • Image-to-image (Data Designer's multi_modal_context on the image column)
  • Captioning generated images with a vision LLM step
  • A recipe with both a local chat step and a local image step needs Keep multiple models loaded set to When they fit. That path is covered by the route test, but I didn't load a chat model next to sdxl-turbo to try it end to end.
  • Downloading a test run (which comes from the rows in the browser) gets the thumbnails, the same as seed image previews; a full run's download has the full images.

@samihsq
samihsq marked this pull request as ready for review November 9, 2026 06:09
danielhanchen added a commit that referenced this pull request Nov 9, 2026
#17221)

## Summary

Follow-up to #17211, for the same GitHub release-asset outage. The
frontend CI step `Typecheck through bun check` downloads the pinned Bun
zip with `curl --retry 5 --retry-delay 3`, which gives up after about 15
seconds of waiting. GitHub served bursts of 504s for release assets for
over two hours today, and #17208's `Frontend build + bundle sanity` went
red with six `curl: (22) The requested URL returned error: 504` lines in
a row.

This drops the fixed `--retry-delay` and raises `--retry` to 8. Without
a fixed delay, curl backs off exponentially (1, 2, 4, ... 128 s), so the
step now waits about four minutes in total before failing. A healthy
download is unchanged, and a download that never recovers still fails
the job. The SHA-256 check and the `UNSLOTH_TYPECHECK=bun` gate are
untouched.

## Changes

- `.github/workflows/studio-frontend-ci.yml`: `--retry 8
--retry-connrefused --retry-all-errors`, no `--retry-delay`.
- `tests/test_bun_download_retries.py`: reads the step's `curl` line
from the workflow and checks that `--retry-all-errors` is set (curl does
not retry a 504 without it) and that the total backoff is at least 240
s. A second test pins the backoff arithmetic against curl's documented
behaviour.

## Testing

- Against a local server that always answers 504, `curl --retry 3`
without `--retry-delay` waits 7 s (1 + 2 + 4), which matches the
arithmetic in the test.
- `pytest tests/test_bun_download_retries.py`: 2 passed. Against the old
step from `main` it fails with `assert 15 >= 240`.
- The other tests that read `studio-frontend-ci.yml` pass (98 passed),
and `scripts/lint_workflow_triggers.py` is clean.
@oobabooga

Copy link
Copy Markdown
Member

@codex review

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 9, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ❌ Failed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ❌ Failed 2026-11-13T15:05:48.342948Z
We couldn’t complete this review. Comment @codex review to try again.
bff4bb1 New commits
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: ddeb6e921f

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +180 to +183
else render_image_columns(
to_preview_jsonable_row(results.dataset.to_dict(orient = "records")),
image_column_names(recipe),
)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Preserve original image cells for preview downloads

When an image recipe runs in preview mode, this replaces the dataset sent to JobManager with JPEG thumbnails capped at 384 px, retaining only the first image in each cell. The existing Download action exports those same rows through _build_in_memory_job_dataset_download() or its client-side fallback, so downloading a preview silently exports thumbnail objects rather than the original generated images, shrinking larger images and discarding additional ones. Preview runs have no artifact directory from which export can recover the originals; retain the raw image cells separately and derive thumbnails only for display.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 2063276: the job keeps the original image cells, the SSE event and /dataset pages get thumbnails, and the in-memory download reads the raw rows.

@oobabooga

Copy link
Copy Markdown
Member

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Chef's kiss.

Reviewed commit: 2063276411

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@oobabooga

oobabooga commented Nov 10, 2026 •

Copy link
Copy Markdown
Member

Walkthrough

Run at 8c58910 in Studio on an RTX 3090 with unsloth/gemma-4-E2B-it-GGUF (Q4_K_M) as the chat model and unsloth/Z-Image-Turbo-GGUF (Q4_K_M) as the image model. Every image below was generated by the recipe shown. Numbers in the screenshots match the lists.

1. Data Recipes page

Data Recipes page

  1. New learning recipe: Product Photos, tagged AI Image.

2. Product Photos recipe

Product Photos canvas

  1. Image model preset: Generates is Image, the model is the one loaded on the Images page.
  2. AI image step: one image per row, prompt uses {{ style }} and {{ subject }}.
  3. Category sampler fields feeding the prompt.
  4. Run.

3. Step catalog

Step catalog

  1. AI image is listed under AI generation, next to AI text.

4. Image model preset

Image model preset dialog

  1. Generates: Text / Image switch.
  2. On the local provider there is no model ID field to fill; it uses the loaded image model.
  3. Size, steps and guidance are blank, so the request leaves them out and Studio uses the loaded model's defaults. For Z-Image-Turbo the gallery records 8 steps, guidance 0, 1024x1024.

5. AI image step

AI image step dialog

  1. Fields available to the prompt.
  2. The prompt, rendered per row.

6. Test run, 4 rows

Test run results

  1. Images are shown as thumbnails.
  2. Download exports the original images, not the thumbnails.

7. Recipe using the chat model and the image model together

This recipe is not part of the PR. It was imported with Paste recipe JSON to exercise both model types in one run.

Text and image recipe

  1. Text preset on the local provider (gemma-4-E2B).
  2. Image preset on the local provider (Z-Image-Turbo), settings blank.
  3. Two AI text steps: a one-sentence description from the sampled product and material, then a title from the description.
  4. AI image step whose prompt includes the description.

8. Full run, 6 rows

Full run results

  1. description, written by the chat model.
  2. title, written by the chat model from the description.
  3. photo, drawn by the image model from the description.
  4. Download: a zip with the JSONL and 6 PNGs (1024x1024) under images/photo/. Each row's photo cell is ["images/photo/<uuid>.png"].
  5. Publish to Hugging Face was not exercised.

Both models were loaded on one 24 GB card with Keep multiple models loaded set to When they fit. In this run, loading the chat model with an 8192 context evicted the image model; with a 2048 context both stayed loaded.

Follow-ups

  • b78dd21 Merge main (docstring conflict in jobs.py).
  • 3cdb561 An external preset naming the same model as the local image preset was sent to /images/generations.
  • 469a52e With media auto-switch on, a recipe swapped the loaded GGUF quant for the preferred one.
  • 5d0cbb8 A GGUF loaded from a local folder got 404 on every image request.
  • ddeb6e9 Comment cleanup.
  • 2063276 Test-run downloads exported thumbnails instead of the original images.
  • 8c58910 Product Photos used sdxl-turbo settings on every model; it now uses the loaded model's defaults.

@oobabooga

Copy link
Copy Markdown
Member

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Keep it up!

Reviewed commit: 8c58910e31

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants