`ZImageImg2ImgPipeline` / `ZImageInpaintPipeline`: explicit height/width different from the input image raises RuntimeError
メンテナーはふだん 1 日以内に返信
評価
- 難易度
- 2/5
- 見積もり時間
- 1〜3時間
- 初心者へのやさしさ
- 70/100
- issue の種類
- バグ
- 明瞭さ
- 明確に書かれている
- 活発さ
- 活発
調査の方向性
src/diffusers/pipelines/z_image/pipeline_z_image_img2img.py の489行目付近にある初期画像の前処理と、673行目付近にある対応するインペインティングコードを読む。SD3、Flux、QwenImage、Chroma がどのように寸法を image_processor.preprocess に渡すかを比較し、入力画像と異なる height/width を使って再現する。両方のパイプラインがサイズの不一致なく要求された出力寸法を受け付ければ完了。
索引モデルが issue の本文から書いたものです。
説明
Describe the bug
In ZImageImg2ImgPipeline and ZImageInpaintPipeline, passing height/width that differ from the input image size raises a size-mismatch RuntimeError, although the docstring says they set the output size. The init image is preprocessed without them (img2img L489, inpaint L673), so it is never resized and keeps its original size, while the noise shape uses height/width. Other pipelines that take height/width (SD3, Flux, QwenImage, Chroma) pass them to image_processor.preprocess, which resizes the image first. In the inpaint pipeline the mask is already resized this way, only the image is not.
Also, passing more images than prompts (e.g. two images with one prompt string) fails with a bare AssertionError in the transformer; a clear ValueError might help.
I'm not sure whether this is intended behavior of the pipeline or an actual bug. If it is a bug, I'd be happy to open a PR that passes height/width to preprocess (and adds the ValueError above, if wanted). Would that be appropriate?
Reproduction
import torch
from PIL import Image
from diffusers import ZImageImg2ImgPipeline
pipe = ZImageImg2ImgPipeline.from_pretrained(
"Tongyi-MAI/Z-Image-Turbo", torch_dtype=torch.bfloat16
).to("cuda")
img = Image.new("RGB", (256, 256))
# Works without height/width (output 256x256).
# With height/width != image size it raises:
# RuntimeError: The size of tensor a (16) must match the size of tensor b (32)
pipe("a cat", image=img, height=128, width=128,
num_inference_steps=4, strength=0.6, guidance_scale=0.0)
Context
I'm building an app that runs image-to-image and inpainting on user images of various sizes, with a target output size chosen by the user. SD3 / SD3 Inpaint and Flux Img2Img / Inpaint work fine with explicit height/width, but Z-Image Img2Img / Inpaint raise the error above.
Logs
File ".../pipeline_z_image_img2img.py", line 345, in prepare_latents
latents = self.scheduler.scale_noise(image_latents, timestep, noise)
File ".../scheduling_flow_match_euler_discrete.py", line 234, in scale_noise
sample = sigma * noise + (1.0 - sigma) * sample
RuntimeError: The size of tensor a (16) must match the size of tensor b (32) at non-singleton dimension 3
System Info
- 🤗 Diffusers version: 0.44.0.dev0
- Platform: Linux-7.0.0-38-generic-x86_64-with-glibc2.39
- Running on Google Colab?: No
- Python version: 3.12.3
- PyTorch version (GPU?): 2.16.0a0+rocm10.3.0a20261117 (True)
- Huggingface_hub version: 2.4.0
- Transformers version: 5.23.0
- Accelerate version: 1.16.0
- PEFT version: not installed
- Safetensors version: 0.8.0
- xFormers version: not installed
- Accelerator: NA
- Using GPU in script?: Yes (AMD Radeon AI PRO R9700)
- Using distributed or parallel set-up in script?: No
diffusers main @ e84bda1
Who can help?
@yiyixuxu @sayakpaul
- 主要言語
- Python
- スター
- 34.9k
- フォーク
- 7.5k
- 平均マージ
- 3日 16時間
- マージ済み PR(30日)
- 65
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートあり
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
huggingface/diffusers のほかの issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 84/100
huggingface/diffusers#15363 ·
メンテナーはふだん 1 日以内に返信
-
Multi-vector textual inversion uses only the first vector when the token has uppercase letters (transformers v5)対応中かも @sunhouy が 2 日前に担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
huggingface/diffusers#15313 ·
メンテナーはふだん 1 日以内に返信
-
TCDScheduler advances the generator on the final step of a strength-truncated custom schedule対応中かも @SIDDARTHAREDDY8 が 5 日前に担当しました。 オープンbug
難易度 2/5 1〜3時間 初心者へのやさしさ 74/100
huggingface/diffusers#15288 · コメント 2 件 ·
メンテナーはふだん 1 日以内に返信
-
unload_textual_inversion(token) leaves the extra tokens of a multi-vector embedding behind, so it can't be loaded again対応中かも @sohailshk が 11 日前に担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
huggingface/diffusers#15211 · コメント 3 件 ·
メンテナーはふだん 1 日以内に返信
-
set_ip_adapter_scale(float) raises "Cannot assign 1 scale_configs to 2 IP-Adapter" when several IP-Adapters are loaded対応中かも @sohailshk が 11 日前に担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
huggingface/diffusers#15210 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
huggingface/diffusers の issue をすべて見る
似ている issue
-
[dbt] exported dataset keys reference physical columns対応中かも @WilliamKelley が今日担当しました。 オープンneeds-triage
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
apache/ossie-converters#251 ·
メンテナーはふだん 2 日以内に返信
-
cli difficulty: easy enhancement
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
メンテナーはふだん 2 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 62/100
desec-io/desec-stack#1312 ·
メンテナーはふだん 14 日以内に返信
-
needs-triage
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
aws/aws-durable-execution-sdk-python#977 ·
メンテナーはふだん 1 日以内に返信
-
needs-triage
難易度 1/5 1時間未満 初心者へのやさしさ 88/100
flashinfer-ai/flashinfer#9803 ·
メンテナーはふだん 1 日以内に返信