Add UniPic3Pipeline for multi-image editing and composition#14201
Open
chenyangzhu1 wants to merge 1 commit into
Open
Add UniPic3Pipeline for multi-image editing and composition#14201chenyangzhu1 wants to merge 1 commit into
chenyangzhu1 wants to merge 1 commit into
Conversation
UniPic-3 is a unified framework by Skywork for single-image editing and multi-image composition (1-6 input images). It reuses the existing QwenImageTransformer2DModel, AutoencoderKLQwenImage, and FlowMatchEulerDiscreteScheduler. The key differences from QwenImageEditPipeline are chat-template-based prompt encoding with system messages, per-image VAE encoding with sequence-dimension concatenation, and total pixel budget normalization across multiple input images. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
UniPic3Pipelinetosrc/diffusers/pipelines/unipic3/for multi-image editing and compositionQwenImageTransformer2DModel,AutoencoderKLQwenImage,FlowMatchEulerDiscreteScheduler)__init__.pylevels and dummy objectsWhat is UniPic-3?
UniPic-3 is a unified framework by Skywork for single-image editing and multi-image composition, supporting 1-6 input images with arbitrary output resolutions. It achieves SOTA multi-image composition quality.
Key Design Decisions
Pipeline-only change: UniPic-3 uses the exact same model components as the existing QwenImageEdit pipeline. No new model classes, schedulers, or weight conversion scripts are needed.
Base pipeline only (50-step): The CM/DMD fast variant (8-step) uses a custom sampling loop that bypasses
scheduler.step(), violating diffusers conventions (.ai/pipelines.mdgotcha make from hub import work #3). This can be added later with a proper scheduler implementation.Separate pipeline vs extending QwenImageEditPipeline: Per diffusers conventions, each pipeline gets its own file and class. The multi-image input, chat-template prompt encoding, and per-image latent handling are sufficiently different from
QwenImageEditPipelineto warrant a new class.Key Differences from QwenImageEditPipeline
image: PipelineImageInput(single)images: list[PipelineImageInput](1-6)processor.apply_chat_template()with system message + multi-imagecalculate_dimensionsimg_shapesFiles Changed
New files
src/diffusers/pipelines/unipic3/__init__.py— Lazy import modulesrc/diffusers/pipelines/unipic3/pipeline_unipic3.py— Main pipeline implementationtests/pipelines/unipic3/__init__.py— Test package inittests/pipelines/unipic3/test_unipic3.py— Pipeline unit testsdocs/source/en/api/pipelines/unipic3.md— API documentationModified files
src/diffusers/__init__.py— RegisterUniPic3Pipelinein exportssrc/diffusers/pipelines/__init__.py— Registerunipic3modulesrc/diffusers/utils/dummy_torch_and_transformers_objects.py— Add dummy classdocs/source/en/_toctree.yml— Add documentation entryTest plan
from diffusers import UniPic3Pipelineworkstest_inference— Multi-image generation produces correct output shapetest_inference_single_image— Single image input worksmake stylepassesmake fix-copiespassesUsage Examples
Single image editing
Two-image composition
Three-image composition
Loading components separately
Real-Weight Validation (Skywork/Unipic3, 50-step)
5 additional tests using real photographs and artwork, all passed:
A: Single Image Edit — Cat wearing a hat (1 image)
B: Single Image Edit — Style transfer (1 image)
C: Two-Image Composition — Cat in landscape (2 images)
D: Two-Image Composition — Character mashup (2 images)
E: Three-Image Composition — Multi-character scene (3 images)
Self-Review Report
Blocking Issues — All Fixed
B1:→ Fixed: RestoredVersatileDiffusionDualGuidedPipelineaccidentally removed from TYPE_CHECKING importsB2:→ Fixed: Restored viaVersatileDiffusionDualGuidedPipelinedummy object replacedcheck_dummies.pyB3:→ Consistent with QwenImageEditPipeline (parameter is validated inmax_sequence_lengthaccepted but unusedcheck_inputsbut not truncated — same pattern)Non-Blocking Issues
_import_structure["unipic3"]placement inpipelines/__init__.pynot perfectly alphabetical — consistent with howchronoeditandglm_imageare appended in the same block→ Fixed: Added validation inimages=Nonenot validated__call__sigmasinlined — consistent withQwenImageEditPipelinepatternDead Code (Advisory — Kept for Consistency)
self.tokenizer_max_length = 1024— same asQwenImageEditPipeline, may be used by LoRA mixinsself.default_sample_size = 128— same asQwenImageEditPipelineretrieve_latents"sample" branch —# Copied fromfunction, kept for syncVerdict: READY
Fixes #13053
Before submitting
self-reviewskill on the diff?documentation guidelines, and
here are tips on formatting docstrings.
Who can review?
Anyone in the community is free to review the PR once the tests have passed. Feel free to tag
members/contributors who may be interested in your PR.
@yiyixuxu @dg845 @asomoza @sayakpaul @DN6