From 867c5abc5c8fc0fe8c0c0ddf397c802bae87e894 Mon Sep 17 00:00:00 2001 From: Vladimir Mandic Date: Wed, 13 Aug 2025 14:35:06 -0400 Subject: [PATCH] add qwen img2img and inpaint Signed-off-by: Vladimir Mandic --- CHANGELOG.md | 1 - TODO.md | 1 + installer.py | 2 +- modules/sd_models.py | 3 +++ pipelines/model_qwen.py | 4 ++++ 5 files changed, 9 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index de4886be9..eeb37413e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -22,7 +22,6 @@ SD.Next will warn on startup on unused cache entries that can be removed. Also, new image foundational model with *20B* params DiT and using *Qwen2.5-VL-7B* as the text-encoder! available via *networks -> models -> reference* *note*: this model is almost 2x the size of Flux, quantization and offloading are highly recommended! - *note* qwen-image supports text-to-image workflows as image-editing model is not yet available *recommended* params: *steps=50, attention-guidance=4* also available is pre-packaged [Qwen-Lightning](https://huggingface.co/vladmandic/Qwen-Lightning) which is an unofficial merge of [Qwen-Image](https://qwenlm.github.io/blog/qwen-image/) with [Qwen-Lightning-LoRA](https://github.com/ModelTC/Qwen-Image-Lightning/) to improve quality and allow for generating in 8-steps! diff --git a/TODO.md b/TODO.md index bbce04ade..f3371e091 100644 --- a/TODO.md +++ b/TODO.md @@ -8,6 +8,7 @@ Main ToDo list can be found at [GitHub projects](https://github.com/users/vladma ## Future Candidates +- Remote TE - Unified `CLIPTextModelWithProjection` loader - [Modular pipelines and guiders](https://github.com/huggingface/diffusers/issues/11915) - Refactor: Sampler options diff --git a/installer.py b/installer.py index 6de6a025e..a35fd490e 100644 --- a/installer.py +++ b/installer.py @@ -593,7 +593,7 @@ def check_diffusers(): t_start = time.time() if args.skip_all or args.skip_git: return - sha = '4a9dbd56f68214f0c949b8036a58c9ac3607f54e' # diffusers commit hash + sha = 'bc2762cce9c42ff7a7c3e4814ae4d5f0385e35e4' # diffusers commit hash pkg = pkg_resources.working_set.by_key.get('diffusers', None) minor = int(pkg.version.split('.')[1] if pkg is not None else -1) cur = opts.get('diffusers_version', '') if minor > -1 else '' diff --git a/modules/sd_models.py b/modules/sd_models.py index 817367b3a..276f84adc 100644 --- a/modules/sd_models.py +++ b/modules/sd_models.py @@ -863,6 +863,7 @@ def backup_pipe_components(pipe): 'feature_extractor': getattr(pipe, "feature_extractor", None), 'mask_processor': getattr(pipe, "mask_processor", None), 'restore_pipeline': getattr(pipe, "restore_pipeline", None), + 'task_args': getattr(pipe, "task_args", None), } @@ -886,6 +887,8 @@ def restore_pipe_components(pipe, components): pipe.mask_processor = components['mask_processor'] if components['restore_pipeline'] is not None: pipe.restore_pipeline = components['restore_pipeline'] + if components['task_args'] is not None: + pipe.task_args = components['task_args'] if pipe.__class__.__name__ in ['FluxPipeline', 'StableDiffusion3Pipeline']: pipe.register_modules(image_encoder = components['image_encoder']) diff --git a/pipelines/model_qwen.py b/pipelines/model_qwen.py index 61b904171..63ee989e3 100644 --- a/pipelines/model_qwen.py +++ b/pipelines/model_qwen.py @@ -26,6 +26,10 @@ def load_qwen(checkpoint_info, diffusers_load_config={}): 'output_type': 'np', } + diffusers.pipelines.auto_pipeline.AUTO_TEXT2IMAGE_PIPELINES_MAPPING["qwen-image"] = diffusers.QwenImagePipeline + diffusers.pipelines.auto_pipeline.AUTO_IMAGE2IMAGE_PIPELINES_MAPPING["qwen-image"] = diffusers.QwenImageImg2ImgPipeline + diffusers.pipelines.auto_pipeline.AUTO_INPAINT_PIPELINES_MAPPING["qwen-image"] = diffusers.QwenImageInpaintPipeline + del text_encoder del transformer