Skip to content

Studio: add Qwen-Image-2.1 image editing - #11587

Merged
danielhanchen merged 7 commits into
unslothai:mainfrom
oobabooga:qwen-image-21-edit
Sep 22, 2026
Merged

danielhanchen merged 7 commits into
unslothai:mainfrom
oobabooga:qwen-image-21-edit

Conversation

@oobabooga

@oobabooga oobabooga commented Sep 22, 2026 •

Copy link
Copy Markdown
Member

Adds Qwen-Image-2.1 editing to Studio's Images page, with multiple reference images, localized edits and transparent PNG output. The same model remains available for text-to-image generation.

Previously, image input was only exposed through Reference, which discarded transparency and kept at most four images. Native GGUF loads could not edit images.

What changes

  • Edit: upload a source image and describe the change. Add up to nine more images for subjects, styles or composition, with numbered slots matching their order in the prompt.
  • Localize: draw colored annotations, paint over a region, or provide a separate mask. The instruction can be updated visibly to describe the markings. These guide generation rather than preserving every pixel outside the region.
  • Transparency: edit transparent layers or extract a subject onto a transparent background. PNG results retain alpha, with checkerboard previews in Studio. On the native engine this needs an sd.cpp build newer than the current pin, as described below.
  • Output controls: match the source's aspect ratio or choose custom dimensions, including 2K presets. Diffusers also offers separate reference-detail settings. Restoring a gallery recipe reopens the editing workflow and asks for its source images again.

Both Diffusers and native sd.cpp/GGUF can run edits. The backend enforces each model's image and size limits, includes references in its memory estimate, and fixes the offloaded vision-encoder device mismatch that prevented image-conditioned calls.

Screenshots

Taken from a fresh Studio profile in Chromium (en-US, 2x scale) with Qwen-Image-2.1 on Diffusers. Each output is the result of the request shown.

Combining images: the empty room is Image 1, the rocking chair Image 2 and the sofa Image 3.
01-edit-multi-image

Localized edit with a colour annotation. "Add region wording" appended the instruction to leave the marks out, and the red circle is gone from the result.
02-localized-annotation

Transparent-layer edit. "Ask for a transparent background" adds the model card's prompt wording, and the output keeps its alpha.

03-transparent-edit

Separate mask: the painted region is sent as Image 2, and the rider appears only there.

04-separate-mask

Verification

Live runs used Linux/CUDA on RTX 6000 Ada and RTX 3090.

Path Exercised
Diffusers, bf16 transformer and FP8 encoder with group offload Single-image edits, ten-image composition at 512 reference detail, annotations, paint, masks, transparent-layer edits, subject extraction and gallery reuse
Native sd-server, pinned build, Q4_K_M Single-image edits, three-image composition, masks, cancellation and text-to-image
Native sd-server, upstream c92d73c built locally, Q6_K Transparent-layer edit and subject extraction at guidance 6, and a mask edit at a different output shape
Chromium, fresh profile Three-image edit, colour annotation, transparent edit and separate mask, end to end (screenshots above)

A Diffusers run matched a direct pipeline call pixel-for-pixel with the same settings.

Transparent edit of the same RGBA source (fully transparent pixels in the output):

Path Transparent
Diffusers, guidance 1 51.2%
Native, upstream build, RGBA reference, guidance 6 46.9%
Native, upstream build, reference flattened onto white, guidance 6 24.9%
Native, upstream build, RGBA reference, guidance 1 3.7%

Subject extraction on the native upstream build reached 72.7% transparent, with some white patches left in the background.

Backend suites: 1,545 passed. Frontend typecheck passed. The full frontend suite had eight failures out of 8,475 tests: seven also fail on origin/main; the remaining transport test passes in isolation on both branches.

Scope and limitations

The pinned native build (master-813-bfbef5b-u1d02858) predates upstream's reference fixes (78557f8, e012065, e112ab5). Studio checks the binary for a string the alpha fix added. When it is missing, Studio flattens input transparency onto white and pads references so sd-server does not crop them, and the page says so. Separate masks are padded with black so the padding adds no edit region. With a build that has the fixes, images go through unchanged and native transparent editing works. Shipping that needs a new mirror release of the pinned sd.cpp. On any native build, transparent output needs guidance above 1, and the page says so.

Match Image 1 always produces a size the API accepts. For an extreme aspect ratio such as 4096x256, the short side is held at 256 and the long side capped at the model's maximum.

Native loads also download a 1.16 GB vision projector.

INT8/FP8 transformer builds, other platforms and 2K outputs were not validated. Ten references at 1024 detail and one at 2048 detail exhausted memory on the RTX 3090.

oobabooga and others added 6 commits September 22, 2026 18:51
…rojector for PR unslothai#11587

The projector (mmproj-F16.gguf) is now a listed native asset, and a
local_files_only load fails on any uncached asset, so a Qwen-Image-2.1
GGUF cached before this change stopped restoring even though
text-to-image never reads the projector. Skip an uncached llm_vision
asset offline instead; edit is already offered only when it is loaded,
and opening the model from the Images page fetches it.
@danielhanchen
danielhanchen merged commit 40fd40c into unslothai:main Sep 22, 2026
6 of 58 checks passed
shaojun pushed a commit to shaojun/unsloth that referenced this pull request Sep 29, 2026
* Studio: add Qwen-Image-2.1 image editing

* Keep Match Image 1 sizes valid, pad native masks black, and pass alpha to capable sd.cpp builds

* Trim comments

* Share conditioned-field checks across engines, bound native sizes, and drop a stale localized layer at once

* Fix offline load of a cached Qwen-Image-2.1 GGUF without the vision projector for PR unslothai#11587

The projector (mmproj-F16.gguf) is now a listed native asset, and a
local_files_only load fails on any uncached asset, so a Qwen-Image-2.1
GGUF cached before this change stopped restoring even though
text-to-image never reads the projector. Skip an uncached llm_vision
asset offline instead; edit is already offered only when it is loaded,
and opening the model from the Images page fetches it.

* Fail closed on unreadable builds for native edit and reference fidelity

* Move Edit right after Create in the Images workflows

---------

Co-authored-by: danielhanchen <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants