Instructions to use alibaba-pai/Qwen-Image-2.1-Fun-Controlnet-Union with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- VideoX Fun
How to use alibaba-pai/Qwen-Image-2.1-Fun-Controlnet-Union with VideoX Fun:
# No code snippets available yet for this library. # To use this model, check the repository files and the library's documentation. # Want to help? PRs adding snippets are welcome at: # https://github.com/huggingface/huggingface.js
- Notebooks
- Google Colab
- Kaggle
bubbliiiing commited on
Commit ·
8a47020
1
Parent(s): b362c74
Update Weights
Browse files- .gitattributes +21 -9
- LICENSE +55 -0
- Qwen-Image-2.1-Fun-Controlnet-Union.safetensors +3 -0
- README.md +146 -1
- README_zh.md +151 -0
- asset/control_13_00000494.png +3 -0
- asset/control_1_00014291.png +3 -0
- asset/control_2_00001450.png +3 -0
- asset/control_2_00025069.png +3 -0
- asset/control_4_00000931.png +3 -0
- asset/control_4_00003435.png +3 -0
- asset/control_4_00027496.png +3 -0
- asset/control_5_00005389.png +3 -0
- asset/control_6_00009388.png +3 -0
- asset/control_7_00015359.png +3 -0
- asset/control_7_00018303.png +3 -0
- asset/control_7_00034515.png +3 -0
- asset/inpaint_control.jpg +3 -0
- asset/inpaint_mask.png +3 -0
- asset/inpaint_source.png +3 -0
- configuration.json +1 -0
- results/control_13_00000494.png +3 -0
- results/control_1_00014291.png +3 -0
- results/control_2_00001450.png +3 -0
- results/control_2_00025069.png +3 -0
- results/control_4_00000931.png +3 -0
- results/control_4_00003435.png +3 -0
- results/control_4_00027496.png +3 -0
- results/control_5_00005389.png +3 -0
- results/control_6_00009388.png +3 -0
- results/control_7_00015359.png +3 -0
- results/control_7_00018303.png +3 -0
- results/control_7_00034515.png +3 -0
- results/inpaint.png +3 -0
.gitattributes
CHANGED
|
@@ -1,36 +1,48 @@
|
|
| 1 |
*.7z filter=lfs diff=lfs merge=lfs -text
|
| 2 |
*.arrow filter=lfs diff=lfs merge=lfs -text
|
| 3 |
*.bin filter=lfs diff=lfs merge=lfs -text
|
|
|
|
| 4 |
*.bz2 filter=lfs diff=lfs merge=lfs -text
|
| 5 |
-
*.ckpt filter=lfs diff=lfs merge=lfs -text
|
| 6 |
*.ftz filter=lfs diff=lfs merge=lfs -text
|
| 7 |
*.gz filter=lfs diff=lfs merge=lfs -text
|
| 8 |
*.h5 filter=lfs diff=lfs merge=lfs -text
|
| 9 |
*.joblib filter=lfs diff=lfs merge=lfs -text
|
| 10 |
*.lfs.* filter=lfs diff=lfs merge=lfs -text
|
| 11 |
-
*.mlmodel filter=lfs diff=lfs merge=lfs -text
|
| 12 |
*.model filter=lfs diff=lfs merge=lfs -text
|
| 13 |
*.msgpack filter=lfs diff=lfs merge=lfs -text
|
| 14 |
-
*.npy filter=lfs diff=lfs merge=lfs -text
|
| 15 |
-
*.npz filter=lfs diff=lfs merge=lfs -text
|
| 16 |
*.onnx filter=lfs diff=lfs merge=lfs -text
|
| 17 |
*.ot filter=lfs diff=lfs merge=lfs -text
|
| 18 |
*.parquet filter=lfs diff=lfs merge=lfs -text
|
| 19 |
*.pb filter=lfs diff=lfs merge=lfs -text
|
| 20 |
-
*.pickle filter=lfs diff=lfs merge=lfs -text
|
| 21 |
-
*.pkl filter=lfs diff=lfs merge=lfs -text
|
| 22 |
*.pt filter=lfs diff=lfs merge=lfs -text
|
| 23 |
*.pth filter=lfs diff=lfs merge=lfs -text
|
| 24 |
*.rar filter=lfs diff=lfs merge=lfs -text
|
| 25 |
-
*.safetensors filter=lfs diff=lfs merge=lfs -text
|
| 26 |
saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
| 27 |
*.tar.* filter=lfs diff=lfs merge=lfs -text
|
| 28 |
-
*.tar filter=lfs diff=lfs merge=lfs -text
|
| 29 |
*.tflite filter=lfs diff=lfs merge=lfs -text
|
| 30 |
*.tgz filter=lfs diff=lfs merge=lfs -text
|
| 31 |
-
*.wasm filter=lfs diff=lfs merge=lfs -text
|
| 32 |
*.xz filter=lfs diff=lfs merge=lfs -text
|
| 33 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 34 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
| 35 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
| 36 |
*.png filter=lfs diff=lfs merge=lfs -text
|
|
|
|
| 1 |
*.7z filter=lfs diff=lfs merge=lfs -text
|
| 2 |
*.arrow filter=lfs diff=lfs merge=lfs -text
|
| 3 |
*.bin filter=lfs diff=lfs merge=lfs -text
|
| 4 |
+
*.bin.* filter=lfs diff=lfs merge=lfs -text
|
| 5 |
*.bz2 filter=lfs diff=lfs merge=lfs -text
|
|
|
|
| 6 |
*.ftz filter=lfs diff=lfs merge=lfs -text
|
| 7 |
*.gz filter=lfs diff=lfs merge=lfs -text
|
| 8 |
*.h5 filter=lfs diff=lfs merge=lfs -text
|
| 9 |
*.joblib filter=lfs diff=lfs merge=lfs -text
|
| 10 |
*.lfs.* filter=lfs diff=lfs merge=lfs -text
|
|
|
|
| 11 |
*.model filter=lfs diff=lfs merge=lfs -text
|
| 12 |
*.msgpack filter=lfs diff=lfs merge=lfs -text
|
|
|
|
|
|
|
| 13 |
*.onnx filter=lfs diff=lfs merge=lfs -text
|
| 14 |
*.ot filter=lfs diff=lfs merge=lfs -text
|
| 15 |
*.parquet filter=lfs diff=lfs merge=lfs -text
|
| 16 |
*.pb filter=lfs diff=lfs merge=lfs -text
|
|
|
|
|
|
|
| 17 |
*.pt filter=lfs diff=lfs merge=lfs -text
|
| 18 |
*.pth filter=lfs diff=lfs merge=lfs -text
|
| 19 |
*.rar filter=lfs diff=lfs merge=lfs -text
|
|
|
|
| 20 |
saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
| 21 |
*.tar.* filter=lfs diff=lfs merge=lfs -text
|
|
|
|
| 22 |
*.tflite filter=lfs diff=lfs merge=lfs -text
|
| 23 |
*.tgz filter=lfs diff=lfs merge=lfs -text
|
|
|
|
| 24 |
*.xz filter=lfs diff=lfs merge=lfs -text
|
| 25 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
| 26 |
+
*.zstandard filter=lfs diff=lfs merge=lfs -text
|
| 27 |
+
*.tfevents* filter=lfs diff=lfs merge=lfs -text
|
| 28 |
+
*.db* filter=lfs diff=lfs merge=lfs -text
|
| 29 |
+
*.ark* filter=lfs diff=lfs merge=lfs -text
|
| 30 |
+
**/*ckpt*data* filter=lfs diff=lfs merge=lfs -text
|
| 31 |
+
**/*ckpt*.meta filter=lfs diff=lfs merge=lfs -text
|
| 32 |
+
**/*ckpt*.index filter=lfs diff=lfs merge=lfs -text
|
| 33 |
+
*.safetensors filter=lfs diff=lfs merge=lfs -text
|
| 34 |
+
*.ckpt filter=lfs diff=lfs merge=lfs -text
|
| 35 |
+
*.gguf* filter=lfs diff=lfs merge=lfs -text
|
| 36 |
+
*.ggml filter=lfs diff=lfs merge=lfs -text
|
| 37 |
+
*.llamafile* filter=lfs diff=lfs merge=lfs -text
|
| 38 |
+
*.pt2 filter=lfs diff=lfs merge=lfs -text
|
| 39 |
+
*.mlmodel filter=lfs diff=lfs merge=lfs -text
|
| 40 |
+
*.npy filter=lfs diff=lfs merge=lfs -text
|
| 41 |
+
*.npz filter=lfs diff=lfs merge=lfs -text
|
| 42 |
+
*.pickle filter=lfs diff=lfs merge=lfs -text
|
| 43 |
+
*.pkl filter=lfs diff=lfs merge=lfs -text
|
| 44 |
+
*.tar filter=lfs diff=lfs merge=lfs -text
|
| 45 |
+
*.wasm filter=lfs diff=lfs merge=lfs -text
|
| 46 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
| 47 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
| 48 |
*.png filter=lfs diff=lfs merge=lfs -text
|
LICENSE
CHANGED
|
@@ -0,0 +1,55 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
Qwen RESEARCH LICENSE AGREEMENT
|
| 2 |
+
|
| 3 |
+
Qwen RESEARCH LICENSE AGREEMENT Release Date: September 20, 2026
|
| 4 |
+
|
| 5 |
+
By clicking to agree or by using or distributing any portion or element of the Qwen Materials, you will be deemed to have recognized and accepted the content of this Agreement, which is effective immediately.
|
| 6 |
+
|
| 7 |
+
1. Definitions
|
| 8 |
+
a. This Qwen RESEARCH LICENSE AGREEMENT (this "Agreement") shall mean the terms and conditions for use, reproduction, distribution and modification of the Materials as defined by this Agreement.
|
| 9 |
+
b. "We" (or "Us") shall mean Hangzhou Tongyi Laboratory Technology Co., Ltd.
|
| 10 |
+
c. "You" (or "Your") shall mean a natural person or legal entity exercising the rights granted by this Agreement and/or using the Materials for any purpose and in any field of use.
|
| 11 |
+
d. "Third Parties" shall mean individuals or legal entities that are not under common control with us or you.
|
| 12 |
+
e. "Qwen" shall mean the large language models, diffusion models, and software and algorithms, consisting of trained model weights, parameters (including optimizer states), machine-learning model code, inference-enabling code, training-enabling code, fine-tuning enabling code and other elements of the foregoing distributed by us.
|
| 13 |
+
f. "Materials" shall mean, collectively, our proprietary Qwen and Documentation (and any portion thereof) made available under this Agreement.
|
| 14 |
+
g. "Source" form shall mean the preferred form for making modifications, including but not limited to model source code, documentation source, and configuration files.
|
| 15 |
+
h. "Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types.
|
| 16 |
+
i. "Non-Commercial" shall mean for research or evaluation purposes only.
|
| 17 |
+
|
| 18 |
+
2. Grant of Rights
|
| 19 |
+
a. You are granted a non-exclusive, worldwide, non-transferable and royalty-free limited license under our intellectual property or other rights owned by us embodied in the Materials to use, reproduce, distribute, copy, create derivative works of, and make modifications to the Materials FOR NON-COMMERCIAL PURPOSES ONLY.
|
| 20 |
+
b. You shall not use the Materials for any commercial purpose without obtaining a separate commercial license from us. If you wish to use the Materials commercially, you shall request a license from us at model-business@notice.qwencloud.com.
|
| 21 |
+
|
| 22 |
+
3. Redistribution
|
| 23 |
+
Subject to Section 2 (Grant of Rights), you may distribute copies or make the Materials, or derivative works thereof, available as part of a product or service that contains any of them, with or without modifications, and in Source or Object form, provided that you meet the following conditions:
|
| 24 |
+
a. You shall give any other recipients of the Materials or derivative works a copy of this Agreement;
|
| 25 |
+
b. You shall cause any modified files to carry prominent notices stating that you changed the files;
|
| 26 |
+
c. You shall retain in all copies of the Materials that you distribute the following attribution notices within a "Notice" text file distributed as a part of such copies: "Qwen is licensed under the Qwen RESEARCH LICENSE AGREEMENT, Copyright (c) 2026 Hangzhou Tongyi Laboratory Technology Co., Ltd. All Rights Reserved."; and
|
| 27 |
+
d. You may add your own copyright statement to your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of your modifications, or for any such derivative works as a whole, provided your use, reproduction, and distribution of the work otherwise complies with the terms and conditions of this Agreement.
|
| 28 |
+
|
| 29 |
+
4. Rules of use
|
| 30 |
+
a. The Materials may be subject to export controls or restrictions in China, the United States or other countries or regions. You shall comply with applicable laws and regulations in your use of the Materials.
|
| 31 |
+
b. If you use the Materials or any outputs or results therefrom to create, train, fine-tune, or improve an AI model that is distributed or made available, you shall prominently display “Built with Qwen” or “Improved using Qwen” in the related product documentation.
|
| 32 |
+
c. You shall not use "Qwen" as the primary name or identifier of any derivative works or products; reasonable descriptive use (e.g., "fine-tuned from Qwen Image") is permitted.
|
| 33 |
+
|
| 34 |
+
5. Intellectual Property
|
| 35 |
+
a. We retain ownership of all intellectual property rights in and to the Materials and derivatives made by or for us. Conditioned upon compliance with the terms and conditions of this Agreement, with respect to any derivative works and modifications of the Materials that are made by you, you are and will be the owner of such derivative works and modifications.
|
| 36 |
+
b. No trademark license is granted to use the trade names, trademarks, service marks, or product names of us, except as required to fulfill notice requirements under this Agreement or as required for reasonable and customary use in describing and redistributing the Materials.
|
| 37 |
+
c. If you commence a lawsuit or other proceedings (including a cross-claim or counterclaim in a lawsuit) against us or any entity alleging that the Materials or any output therefrom, or any part of the foregoing, infringe any intellectual property or other right owned or licensable by you, then all licenses granted to you under this Agreement shall terminate as of the date such lawsuit or other proceeding is commenced or brought.
|
| 38 |
+
|
| 39 |
+
6. Disclaimer of Warranty and Limitation of Liability
|
| 40 |
+
a. We are not obligated to support, update, provide training for, or develop any further version of the Qwen Materials or to grant any license thereto.
|
| 41 |
+
b. THE MATERIALS ARE PROVIDED "AS IS" WITHOUT ANY EXPRESS OR IMPLIED WARRANTY OF ANY KIND INCLUDING WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT, OR FITNESS FOR A PARTICULAR PURPOSE. WE MAKE NO WARRANTY AND ASSUME NO RESPONSIBILITY FOR THE SAFETY OR STABILITY OF THE MATERIALS AND ANY OUTPUT THEREFROM.
|
| 42 |
+
c. IN NO EVENT SHALL WE BE LIABLE TO YOU FOR ANY DAMAGES, INCLUDING, BUT NOT LIMITED TO ANY DIRECT, OR INDIRECT, SPECIAL OR CONSEQUENTIAL DAMAGES ARISING FROM YOUR USE OR INABILITY TO USE THE MATERIALS OR ANY OUTPUT OF IT, NO MATTER HOW IT’S CAUSED.
|
| 43 |
+
d. You will defend, indemnify and hold harmless us from and against any claim by any third party arising out of or related to your use or distribution of the Materials.
|
| 44 |
+
|
| 45 |
+
7. Survival and Termination.
|
| 46 |
+
a. The term of this Agreement shall commence upon your acceptance of this Agreement or access to the Materials and will continue in full force and effect until terminated in accordance with the terms and conditions herein.
|
| 47 |
+
b. We may terminate this Agreement if you breach any of the terms or conditions of this Agreement. Upon termination of this Agreement, you must delete and cease use of the Materials. Sections 6 and 8 shall survive the termination of this Agreement.
|
| 48 |
+
|
| 49 |
+
8. Governing Law and Jurisdiction.
|
| 50 |
+
a. This Agreement and any dispute arising out of or relating to it will be governed by the laws of China, without regard to conflict of law principles, and the UN Convention on Contracts for the International Sale of Goods does not apply to this Agreement.
|
| 51 |
+
b. The People's Courts in Hangzhou City shall have exclusive jurisdiction over any dispute arising out of this Agreement.
|
| 52 |
+
|
| 53 |
+
9. Other Terms and Conditions.
|
| 54 |
+
a. Any arrangements, understandings, or agreements regarding the Material not stated herein are separate from and independent of the terms and conditions of this Agreement. You shall request a separate license from us, if you use the Materials in ways not expressly agreed to in this Agreement.
|
| 55 |
+
b. We shall not be bound by any additional or different terms or conditions communicated by you unless expressly agreed.
|
Qwen-Image-2.1-Fun-Controlnet-Union.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:65d6b66d734da9e7ff5ef04e7db3a133553a52a3f29a7fcb3e9cce8fa21dcfcd
|
| 3 |
+
size 7550979904
|
README.md
CHANGED
|
@@ -1,5 +1,150 @@
|
|
| 1 |
---
|
| 2 |
license: other
|
| 3 |
-
license_name: qwen-research
|
| 4 |
license_link: LICENSE
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 5 |
---
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
---
|
| 2 |
license: other
|
|
|
|
| 3 |
license_link: LICENSE
|
| 4 |
+
license_name: qwen-research
|
| 5 |
+
library_name: videox_fun
|
| 6 |
+
tags:
|
| 7 |
+
- controlnet
|
| 8 |
+
- controlnet-union
|
| 9 |
+
- text-to-image
|
| 10 |
+
- image-to-image
|
| 11 |
+
- image-inpainting
|
| 12 |
+
tasks:
|
| 13 |
+
- text-to-image-synthesis
|
| 14 |
---
|
| 15 |
+
|
| 16 |
+
# Qwen-Image-2.1-Fun-Controlnet-Union
|
| 17 |
+
|
| 18 |
+
[](https://github.com/aigc-apps/VideoX-Fun)
|
| 19 |
+
|
| 20 |
+
## Overview
|
| 21 |
+
|
| 22 |
+
Qwen-Image-2.1-Fun-Controlnet-Union is a **ControlNet-Union branch for [Qwen-Image 2.1](https://github.com/aigc-apps/VideoX-Fun)** (the flow-matching text-to-image DiT). A single checkpoint drives **8 structural control conditions** (Canny, Depth, Grayscale, HED, Lineart, MLSD, Pose, Scribble) *and* image inpainting, without per-condition weights. The checkpoint holds **only the control branch** (`control_img_in` plus 16 `control_blocks`, about 7.0 GB) and is loaded on top of the base Qwen-Image 2.1 transformer.
|
| 23 |
+
|
| 24 |
+
## Model Card
|
| 25 |
+
|
| 26 |
+
| Name | Description |
|
| 27 |
+
|--|--|
|
| 28 |
+
| Qwen-Image-2.1-Fun-Controlnet-Union.safetensors | ControlNet-Union branch weights for Qwen-Image 2.1. Contains only the control branch (`control_img_in` + 16 `control_blocks`, about 7.0 GB); loaded with `strict=False` on top of the base Qwen-Image 2.1 transformer. One checkpoint covers 8 control conditions and image inpainting. |
|
| 29 |
+
|
| 30 |
+
## Model Features
|
| 31 |
+
- **Union control over 8 conditions**: one checkpoint handles Canny, Depth, Grayscale, HED, Lineart, MLSD, Pose and Scribble control images for text-to-image generation — no per-condition checkpoint switching.
|
| 32 |
+
- **Dense control injection**: the control branch attaches a skip to every 2nd of the 32 transformer blocks (`control_layers = [0, 2, 4, …, 30]`, 16 injection points). Each control skip is added back to the main branch through zero-gated `before_proj` / `after_proj` projections, giving tight structural adherence while the base model stays frozen.
|
| 33 |
+
- **Control and inpainting share one branch**: the control input is widened to `control_in_dim = 129` — `control latents (64) | mask (1) | masked-image latents (64)`. For pure control the mask / masked-image channels are zero-padded; for inpainting the same branch re-draws the masked region from the prompt. The two can also be **combined** — a control image and a mask are fed together, so the re-drawn region follows both the prompt and the given structure.
|
| 34 |
+
- **CFG-distilled fast sampling**: the standalone example scripts run with `guidance_scale = 1.0` (single forward pass per step, no classifier-free guidance needed).
|
| 35 |
+
- `control_context_scale` scales every control skip before it is added to the main branch: `1.0` is the strongest control (used for all results below), lower values weaken the guidance, `0.0` switches the control branch off.
|
| 36 |
+
- **Prompt-friendly**: write a prompt that describes the **whole target image**; the masked region is conveyed by the mask channel, not by the text. Detailed prompts give better stability.
|
| 37 |
+
- Qwen-Image 2.1 encodes the prompt (and any condition image) with a **Qwen3-VL** text encoder + processor, and its VAE decodes to **RGBA**, so every preview is saved as PNG.
|
| 38 |
+
|
| 39 |
+
## Supported control conditions
|
| 40 |
+
|
| 41 |
+
| Condition | Control signal |
|
| 42 |
+
|--|--|
|
| 43 |
+
| Canny | Canny edge map |
|
| 44 |
+
| Depth | Monocular depth map |
|
| 45 |
+
| Grayscale | Grayscale (luminance) image |
|
| 46 |
+
| HED | HED edge detection map |
|
| 47 |
+
| Lineart | Line-art extraction |
|
| 48 |
+
| MLSD | Line-segment detection map |
|
| 49 |
+
| Pose | DWPose skeleton |
|
| 50 |
+
| Scribble | Free-hand / sketch lines |
|
| 51 |
+
|
| 52 |
+
Any ordinary RGB control image at the target canvas works; the model tolerates different line thickness, thresholds and crops.
|
| 53 |
+
|
| 54 |
+
## Results
|
| 55 |
+
|
| 56 |
+
All samples below are generated with `num_inference_steps = 40`, `control_context_scale = 1.0`, seed 43. In each column the top row is the control image, the bottom row is the output.
|
| 57 |
+
|
| 58 |
+
<table border="0" style="width: 100%; text-align: left; margin-top: 20px;">
|
| 59 |
+
<tr><td>Canny</td><td>Depth</td><td>Grayscale</td><td>HED</td><td>Lineart</td><td>MLSD</td><td>Pose</td><td>Scribble</td></tr>
|
| 60 |
+
<tr>
|
| 61 |
+
<td><img src="https://huggingface.co/alibaba-pai/Qwen-Image-2.1-Fun-Controlnet-Union/resolve/main/asset/control_2_00025069.png" width="100%"></td>
|
| 62 |
+
<td><img src="https://huggingface.co/alibaba-pai/Qwen-Image-2.1-Fun-Controlnet-Union/resolve/main/asset/control_5_00005389.png" width="100%"></td>
|
| 63 |
+
<td><img src="https://huggingface.co/alibaba-pai/Qwen-Image-2.1-Fun-Controlnet-Union/resolve/main/asset/control_1_00014291.png" width="100%"></td>
|
| 64 |
+
<td><img src="https://huggingface.co/alibaba-pai/Qwen-Image-2.1-Fun-Controlnet-Union/resolve/main/asset/control_6_00009388.png" width="100%"></td>
|
| 65 |
+
<td><img src="https://huggingface.co/alibaba-pai/Qwen-Image-2.1-Fun-Controlnet-Union/resolve/main/asset/control_4_00003435.png" width="100%"></td>
|
| 66 |
+
<td><img src="https://huggingface.co/alibaba-pai/Qwen-Image-2.1-Fun-Controlnet-Union/resolve/main/asset/control_4_00027496.png" width="100%"></td>
|
| 67 |
+
<td><img src="https://huggingface.co/alibaba-pai/Qwen-Image-2.1-Fun-Controlnet-Union/resolve/main/asset/control_4_00000931.png" width="100%"></td>
|
| 68 |
+
<td><img src="https://huggingface.co/alibaba-pai/Qwen-Image-2.1-Fun-Controlnet-Union/resolve/main/asset/control_13_00000494.png" width="100%"></td>
|
| 69 |
+
</tr>
|
| 70 |
+
<tr>
|
| 71 |
+
<td><img src="https://huggingface.co/alibaba-pai/Qwen-Image-2.1-Fun-Controlnet-Union/resolve/main/results/control_2_00025069.png" width="100%"></td>
|
| 72 |
+
<td><img src="https://huggingface.co/alibaba-pai/Qwen-Image-2.1-Fun-Controlnet-Union/resolve/main/results/control_5_00005389.png" width="100%"></td>
|
| 73 |
+
<td><img src="https://huggingface.co/alibaba-pai/Qwen-Image-2.1-Fun-Controlnet-Union/resolve/main/results/control_1_00014291.png" width="100%"></td>
|
| 74 |
+
<td><img src="https://huggingface.co/alibaba-pai/Qwen-Image-2.1-Fun-Controlnet-Union/resolve/main/results/control_6_00009388.png" width="100%"></td>
|
| 75 |
+
<td><img src="https://huggingface.co/alibaba-pai/Qwen-Image-2.1-Fun-Controlnet-Union/resolve/main/results/control_4_00003435.png" width="100%"></td>
|
| 76 |
+
<td><img src="https://huggingface.co/alibaba-pai/Qwen-Image-2.1-Fun-Controlnet-Union/resolve/main/results/control_4_00027496.png" width="100%"></td>
|
| 77 |
+
<td><img src="https://huggingface.co/alibaba-pai/Qwen-Image-2.1-Fun-Controlnet-Union/resolve/main/results/control_4_00000931.png" width="100%"></td>
|
| 78 |
+
<td><img src="https://huggingface.co/alibaba-pai/Qwen-Image-2.1-Fun-Controlnet-Union/resolve/main/results/control_13_00000494.png" width="100%"></td>
|
| 79 |
+
</tr>
|
| 80 |
+
</table>
|
| 81 |
+
|
| 82 |
+
### Inpainting (+ control)
|
| 83 |
+
|
| 84 |
+
A masked region of the source image is re-drawn from the prompt while the rest of the frame is preserved. The mask image is **white where the content should be re-generated** and **black where it should be kept**. Because control and inpainting share the same branch, a control image (here a DWPose skeleton) is fed together with the mask, so the re-drawn region also follows the given pose.
|
| 85 |
+
|
| 86 |
+
<table border="0" style="width: 100%; text-align: left; margin-top: 20px;">
|
| 87 |
+
<tr><td>Source image</td><td>Mask</td><td>Pose control</td><td>Inpaint output</td></tr>
|
| 88 |
+
<tr>
|
| 89 |
+
<td><img src="https://huggingface.co/alibaba-pai/Qwen-Image-2.1-Fun-Controlnet-Union/resolve/main/asset/inpaint_source.png" width="100%"></td>
|
| 90 |
+
<td><img src="https://huggingface.co/alibaba-pai/Qwen-Image-2.1-Fun-Controlnet-Union/resolve/main/asset/inpaint_mask.png" width="100%"></td>
|
| 91 |
+
<td><img src="https://huggingface.co/alibaba-pai/Qwen-Image-2.1-Fun-Controlnet-Union/resolve/main/asset/inpaint_control.jpg" width="100%"></td>
|
| 92 |
+
<td><img src="https://huggingface.co/alibaba-pai/Qwen-Image-2.1-Fun-Controlnet-Union/resolve/main/results/inpaint.png" width="100%"></td>
|
| 93 |
+
</tr>
|
| 94 |
+
</table>
|
| 95 |
+
|
| 96 |
+
## Inference
|
| 97 |
+
Go to the VideoX-Fun repository for more details.
|
| 98 |
+
|
| 99 |
+
Please clone the VideoX-Fun repository and create the required directories:
|
| 100 |
+
|
| 101 |
+
```sh
|
| 102 |
+
# Clone the code
|
| 103 |
+
git clone https://github.com/aigc-apps/VideoX-Fun.git
|
| 104 |
+
|
| 105 |
+
# Enter VideoX-Fun's directory
|
| 106 |
+
cd VideoX-Fun
|
| 107 |
+
|
| 108 |
+
# Create model directories
|
| 109 |
+
mkdir -p models/Diffusion_Transformer
|
| 110 |
+
```
|
| 111 |
+
|
| 112 |
+
Then download the base Qwen-Image 2.1 model and this checkpoint into `models/Diffusion_Transformer`.
|
| 113 |
+
|
| 114 |
+
```
|
| 115 |
+
📦 models/
|
| 116 |
+
├── Diffusion_Transformer/
|
| 117 |
+
│ ├── 📂 Qwen-Image-2.1/
|
| 118 |
+
│ └── 📂 Qwen-Image-2.1-Fun-Controlnet-Union/
|
| 119 |
+
│ └── Qwen-Image-2.1-Fun-Controlnet-Union.safetensors
|
| 120 |
+
```
|
| 121 |
+
|
| 122 |
+
Then edit the settings at the top of `examples/qwenimage21_fun/predict_t2i_control.py` (or `predict_i2i_inpaint.py` for inpainting) and run it.
|
| 123 |
+
|
| 124 |
+
```python
|
| 125 |
+
model_name = "models/Diffusion_Transformer/Qwen-Image-2.1"
|
| 126 |
+
config_path = "config/qwenimage21/qwenimage21_control.yaml"
|
| 127 |
+
transformer_path = "models/Diffusion_Transformer/Qwen-Image-2.1-Fun-Controlnet-Union/Qwen-Image-2.1-Fun-Controlnet-Union.safetensors"
|
| 128 |
+
control_image = "asset/pose.jpg"
|
| 129 |
+
# inpaint only:
|
| 130 |
+
inpaint_image = "asset/8.png"
|
| 131 |
+
mask_image = "asset/mask.png"
|
| 132 |
+
prompt = "your prompt describing the whole target image"
|
| 133 |
+
```
|
| 134 |
+
|
| 135 |
+
```sh
|
| 136 |
+
python examples/qwenimage21_fun/predict_t2i_control.py
|
| 137 |
+
```
|
| 138 |
+
|
| 139 |
+
Notes:
|
| 140 |
+
- `config_path` **must** be `config/qwenimage21/qwenimage21_control.yaml`. It builds the control branch exactly as the checkpoint expects (`control_layers: [0, 2, 4, …, 30]`, `control_in_dim: 129`); a mismatched config silently drops or misplaces control weights and produces wrong outputs.
|
| 141 |
+
- For pure control (no inpaint input) the pipeline zero-pads the mask / masked-image channels, so this inpaint-capable checkpoint still runs plain Canny/Depth/… control correctly.
|
| 142 |
+
- The control checkpoint carries only the control branch; the base Qwen-Image 2.1 weights must be present in `model_name`.
|
| 143 |
+
- `control_context_scale = 1.0` is the value the adapter expects; use lower values to loosen the structural constraint.
|
| 144 |
+
- `sample_size` sets the output canvas (e.g. `[1728, 992]`); keep both sides as multiples of 16 so the control map is not distorted.
|
| 145 |
+
- `use_kv_cache = True` caches the text / condition-image keys after the first denoising step for a speedup at fixed resolution.
|
| 146 |
+
- Memory: the transformer plus the Qwen3-VL text encoder do not fit a single consumer GPU fully loaded; use `model_group_offload` (fastest) or `model_cpu_offload_and_qfloat8` on a single high-memory GPU.
|
| 147 |
+
|
| 148 |
+
## License
|
| 149 |
+
|
| 150 |
+
This model is a derivative of Qwen-Image 2.1 and is released under the [Qwen Research License](https://modelscope.cn/models/Qwen/Qwen-Image-2.1/file/view/master/LICENSE). Please read the license carefully before use.
|
README_zh.md
ADDED
|
@@ -0,0 +1,151 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
license: other
|
| 3 |
+
license_link: LICENSE
|
| 4 |
+
license_name: qwen-research
|
| 5 |
+
library_name: videox_fun
|
| 6 |
+
tags:
|
| 7 |
+
- controlnet
|
| 8 |
+
- controlnet-union
|
| 9 |
+
- text-to-image
|
| 10 |
+
- image-to-image
|
| 11 |
+
- image-inpainting
|
| 12 |
+
tasks:
|
| 13 |
+
- text-to-image-synthesis
|
| 14 |
+
---
|
| 15 |
+
|
| 16 |
+
# Qwen-Image-2.1-Fun-Controlnet-Union
|
| 17 |
+
|
| 18 |
+
[](https://github.com/aigc-apps/VideoX-Fun)
|
| 19 |
+
|
| 20 |
+
## 概述
|
| 21 |
+
|
| 22 |
+
Qwen-Image-2.1-Fun-Controlnet-Union 是面向 **[Qwen-Image 2.1](https://github.com/aigc-apps/VideoX-Fun)**(flow-matching 文生图 DiT)的 **ControlNet-Union 控制分支**。单个 checkpoint 即可驱动 **8 种结构控制条件**(Canny、深度、灰度、HED、Lineart、MLSD、姿态、涂鸦)*以及*图像修复,无需为每种条件单独准备权重。checkpoint **仅包含控制分支**(`control_img_in` 与 16 个 `control_blocks`,约 7.0 GB),需叠加加载到 Qwen-Image 2.1 基础 transformer 之上。
|
| 23 |
+
|
| 24 |
+
## 模型文件说明
|
| 25 |
+
|
| 26 |
+
| 文件名 | 说明 |
|
| 27 |
+
|--|--|
|
| 28 |
+
| Qwen-Image-2.1-Fun-Controlnet-Union.safetensors | Qwen-Image 2.1 的 ControlNet-Union 分支权重,仅包含控制分支(`control_img_in` + 16 个 `control_blocks`,约 7.0 GB),以 `strict=False` 叠加加载到 Qwen-Image 2.1 基础 transformer 之上。单个 checkpoint 覆盖 8 种控制条件及图像修复。 |
|
| 29 |
+
|
| 30 |
+
## 模型特性
|
| 31 |
+
- **一个 checkpoint 统管 8 种控制条件**:Canny、深度、灰度、HED、Lineart、MLSD、姿态、涂鸦控制图的文生图,无需为每种条件单独切换 checkpoint。
|
| 32 |
+
- **更密集的控制注入**:控制分支在 32 个 transformer 块中每 2 层接入一个跳接(`control_layers = [0, 2, 4, …, 30]`,共 16 个注入点)。每条控制跳接都经零初始化的 `before_proj` / `after_proj` 门控投影后叠加回主分支,在基础模型保持冻结的同时实现严格的结构还原。
|
| 33 |
+
- **控制与修复共用同一分支**:控制输入拓宽至 `control_in_dim = 129` —— `控制潜变量(64) | 掩码(1) | 掩码后图像潜变量(64)`。纯控制时掩码/掩码图像通道补零;修复时同一分支根据 prompt 重绘掩码区域。二者还可**叠加使用**——同时输入一张控制图与掩码,被重绘的区域会同时跟随 prompt 与给定的结构。
|
| 34 |
+
- **CFG 蒸馏快速采样**:独立的示例脚本以 `guidance_scale = 1.0` 推理(每步仅一次前向计算,无需 classifier-free guidance)。
|
| 35 |
+
- `control_context_scale` 在控制跳接叠加回主分支前对其进行缩放:`1.0` 为最强控制(下方所有结果均用此值),调低可减弱结构约束,`0.0` 则完全关闭控制分支。
|
| 36 |
+
- **提示词写法**:prompt 应描述**整张目标图像**;被打掩码的区域由掩码通道表达,而非文字。提示词越详细,生成越稳定。
|
| 37 |
+
- Qwen-Image 2.1 使用 **Qwen3-VL** 文本编码器 + processor 编码 prompt(及条件图),其 VAE 解码为 **RGBA**,因此所有预览图均以 PNG 保存。
|
| 38 |
+
|
| 39 |
+
## 支持的控制条件
|
| 40 |
+
|
| 41 |
+
| 条件 | 控制信号 |
|
| 42 |
+
|--|--|
|
| 43 |
+
| Canny | Canny 边缘图 |
|
| 44 |
+
| Depth | 单目深度图 |
|
| 45 |
+
| Grayscale | 灰度(亮度)图 |
|
| 46 |
+
| HED | HED 边缘检测图 |
|
| 47 |
+
| Lineart | 线稿提取图 |
|
| 48 |
+
| MLSD | 直线段检测图 |
|
| 49 |
+
| Pose | DWPose 人体骨架 |
|
| 50 |
+
| Scribble | 手绘 / 草图线条 |
|
| 51 |
+
|
| 52 |
+
任何与目标画布尺寸一致的普通 RGB 控制图均可使用;模型对不同线条粗细、阈值与裁剪都有很好的容忍度。
|
| 53 |
+
|
| 54 |
+
## 生成效果
|
| 55 |
+
|
| 56 |
+
以下所有样例均在 `num_inference_steps = 40`、`control_context_scale = 1.0`、随机种子 43 的条件下生成。每列中,上排为控制图,下排为生成结果。
|
| 57 |
+
|
| 58 |
+
<table border="0" style="width: 100%; text-align: left; margin-top: 20px;">
|
| 59 |
+
<tr><td>Canny</td><td>Depth</td><td>Grayscale</td><td>HED</td><td>Lineart</td><td>MLSD</td><td>Pose</td><td>Scribble</td></tr>
|
| 60 |
+
<tr>
|
| 61 |
+
<td><img src="https://huggingface.co/alibaba-pai/Qwen-Image-2.1-Fun-Controlnet-Union/resolve/main/asset/control_2_00025069.png" width="100%"></td>
|
| 62 |
+
<td><img src="https://huggingface.co/alibaba-pai/Qwen-Image-2.1-Fun-Controlnet-Union/resolve/main/asset/control_5_00005389.png" width="100%"></td>
|
| 63 |
+
<td><img src="https://huggingface.co/alibaba-pai/Qwen-Image-2.1-Fun-Controlnet-Union/resolve/main/asset/control_1_00014291.png" width="100%"></td>
|
| 64 |
+
<td><img src="https://huggingface.co/alibaba-pai/Qwen-Image-2.1-Fun-Controlnet-Union/resolve/main/asset/control_6_00009388.png" width="100%"></td>
|
| 65 |
+
<td><img src="https://huggingface.co/alibaba-pai/Qwen-Image-2.1-Fun-Controlnet-Union/resolve/main/asset/control_4_00003435.png" width="100%"></td>
|
| 66 |
+
<td><img src="https://huggingface.co/alibaba-pai/Qwen-Image-2.1-Fun-Controlnet-Union/resolve/main/asset/control_4_00027496.png" width="100%"></td>
|
| 67 |
+
<td><img src="https://huggingface.co/alibaba-pai/Qwen-Image-2.1-Fun-Controlnet-Union/resolve/main/asset/control_4_00000931.png" width="100%"></td>
|
| 68 |
+
<td><img src="https://huggingface.co/alibaba-pai/Qwen-Image-2.1-Fun-Controlnet-Union/resolve/main/asset/control_13_00000494.png" width="100%"></td>
|
| 69 |
+
</tr>
|
| 70 |
+
<tr>
|
| 71 |
+
<td><img src="https://huggingface.co/alibaba-pai/Qwen-Image-2.1-Fun-Controlnet-Union/resolve/main/results/control_2_00025069.png" width="100%"></td>
|
| 72 |
+
<td><img src="https://huggingface.co/alibaba-pai/Qwen-Image-2.1-Fun-Controlnet-Union/resolve/main/results/control_5_00005389.png" width="100%"></td>
|
| 73 |
+
<td><img src="https://huggingface.co/alibaba-pai/Qwen-Image-2.1-Fun-Controlnet-Union/resolve/main/results/control_1_00014291.png" width="100%"></td>
|
| 74 |
+
<td><img src="https://huggingface.co/alibaba-pai/Qwen-Image-2.1-Fun-Controlnet-Union/resolve/main/results/control_6_00009388.png" width="100%"></td>
|
| 75 |
+
<td><img src="https://huggingface.co/alibaba-pai/Qwen-Image-2.1-Fun-Controlnet-Union/resolve/main/results/control_4_00003435.png" width="100%"></td>
|
| 76 |
+
<td><img src="https://huggingface.co/alibaba-pai/Qwen-Image-2.1-Fun-Controlnet-Union/resolve/main/results/control_4_00027496.png" width="100%"></td>
|
| 77 |
+
<td><img src="https://huggingface.co/alibaba-pai/Qwen-Image-2.1-Fun-Controlnet-Union/resolve/main/results/control_4_00000931.png" width="100%"></td>
|
| 78 |
+
<td><img src="https://huggingface.co/alibaba-pai/Qwen-Image-2.1-Fun-Controlnet-Union/resolve/main/results/control_13_00000494.png" width="100%"></td>
|
| 79 |
+
</tr>
|
| 80 |
+
</table>
|
| 81 |
+
|
| 82 |
+
### 图像修复(+ 控制)
|
| 83 |
+
|
| 84 |
+
源图中被打上掩码的区域会根据 prompt 重新绘制,画面其余部分原样保留。掩码图中,**需要重新生成的区域为白色**,**需要保留的区域为黑色**。由于控制与修复共用同一分支,这里在掩码之外还同时输入了一张控制图(DWPose 骨架),被重绘的区域因此也会跟随给定的姿态。
|
| 85 |
+
|
| 86 |
+
<table border="0" style="width: 100%; text-align: left; margin-top: 20px;">
|
| 87 |
+
<tr><td>源图</td><td>掩码</td><td>姿态控制</td><td>修复输出</td></tr>
|
| 88 |
+
<tr>
|
| 89 |
+
<td><img src="https://huggingface.co/alibaba-pai/Qwen-Image-2.1-Fun-Controlnet-Union/resolve/main/asset/inpaint_source.png" width="100%"></td>
|
| 90 |
+
<td><img src="https://huggingface.co/alibaba-pai/Qwen-Image-2.1-Fun-Controlnet-Union/resolve/main/asset/inpaint_mask.png" width="100%"></td>
|
| 91 |
+
<td><img src="https://huggingface.co/alibaba-pai/Qwen-Image-2.1-Fun-Controlnet-Union/resolve/main/asset/inpaint_control.jpg" width="100%"></td>
|
| 92 |
+
<td><img src="https://huggingface.co/alibaba-pai/Qwen-Image-2.1-Fun-Controlnet-Union/resolve/main/results/inpaint.png" width="100%"></td>
|
| 93 |
+
</tr>
|
| 94 |
+
</table>
|
| 95 |
+
|
| 96 |
+
## 推理
|
| 97 |
+
|
| 98 |
+
更多细节请参见 VideoX-Fun 代码仓库。
|
| 99 |
+
|
| 100 |
+
首先克隆 VideoX-Fun 仓库并创建模型目录:
|
| 101 |
+
|
| 102 |
+
```sh
|
| 103 |
+
# 克隆代码
|
| 104 |
+
git clone https://github.com/aigc-apps/VideoX-Fun.git
|
| 105 |
+
|
| 106 |
+
# 进入 VideoX-Fun 目录
|
| 107 |
+
cd VideoX-Fun
|
| 108 |
+
|
| 109 |
+
# 创建模型目录
|
| 110 |
+
mkdir -p models/Diffusion_Transformer
|
| 111 |
+
```
|
| 112 |
+
|
| 113 |
+
随后将 Qwen-Image 2.1 基础模型与本 checkpoint 下载至 `models/Diffusion_Transformer` 下:
|
| 114 |
+
|
| 115 |
+
```
|
| 116 |
+
📦 models/
|
| 117 |
+
├── Diffusion_Transformer/
|
| 118 |
+
│ ├── 📂 Qwen-Image-2.1/
|
| 119 |
+
│ └── 📂 Qwen-Image-2.1-Fun-Controlnet-Union/
|
| 120 |
+
│ └── Qwen-Image-2.1-Fun-Controlnet-Union.safetensors
|
| 121 |
+
```
|
| 122 |
+
|
| 123 |
+
接着修改 `examples/qwenimage21_fun/predict_t2i_control.py`(图像修复用 `predict_i2i_inpaint.py`)顶部的配置项,然后运行:
|
| 124 |
+
|
| 125 |
+
```python
|
| 126 |
+
model_name = "models/Diffusion_Transformer/Qwen-Image-2.1"
|
| 127 |
+
config_path = "config/qwenimage21/qwenimage21_control.yaml"
|
| 128 |
+
transformer_path = "models/Diffusion_Transformer/Qwen-Image-2.1-Fun-Controlnet-Union/Qwen-Image-2.1-Fun-Controlnet-Union.safetensors"
|
| 129 |
+
control_image = "asset/pose.jpg"
|
| 130 |
+
# 仅修复任务需要:
|
| 131 |
+
inpaint_image = "asset/8.png"
|
| 132 |
+
mask_image = "asset/mask.png"
|
| 133 |
+
prompt = "描述整张目标图像的 prompt"
|
| 134 |
+
```
|
| 135 |
+
|
| 136 |
+
```sh
|
| 137 |
+
python examples/qwenimage21_fun/predict_t2i_control.py
|
| 138 |
+
```
|
| 139 |
+
|
| 140 |
+
注意事项:
|
| 141 |
+
- `config_path` **必须**是 `config/qwenimage21/qwenimage21_control.yaml`:只有它能按 checkpoint 期望的结构完整搭建控制分支(`control_layers: [0, 2, 4, …, 30]`、`control_in_dim: 129`);配置不匹配会静默丢弃或错位加载控制权重,产出错误结果。
|
| 142 |
+
- 纯控制(不做修复输入)时,pipeline 会自动把掩码 / 掩码图像通道补零,因此这个支持修复的 checkpoint 一样能正确跑普通的 Canny/深度/… 控制任务。
|
| 143 |
+
- 控制 checkpoint 只含控制分支,`model_name` 目录中必须有 Qwen-Image 2.1 基础权重。
|
| 144 |
+
- `control_context_scale = 1.0` 是适配器期望的取值;调低可减弱结构约束。
|
| 145 |
+
- `sample_size` 设定输出画布(如 `[1728, 992]`);请将宽高均保持为 32 的倍数,以免控制图被拉伸变形。
|
| 146 |
+
- `use_kv_cache = True` 会在首个去噪步后缓存文本 / 条件图的 key/value,在固定分辨率下加速推理。
|
| 147 |
+
- 显存:transformer 加 Qwen3-VL 文本编码器无法在单张消费级显卡上全量驻留;单卡大显存请使用 `model_group_offload`(速度最快)或 `model_cpu_offload_and_qfloat8`。
|
| 148 |
+
|
| 149 |
+
## 许可证
|
| 150 |
+
|
| 151 |
+
本模型为 Qwen-Image 2.1 的衍生模型,依据 [Qwen Research License](https://modelscope.cn/models/Qwen/Qwen-Image-2.1/file/view/master/LICENSE) 发布。使用前请仔细阅读许可条款。
|
asset/control_13_00000494.png
ADDED
|
Git LFS Details
|
asset/control_1_00014291.png
ADDED
|
Git LFS Details
|
asset/control_2_00001450.png
ADDED
|
Git LFS Details
|
asset/control_2_00025069.png
ADDED
|
Git LFS Details
|
asset/control_4_00000931.png
ADDED
|
Git LFS Details
|
asset/control_4_00003435.png
ADDED
|
Git LFS Details
|
asset/control_4_00027496.png
ADDED
|
Git LFS Details
|
asset/control_5_00005389.png
ADDED
|
Git LFS Details
|
asset/control_6_00009388.png
ADDED
|
Git LFS Details
|
asset/control_7_00015359.png
ADDED
|
Git LFS Details
|
asset/control_7_00018303.png
ADDED
|
Git LFS Details
|
asset/control_7_00034515.png
ADDED
|
Git LFS Details
|
asset/inpaint_control.jpg
ADDED
|
Git LFS Details
|
asset/inpaint_mask.png
ADDED
|
Git LFS Details
|
asset/inpaint_source.png
ADDED
|
Git LFS Details
|
configuration.json
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
{"task":"text-to-image-synthesis"}
|
results/control_13_00000494.png
ADDED
|
Git LFS Details
|
results/control_1_00014291.png
ADDED
|
Git LFS Details
|
results/control_2_00001450.png
ADDED
|
Git LFS Details
|
results/control_2_00025069.png
ADDED
|
Git LFS Details
|
results/control_4_00000931.png
ADDED
|
Git LFS Details
|
results/control_4_00003435.png
ADDED
|
Git LFS Details
|
results/control_4_00027496.png
ADDED
|
Git LFS Details
|
results/control_5_00005389.png
ADDED
|
Git LFS Details
|
results/control_6_00009388.png
ADDED
|
Git LFS Details
|
results/control_7_00015359.png
ADDED
|
Git LFS Details
|
results/control_7_00018303.png
ADDED
|
Git LFS Details
|
results/control_7_00034515.png
ADDED
|
Git LFS Details
|
results/inpaint.png
ADDED
|
Git LFS Details
|