Skip to content

diffsyn代码有bug?为什么Qwen-Image-Edit-2509用DiffSynth-Studio推理比diffusers效果差很多 #1000

@huxian0402

Description

@huxian0402

@pengqun @Lupino @calmhawk @co63oc @wenmengzhou
用DiffSynth-Studio最新的推理代码,相同的配置和测试集,跑出来比diffusers推理效果差很多,这个是什么原因呢?

测试图片:

Image
Image

DiffSynth-Studio推理结果:

Image
Image

diffusers推理结果:

Image
Image

下面是我的测试代码:
def test_qwen_edit_diffusers():
import os
import torch
from PIL import Image
from diffusers import QwenImageEditPlusPipeline, QwenImageEditPipeline

model_path = "Qwen-Image-Edit-2509"
pipeline = QwenImageEditPlusPipeline.from_pretrained(model_path, torch_dtype=torch.bfloat16)
print("pipeline loaded from", model_path)
pipeline.to('cuda')
pipeline.set_progress_bar_config(disable=None)

image = Image.open("08_0.jpg").convert("RGB")
inputs = {
    "image": image,
    "prompt": "Remove the black area.",
    "width": 1024,
    "height": 1024,
    "generator": torch.manual_seed(42),
    "true_cfg_scale": 4.0,
    "negative_prompt": "",
    "num_inference_steps": 40,
    "guidance_scale": 1.0,
    "num_images_per_prompt": 1,
}
with torch.inference_mode():
    output = pipeline(**inputs)
    output_image = output.images[0]

output_image.save("qwen_edit_diffusers.jpg")
print(f"Image saved at qwen_edit_diffusers.jpg")

def test_qwen_edit_diffsyn():
import os, sys
sys.path.append(os.getcwd())
from diffsynth.pipelines.qwen_image import QwenImagePipeline, ModelConfig
from PIL import Image
import torch

base_model_path = "Qwen-Image-Edit-2509"
pipe = QwenImagePipeline.from_pretrained(
    torch_dtype=torch.bfloat16,
    device="cuda",
    model_configs=[
        ModelConfig(model_id=f"{base_model_path}", origin_file_pattern="transformer/diffusion_pytorch_model*.safetensors", skip_download=True),
        ModelConfig(model_id=f"{base_model_path}", origin_file_pattern="text_encoder/model*.safetensors", skip_download=True),
        ModelConfig(model_id=f"{base_model_path}", origin_file_pattern="vae/diffusion_pytorch_model.safetensors", skip_download=True),
    ],
    tokenizer_config=None,
    processor_config=ModelConfig(model_id=f"{base_model_path}", origin_file_pattern="processor/", skip_download=True),
)

image = Image.open("08_0.jpg").convert("RGB")
output_image = pipe(
        edit_image=image,
        prompt="Remove the black area.",
        height=1024,
        width=1024,
        seed=42,
        cfg_scale=4.0,
        num_inference_steps=40, 
        negative_prompt="",
    )
output_image.save("qwen_edit_diffsyn.jpg")
print(f"Image saved at qwen_edit_diffsyn.jpg")

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions