recoilme commited on
Commit
3a93d0e
·
1 Parent(s): c49fab3

Zen Image Edit: Qwen-Image-2.1 on Qwen3.5-0.8B with a text-fusion adapter inside the DiT

Browse files

Text encoder replaced (Qwen3-VL-8B -> Qwen3.5-0.8B + 158M adapter), adapter embedded in the
transformer as text_fusion before txt_in. Weights fp16 (VAE fp32, 13 files via LFS), 8 example
images generated by this pipeline, NOTICE/LICENSE included per the Qwen Research License.

.gitattributes CHANGED
@@ -33,3 +33,7 @@ saved_model/**/* 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
 
 
 
 
 
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
37
+ *.jpg filter=lfs diff=lfs merge=lfs -text
38
+ *.jpeg filter=lfs diff=lfs merge=lfs -text
39
+ tokenizer.json filter=lfs diff=lfs merge=lfs -text
.gitignore ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ __pycache__/
2
+ *.pyc
3
+ .ipynb_checkpoints/
LICENSE ADDED
@@ -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.
LICENSE-Qwen3.5-0.8B ADDED
@@ -0,0 +1,202 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ Apache License
3
+ Version 2.0, January 2004
4
+ http://www.apache.org/licenses/
5
+
6
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7
+
8
+ 1. Definitions.
9
+
10
+ "License" shall mean the terms and conditions for use, reproduction,
11
+ and distribution as defined by Sections 1 through 9 of this document.
12
+
13
+ "Licensor" shall mean the copyright owner or entity authorized by
14
+ the copyright owner that is granting the License.
15
+
16
+ "Legal Entity" shall mean the union of the acting entity and all
17
+ other entities that control, are controlled by, or are under common
18
+ control with that entity. For the purposes of this definition,
19
+ "control" means (i) the power, direct or indirect, to cause the
20
+ direction or management of such entity, whether by contract or
21
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
+ outstanding shares, or (iii) beneficial ownership of such entity.
23
+
24
+ "You" (or "Your") shall mean an individual or Legal Entity
25
+ exercising permissions granted by this License.
26
+
27
+ "Source" form shall mean the preferred form for making modifications,
28
+ including but not limited to software source code, documentation
29
+ source, and configuration files.
30
+
31
+ "Object" form shall mean any form resulting from mechanical
32
+ transformation or translation of a Source form, including but
33
+ not limited to compiled object code, generated documentation,
34
+ and conversions to other media types.
35
+
36
+ "Work" shall mean the work of authorship, whether in Source or
37
+ Object form, made available under the License, as indicated by a
38
+ copyright notice that is included in or attached to the work
39
+ (an example is provided in the Appendix below).
40
+
41
+ "Derivative Works" shall mean any work, whether in Source or Object
42
+ form, that is based on (or derived from) the Work and for which the
43
+ editorial revisions, annotations, elaborations, or other modifications
44
+ represent, as a whole, an original work of authorship. For the purposes
45
+ of this License, Derivative Works shall not include works that remain
46
+ separable from, or merely link (or bind by name) to the interfaces of,
47
+ the Work and Derivative Works thereof.
48
+
49
+ "Contribution" shall mean any work of authorship, including
50
+ the original version of the Work and any modifications or additions
51
+ to that Work or Derivative Works thereof, that is intentionally
52
+ submitted to Licensor for inclusion in the Work by the copyright owner
53
+ or by an individual or Legal Entity authorized to submit on behalf of
54
+ the copyright owner. For the purposes of this definition, "submitted"
55
+ means any form of electronic, verbal, or written communication sent
56
+ to the Licensor or its representatives, including but not limited to
57
+ communication on electronic mailing lists, source code control systems,
58
+ and issue tracking systems that are managed by, or on behalf of, the
59
+ Licensor for the purpose of discussing and improving the Work, but
60
+ excluding communication that is conspicuously marked or otherwise
61
+ designated in writing by the copyright owner as "Not a Contribution."
62
+
63
+ "Contributor" shall mean Licensor and any individual or Legal Entity
64
+ on behalf of whom a Contribution has been received by Licensor and
65
+ subsequently incorporated within the Work.
66
+
67
+ 2. Grant of Copyright License. Subject to the terms and conditions of
68
+ this License, each Contributor hereby grants to You a perpetual,
69
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
+ copyright license to reproduce, prepare Derivative Works of,
71
+ publicly display, publicly perform, sublicense, and distribute the
72
+ Work and such Derivative Works in Source or Object form.
73
+
74
+ 3. Grant of Patent License. Subject to the terms and conditions of
75
+ this License, each Contributor hereby grants to You a perpetual,
76
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
+ (except as stated in this section) patent license to make, have made,
78
+ use, offer to sell, sell, import, and otherwise transfer the Work,
79
+ where such license applies only to those patent claims licensable
80
+ by such Contributor that are necessarily infringed by their
81
+ Contribution(s) alone or by combination of their Contribution(s)
82
+ with the Work to which such Contribution(s) was submitted. If You
83
+ institute patent litigation against any entity (including a
84
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
85
+ or a Contribution incorporated within the Work constitutes direct
86
+ or contributory patent infringement, then any patent licenses
87
+ granted to You under this License for that Work shall terminate
88
+ as of the date such litigation is filed.
89
+
90
+ 4. Redistribution. You may reproduce and distribute copies of the
91
+ Work or Derivative Works thereof in any medium, with or without
92
+ modifications, and in Source or Object form, provided that You
93
+ meet the following conditions:
94
+
95
+ (a) You must give any other recipients of the Work or
96
+ Derivative Works a copy of this License; and
97
+
98
+ (b) You must cause any modified files to carry prominent notices
99
+ stating that You changed the files; and
100
+
101
+ (c) You must retain, in the Source form of any Derivative Works
102
+ that You distribute, all copyright, patent, trademark, and
103
+ attribution notices from the Source form of the Work,
104
+ excluding those notices that do not pertain to any part of
105
+ the Derivative Works; and
106
+
107
+ (d) If the Work includes a "NOTICE" text file as part of its
108
+ distribution, then any Derivative Works that You distribute must
109
+ include a readable copy of the attribution notices contained
110
+ within such NOTICE file, excluding those notices that do not
111
+ pertain to any part of the Derivative Works, in at least one
112
+ of the following places: within a NOTICE text file distributed
113
+ as part of the Derivative Works; within the Source form or
114
+ documentation, if provided along with the Derivative Works; or,
115
+ within a display generated by the Derivative Works, if and
116
+ wherever such third-party notices normally appear. The contents
117
+ of the NOTICE file are for informational purposes only and
118
+ do not modify the License. You may add Your own attribution
119
+ notices within Derivative Works that You distribute, alongside
120
+ or as an addendum to the NOTICE text from the Work, provided
121
+ that such additional attribution notices cannot be construed
122
+ as modifying the License.
123
+
124
+ You may add Your own copyright statement to Your modifications and
125
+ may provide additional or different license terms and conditions
126
+ for use, reproduction, or distribution of Your modifications, or
127
+ for any such Derivative Works as a whole, provided Your use,
128
+ reproduction, and distribution of the Work otherwise complies with
129
+ the conditions stated in this License.
130
+
131
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
132
+ any Contribution intentionally submitted for inclusion in the Work
133
+ by You to the Licensor shall be under the terms and conditions of
134
+ this License, without any additional terms or conditions.
135
+ Notwithstanding the above, nothing herein shall supersede or modify
136
+ the terms of any separate license agreement you may have executed
137
+ with Licensor regarding such Contributions.
138
+
139
+ 6. Trademarks. This License does not grant permission to use the trade
140
+ names, trademarks, service marks, or product names of the Licensor,
141
+ except as required for reasonable and customary use in describing the
142
+ origin of the Work and reproducing the content of the NOTICE file.
143
+
144
+ 7. Disclaimer of Warranty. Unless required by applicable law or
145
+ agreed to in writing, Licensor provides the Work (and each
146
+ Contributor provides its Contributions) on an "AS IS" BASIS,
147
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
+ implied, including, without limitation, any warranties or conditions
149
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
+ PARTICULAR PURPOSE. You are solely responsible for determining the
151
+ appropriateness of using or redistributing the Work and assume any
152
+ risks associated with Your exercise of permissions under this License.
153
+
154
+ 8. Limitation of Liability. In no event and under no legal theory,
155
+ whether in tort (including negligence), contract, or otherwise,
156
+ unless required by applicable law (such as deliberate and grossly
157
+ negligent acts) or agreed to in writing, shall any Contributor be
158
+ liable to You for damages, including any direct, indirect, special,
159
+ incidental, or consequential damages of any character arising as a
160
+ result of this License or out of the use or inability to use the
161
+ Work (including but not limited to damages for loss of goodwill,
162
+ work stoppage, computer failure or malfunction, or any and all
163
+ other commercial damages or losses), even if such Contributor
164
+ has been advised of the possibility of such damages.
165
+
166
+ 9. Accepting Warranty or Additional Liability. While redistributing
167
+ the Work or Derivative Works thereof, You may choose to offer,
168
+ and charge a fee for, acceptance of support, warranty, indemnity,
169
+ or other liability obligations and/or rights consistent with this
170
+ License. However, in accepting such obligations, You may act only
171
+ on Your own behalf and on Your sole responsibility, not on behalf
172
+ of any other Contributor, and only if You agree to indemnify,
173
+ defend, and hold each Contributor harmless for any liability
174
+ incurred by, or claims asserted against, such Contributor by reason
175
+ of your accepting any such warranty or additional liability.
176
+
177
+ END OF TERMS AND CONDITIONS
178
+
179
+ APPENDIX: How to apply the Apache License to your work.
180
+
181
+ To apply the Apache License to your work, attach the following
182
+ boilerplate notice, with the fields enclosed by brackets "[]"
183
+ replaced with your own identifying information. (Don't include
184
+ the brackets!) The text should be enclosed in the appropriate
185
+ comment syntax for the file format. We also recommend that a
186
+ file or class name and description of purpose be included on the
187
+ same "printed page" as the copyright notice for easier
188
+ identification within third-party archives.
189
+
190
+ Copyright 2026 Alibaba Cloud
191
+
192
+ Licensed under the Apache License, Version 2.0 (the "License");
193
+ you may not use this file except in compliance with the License.
194
+ You may obtain a copy of the License at
195
+
196
+ http://www.apache.org/licenses/LICENSE-2.0
197
+
198
+ Unless required by applicable law or agreed to in writing, software
199
+ distributed under the License is distributed on an "AS IS" BASIS,
200
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
201
+ See the License for the specific language governing permissions and
202
+ limitations under the License.
NOTICE ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ NOTICE
2
+ ======
3
+
4
+ Qwen is licensed under the Qwen RESEARCH LICENSE AGREEMENT, Copyright (c) 2026
5
+ Hangzhou Tongyi Laboratory Technology Co., Ltd. All Rights Reserved.
6
+
7
+ This repository is a derivative work of Qwen-Image-2.1. The full agreement is in
8
+ `LICENSE`, a copy of it is given to every recipient of these files.
9
+
10
+ Modified files, as required by section 2.b of the agreement:
11
+
12
+ transformer/config.json added the `text_fusion_config` key, `_class_name` changed to
13
+ QwenImage21FusionTransformer2DModel
14
+ transformer/*.safetensors re-saved in fp16, plus the 66 `text_fusion.*` tensors of the
15
+ adapter from the image21-08b-text-encoder-adapter project (adapter_v11)
16
+ vae/ copied unchanged (fp32)
17
+ scheduler/ copied unchanged
18
+ text_encoder/ different model: Qwen3.5-0.8B in fp16 instead of Qwen3-VL-8B
19
+ tokenizer/, processor/ different tokenizer/processor: the Qwen3.5-0.8B ones
20
+
21
+ Files added by this repository: pipeline.py, transformer.py, example.py, model_index.json,
22
+ media/, README.md.
23
+
24
+ Improved using Qwen.
25
+ The Qwen3.5-0.8B text encoder is redistributed under the Apache License 2.0, see
26
+ `LICENSE-Qwen3.5-0.8B`.
README.md ADDED
@@ -0,0 +1,147 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: other
3
+ license_name: qwen-research
4
+ license_link: https://huggingface.co/AiArtLab/zen-image-edit/blob/main/LICENSE
5
+ library_name: diffusers
6
+ pipeline_tag: image-to-image
7
+ base_model:
8
+ - Qwen/Qwen-Image-2.1
9
+ - Qwen/Qwen3.5-0.8B
10
+ tags:
11
+ - text-to-image
12
+ - image-editing
13
+ - diffusers
14
+ - qwen-image
15
+ - text-encoder
16
+ - adapter
17
+ ---
18
+
19
+ # Zen Image Edit
20
+
21
+ *Qwen-Image-2.1 on a 0.8B text encoder.*
22
+ Text-to-image, character and scene editing, and transparent (RGBA) generation in one pipeline.
23
+
24
+ <img src="media/hero.jpg" width="512"/>
25
+
26
+ | | |
27
+ |---|---|
28
+ | transformer | Qwen-Image-2.1 DiT — 32 layers, 14.5 GB fp16, plus a **158M text-fusion adapter** inside |
29
+ | text encoder | **Qwen3.5-0.8B**, 1.7 GB fp16 (native: Qwen3-VL-8B, 17.5 GB) |
30
+ | conditioning | cosine **0.94** against the native Qwen3-VL-8B encoder (text positions) |
31
+ | VAE | Qwen-Image-2.1, 16× spatial, fp32 |
32
+ | scheduler | `FlowMatchEulerDiscreteScheduler` |
33
+ | resolution | `output_resolution`, 1024 by default; follows the condition image aspect ratio |
34
+ | precision | fp16 everywhere except the VAE |
35
+ | peak VRAM | ~17.5 GB resident, less with `enable_model_cpu_offload()` |
36
+
37
+ ### What changed
38
+
39
+ The text encoder is replaced by **Qwen3.5-0.8B** plus a 158M adapter, fine-tuned to reproduce what
40
+ the native encoder produced — both from plain text and from text read together with the reference
41
+ images (**Improved using Qwen**). The adapter lives *inside* the DiT as its text-fusion block, so the
42
+ whole model is one self-contained diffusers folder and no 17.5 GB encoder is needed anywhere.
43
+
44
+ ### Examples
45
+
46
+ Every image below is generated by this pipeline with 30 steps at 1024 px.
47
+
48
+ **Text-to-image**
49
+
50
+ | | |
51
+ |---|---|
52
+ | ![t2i](media/t2i.jpg) | ![hero](media/hero.jpg) |
53
+
54
+ **Edit — one condition image** (background change, subject kept)
55
+
56
+ ![edit single](media/edit_single.jpg)
57
+
58
+ **Edit — two condition images** (character replacement: identity from `<image1>`, pose/clothing/scene from `<image2>`)
59
+
60
+ | | |
61
+ |---|---|
62
+ | ![edit swap](media/edit_swap.jpg) | ![edit char](media/edit_char.jpg) |
63
+
64
+ **Edit — three condition images** (subject from `<image1>`, scene from `<image2>`, lighting from `<image3>`)
65
+
66
+ ![edit three](media/edit_three.jpg)
67
+
68
+ **Transparent RGBA**
69
+
70
+ ![transparent](media/transparent.png)
71
+
72
+ ### Usage
73
+
74
+ ```python
75
+ import torch
76
+ from pipeline import ZenImageEditPipeline # shipped in this repo
77
+
78
+ pipe = ZenImageEditPipeline.from_pretrained(".", dtype=torch.float16)
79
+ pipe.enable_model_cpu_offload() # 14.5 GB DiT + fp32 VAE decoder do not co-reside on 32 GB
80
+
81
+ # text-to-image
82
+ image = pipe(prompt="a red fox in a snowy forest at dusk, cinematic, 85mm",
83
+ output_resolution=1024, num_inference_steps=30,
84
+ generator=torch.Generator("cuda").manual_seed(1234)).images[0]
85
+
86
+ # editing: 1..N condition images, referenced in the prompt by TAG <image1>, <image2>, ...
87
+ image = pipe(prompt="Replace the woman in <image2> with the woman from <image1>; keep <image2> pose, "
88
+ "clothing and background unchanged.",
89
+ image=[ref_image, scene_image],
90
+ output_resolution=1024, num_inference_steps=30,
91
+ generator=torch.Generator("cuda").manual_seed(1234)).images[0]
92
+ ```
93
+
94
+ CLI: `python example.py --prompt "..." [--image a.png b.png] --out out.png`
95
+
96
+ ### Files
97
+
98
+ ```
99
+ pipeline.py ZenImageEditPipeline — one class for t2i and editing, as QwenImage21Pipeline
100
+ transformer.py QwenImage21FusionTransformer2DModel + the text-fusion blocks
101
+ example.py CLI for both modes
102
+ transformer/ DiT config + 2 fp16 shards, adapter merged in as text_fusion.*
103
+ text_encoder/ Qwen3.5-0.8B, fp16
104
+ processor/ its processor (image slicing + tokenization)
105
+ tokenizer/ its tokenizer
106
+ vae/ Qwen-Image-2.1 VAE, fp32
107
+ scheduler/ FlowMatchEulerDiscreteScheduler config
108
+ media/ the examples above
109
+ ```
110
+
111
+ `QwenImage21FusionTransformer2DModel` is a custom class defined in `transformer.py`, not registered
112
+ inside `diffusers`, so plain `DiffusionPipeline.from_pretrained` does not resolve it. Load through the
113
+ shipped pipeline with this folder on `sys.path`.
114
+
115
+ ### Limitations
116
+
117
+ * **English only** — that is all the adapter was trained and tested on; other languages drift.
118
+ * **Numerals on signage** come out wrong: "OPEN 24 HOURS" renders as "OPEN **26** HOURS" on every
119
+ seed tried. Words are fine. ![numbers](media/limit_numbers.jpg)
120
+ * Batch size >1 at 1024 px peaks near 28 GB; one prompt per call is the safe mode.
121
+
122
+ ### NOTICE
123
+
124
+ Qwen is licensed under the Qwen RESEARCH LICENSE AGREEMENT, Copyright (c) 2026 Hangzhou Tongyi
125
+ Laboratory Technology Co., Ltd. All Rights Reserved.
126
+
127
+ This is a derivative work of Qwen-Image-2.1 — the full agreement is in `LICENSE`, the list of
128
+ modified files and the remainder of the required attribution is in `NOTICE`. The Qwen3.5-0.8B text
129
+ encoder is redistributed under the Apache License 2.0, see `LICENSE-Qwen3.5-0.8B`.
130
+
131
+ ## Contacts
132
+
133
+ Please contact with us if you may provide some GPU's or money on training
134
+
135
+ - telegram [recoilme](https://t.me/recoilme) *prefered way
136
+ - mail at aiartlab.org (slow response)
137
+
138
+ ## Citation
139
+
140
+ ```bibtex
141
+ @misc{zenimageedit,
142
+ title={Zen Image Edit},
143
+ author={recoilme and AiArtLab Team},
144
+ url={https://huggingface.co/AiArtLab/zen-image-edit},
145
+ year={2026}
146
+ }
147
+ ```
example.py ADDED
@@ -0,0 +1,68 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env python3
2
+ """zen-image-edit inference: no native text encoder (Qwen3-VL-8B, 17.5 GB) anywhere.
3
+
4
+ On the GPU: Qwen3.5-0.8B (~1.7 GB), the DiT with the adapter inside (~14.5 GB) and the VAE
5
+ (~1.4 GB, fp32).
6
+
7
+ # text-to-image
8
+ python example.py --prompt "a red fox in a snowy forest at dusk, cinematic, 85mm" --out fox.png
9
+
10
+ # editing: 1..N condition images, referenced in the prompt by TAG <image1>, <image2>, ...
11
+ python example.py --image ref.png scene.png \
12
+ --prompt "Replace the woman in <image2> with the woman from <image1>; keep <image2> pose, \\
13
+ clothing and background unchanged." --out swap.png
14
+ """
15
+ import argparse
16
+ import os
17
+ import sys
18
+
19
+ import torch
20
+ from PIL import Image as PILImage
21
+
22
+ sys.path.insert(0, os.path.dirname(os.path.abspath(__file__)))
23
+ from pipeline import ZenImageEditPipeline # noqa: E402
24
+
25
+ HERE = os.path.dirname(os.path.abspath(__file__))
26
+
27
+
28
+ def main():
29
+ ap = argparse.ArgumentParser(description="Qwen-Image-2.1 with Qwen3.5-0.8B and the adapter inside the DiT")
30
+ ap.add_argument("--prompt", required=True)
31
+ ap.add_argument("--image", nargs="*", default=[],
32
+ help="condition images, order = <image1>, <image2>, ...")
33
+ ap.add_argument("--out", default="out.png")
34
+ ap.add_argument("--model", default=HERE, help="model folder (the layout shipped in this repo)")
35
+ ap.add_argument("--size", type=int, default=1024, help="output_resolution (frame side)")
36
+ ap.add_argument("--steps", type=int, default=30)
37
+ ap.add_argument("--seed", type=int, default=1234)
38
+ ap.add_argument("--device", default="cuda")
39
+ ap.add_argument("--no-offload", action="store_true",
40
+ help="keep every component on the device (needs a large GPU)")
41
+ args = ap.parse_args()
42
+
43
+ pipe = ZenImageEditPipeline.from_pretrained(args.model, dtype=torch.float16)
44
+ pipe.set_progress_bar_config(disable=True)
45
+ # Phase-by-phase offload by default: the 14.5 GB fp16 DiT and the fp32 VAE decoder do not fit
46
+ # an 32 GB card at the same time. Keeping everything resident needs roughly 40 GB.
47
+ if args.device.startswith("cuda") and not args.no_offload:
48
+ pipe.enable_model_cpu_offload(device=args.device)
49
+ else:
50
+ pipe.to(args.device)
51
+
52
+ generator = torch.Generator(args.device).manual_seed(args.seed)
53
+ condition = [PILImage.open(path) for path in args.image] or None
54
+ if condition and len(condition) > 1 and "<image" not in args.prompt:
55
+ print("WARNING: with N>1 the prompt must reference <image1>, <image2>, ...", flush=True)
56
+ image = pipe(prompt=args.prompt,
57
+ image=condition,
58
+ output_resolution=args.size,
59
+ num_inference_steps=args.steps,
60
+ true_cfg_scale=1.0,
61
+ generator=generator,
62
+ output_type="pil").images[0]
63
+ image.save(args.out)
64
+ print(f"{args.size}px, {args.steps} steps, seed {args.seed} -> {args.out} {image.size}", flush=True)
65
+
66
+
67
+ if __name__ == "__main__":
68
+ main()
media/edit_char.jpg ADDED

Git LFS Details

  • SHA256: 3df5faa4989ab0351c5f3614b3d5c2cc9a557a3888abb2d3da62b2073b7537e5
  • Pointer size: 131 Bytes
  • Size of remote file: 136 kB
media/edit_single.jpg ADDED

Git LFS Details

  • SHA256: 5b80383b19098d44902e5ee46a6a81aae290c2963eee57e516865f55abfc90bc
  • Pointer size: 131 Bytes
  • Size of remote file: 232 kB
media/edit_swap.jpg ADDED

Git LFS Details

  • SHA256: 69f98269f59a92042bd0d29776669bf214a4c1bc7435fa3f7e5cfc4135518d76
  • Pointer size: 131 Bytes
  • Size of remote file: 242 kB
media/edit_three.jpg ADDED

Git LFS Details

  • SHA256: 620b943ef69f2003bbaf34d89ba14d789edd66a8ef12684461f95814eb7a9c25
  • Pointer size: 131 Bytes
  • Size of remote file: 234 kB
media/hero.jpg ADDED

Git LFS Details

  • SHA256: e02db9df228f109192997066053c3fee5184fe7f4492152dcc30a88d27daaed2
  • Pointer size: 131 Bytes
  • Size of remote file: 282 kB
media/limit_numbers.jpg ADDED

Git LFS Details

  • SHA256: 130073a15d88dda8b064cbe2fcc55c851e3b9398853228a8833024a8d7068e69
  • Pointer size: 131 Bytes
  • Size of remote file: 406 kB
media/t2i.jpg ADDED

Git LFS Details

  • SHA256: 84bca850d238fb742290e693cf912ac62b8f4950073decd99c1624012013a64a
  • Pointer size: 131 Bytes
  • Size of remote file: 154 kB
media/transparent.png ADDED

Git LFS Details

  • SHA256: c7affd1e6125b1b621982e9b1656cf5774399fb678cd9ad61c5c934f40bdc62c
  • Pointer size: 131 Bytes
  • Size of remote file: 855 kB
model_index.json ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "_class_name": "ZenImageEditPipeline",
3
+ "_diffusers_version": "0.41.0.dev0",
4
+ "processor": [
5
+ "transformers",
6
+ "Qwen3VLProcessor"
7
+ ],
8
+ "scheduler": [
9
+ "diffusers",
10
+ "FlowMatchEulerDiscreteScheduler"
11
+ ],
12
+ "text_encoder": [
13
+ "transformers",
14
+ "Qwen3_5ForConditionalGeneration"
15
+ ],
16
+ "tokenizer": [
17
+ "transformers",
18
+ "Qwen2Tokenizer"
19
+ ],
20
+ "transformer": [
21
+ "diffusers",
22
+ "QwenImage21FusionTransformer2DModel"
23
+ ],
24
+ "vae": [
25
+ "diffusers",
26
+ "AutoencoderKLQwenImage21"
27
+ ]
28
+ }
pipeline.py ADDED
@@ -0,0 +1,190 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Inference pipeline for zen-image-edit: Qwen3.5-0.8B text encoder, adapter inside the DiT.
2
+
3
+ Compared to `QwenImage21Pipeline` exactly one method differs: `_get_qwen_prompt_embeds` returns the
4
+ Qwen3.5-0.8B hidden-state stack `(B, L, K*d)` plus masks instead of `(B, L, 4096)` from Qwen3-VL-8B.
5
+ The transformer's own `text_fusion` turns that into the condition, and it also crops the system
6
+ prompt — the adapter was trained on the full sequence (`drop_first=0`), so cropping before the
7
+ fusion would shift every position.
8
+
9
+ Latents, VAE, scheduler, edit geometry (`<imageN>` blocks, one vision slot per 2x2 latent group) and
10
+ the prefix KV cache are inherited unchanged.
11
+ """
12
+ import os
13
+
14
+ import torch
15
+ from PIL import Image as PILImage
16
+ from diffusers.image_processor import VaeImageProcessor
17
+ from diffusers.pipelines.qwenimage21.pipeline_qwenimage21 import QwenImage21Pipeline
18
+
19
+ from transformer import QwenImage21FusionTransformer2DModel
20
+
21
+
22
+ class ZenImageEditPipeline(QwenImage21Pipeline):
23
+ """Qwen-Image-2.1 with Qwen3.5-0.8B instead of Qwen3-VL-8B; one class for both modes.
24
+
25
+ Like `QwenImage21Pipeline` itself, the mode is picked by the arguments: `image=None` is
26
+ text-to-image, `image=[...]` is editing.
27
+
28
+ Components: `transformer` — `QwenImage21FusionTransformer2DModel` (stock DiT + `text_fusion`),
29
+ `text_encoder` — `Qwen3_5ForConditionalGeneration`, `processor` — the student processor
30
+ (images and tokenization), `tokenizer` — the student tokenizer, `vae`/`scheduler` — the
31
+ Qwen-Image-2.1 ones.
32
+ """
33
+
34
+ def __init__(
35
+ self,
36
+ scheduler,
37
+ vae,
38
+ text_encoder,
39
+ processor,
40
+ transformer,
41
+ tokenizer=None,
42
+ ):
43
+ # `QwenImage21Pipeline.__init__` is not reused: it derives `_drop_idx` from
44
+ # `processor.apply_chat_template(system)`, and the Qwen3.5 processor raises
45
+ # "No user query found" on a system-only message. The rest is its own code.
46
+ super(QwenImage21Pipeline, self).__init__()
47
+ self.register_modules(
48
+ vae=vae,
49
+ text_encoder=text_encoder,
50
+ processor=processor,
51
+ tokenizer=tokenizer,
52
+ transformer=transformer,
53
+ scheduler=scheduler,
54
+ )
55
+ self.vae_scale_factor = 16
56
+ self.latent_channels = self.vae.config.z_dim if getattr(self, "vae", None) else 64
57
+ self.image_processor = VaeImageProcessor(
58
+ vae_scale_factor=self.vae_scale_factor, vae_latent_channels=self.latent_channels
59
+ )
60
+ self.sys_prompt = "Comprehend and analyze the provided prompt."
61
+ # The prompt is a raw template string, not `apply_chat_template`: the checkpoint was
62
+ # trained on this one.
63
+ self.prompt_template_t2i = (
64
+ f"<|im_start|>system\n{self.sys_prompt}<|im_end|>\n"
65
+ f"<|im_start|>user\n{{}}<|im_end|>\n"
66
+ f"<|im_start|>assistant\n"
67
+ )
68
+ self.prompt_template_ti2i = (
69
+ f"<|im_start|>system\n{self.sys_prompt}<|im_end|>\n"
70
+ f"<|im_start|>user\n<image1><|vision_start|><|image_pad|><|vision_end|>{{}}<|im_end|>\n"
71
+ f"<|im_start|>assistant\n"
72
+ )
73
+ fusion = dict(getattr(transformer.config, "text_fusion_config", {}) or {})
74
+ self.student_layers = [int(i) for i in fusion.get("student_layers", ())]
75
+ if not self.student_layers:
76
+ raise ValueError("transformer config has no text_fusion_config.student_layers")
77
+ self._drop_idx = int(fusion.get("drop_idx", 0))
78
+ tokenizer = tokenizer if tokenizer is not None else getattr(processor, "tokenizer", None)
79
+ self._img_token_id = int(tokenizer.encode("<|image_pad|>", add_special_tokens=False)[0])
80
+ # The prefix crop happens inside the transformer; if the tokenizer and the config ever
81
+ # disagree the condition silently slides by a few positions. Check once, at build time.
82
+ prefix = f"<|im_start|>system\n{self.sys_prompt}<|im_end|>\n"
83
+ got = len(tokenizer(prefix, add_special_tokens=False)["input_ids"])
84
+ if got != self._drop_idx:
85
+ raise ValueError(
86
+ f"text_fusion_config.drop_idx={self._drop_idx}, but the tokenizer's system prefix "
87
+ f"is {got} tokens"
88
+ )
89
+
90
+ def _get_qwen_prompt_embeds(self, prompt=None, image=None, device=None):
91
+ """Student slices -> flat `(B, L, K*d)`; masks are full-length, the prefix is not cropped here."""
92
+ device = device or self._execution_device
93
+ prompt = [prompt] if isinstance(prompt, str) else prompt
94
+ # Qwen has no BOS token, so an empty string would leave the encoder with nothing to read.
95
+ prompt = [" " if not p else p for p in prompt]
96
+ is_t2i = image is None
97
+
98
+ if is_t2i:
99
+ prompts = [self.prompt_template_t2i.format(t) for t in prompt]
100
+ condition_pil_list = []
101
+ else:
102
+ replace = "<image1><|vision_start|><|image_pad|><|vision_end|>"
103
+ for i in range(2, len(image) + 1):
104
+ replace += f" <image{i}><|vision_start|><|image_pad|><|vision_end|>"
105
+ template = self.prompt_template_ti2i.replace(
106
+ "<image1><|vision_start|><|image_pad|><|vision_end|>", replace
107
+ )
108
+ prompts = [template.format(t) for t in prompt]
109
+ condition_pil_list = []
110
+ for _ in prompt:
111
+ for img in image:
112
+ if not isinstance(img, PILImage.Image):
113
+ img = PILImage.fromarray(img)
114
+ if img.mode == "RGBA":
115
+ # The checkpoint saw alpha composited over white. Encoder only: the VAE
116
+ # still reads all four channels.
117
+ white = PILImage.new("RGB", img.size, (255, 255, 255))
118
+ white.paste(img, mask=img.getchannel("A"))
119
+ img = white
120
+ condition_pil_list.append(img)
121
+
122
+ # Right padding, as in adapter training: positions of the real tokens do not shift, and the
123
+ # fusion attention branch indexes its position table by absolute index.
124
+ processor_kwargs = {
125
+ "text": prompts,
126
+ "padding": True,
127
+ "padding_side": "right",
128
+ "return_tensors": "pt",
129
+ }
130
+ if not is_t2i:
131
+ processor_kwargs["images"] = condition_pil_list
132
+ model_inputs = self.processor(**processor_kwargs).to(device)
133
+
134
+ forward_kwargs = {
135
+ "input_ids": model_inputs.input_ids,
136
+ "attention_mask": model_inputs.attention_mask,
137
+ "output_hidden_states": True,
138
+ }
139
+ if not is_t2i and hasattr(model_inputs, "pixel_values"):
140
+ forward_kwargs["pixel_values"] = model_inputs.pixel_values.to(self.text_encoder.dtype)
141
+ forward_kwargs["image_grid_thw"] = model_inputs.image_grid_thw
142
+ if hasattr(model_inputs, "mm_token_type_ids"):
143
+ forward_kwargs["mm_token_type_ids"] = model_inputs.mm_token_type_ids
144
+
145
+ outputs = self.text_encoder(**forward_kwargs)
146
+ hidden = outputs.hidden_states
147
+ # (B, K, L, d) -> (B, L, K*d): exactly the flat input the adapter was trained on.
148
+ x = torch.stack([hidden[i] for i in self.student_layers], dim=1)
149
+ x = x.permute(0, 2, 1, 3).reshape(x.shape[0], x.shape[2], -1)
150
+
151
+ return x, model_inputs.attention_mask.bool(), (model_inputs.input_ids == self._img_token_id)
152
+
153
+ def _encode_vae_image(self, image: torch.Tensor, generator: torch.Generator):
154
+ """The VAE is fp32 while condition latents must be in the model dtype (fp16).
155
+
156
+ Without the round trip, `torch.cat([input_images_latents, latents])` in `__call__` promotes
157
+ the input to fp32 and the DiT fails on a dtype mismatch. The encoder itself runs in fp32
158
+ (more accurate), the result is handed back in fp16.
159
+ """
160
+ latents = super()._encode_vae_image(image.to(self.vae.dtype), generator)
161
+ return latents.to(next(self.transformer.parameters()).dtype)
162
+
163
+ @classmethod
164
+ def from_pretrained(cls, root=".", dtype=torch.float16, **kwargs):
165
+ """Load the pipeline from a model folder (the layout shipped in this repo)."""
166
+ from diffusers import AutoencoderKLQwenImage21, FlowMatchEulerDiscreteScheduler
167
+ from transformers import AutoProcessor, AutoTokenizer, Qwen3_5ForConditionalGeneration
168
+
169
+ if not os.path.isdir(root):
170
+ raise ValueError(f"expected a model folder with the components, got {root!r}")
171
+ transformer = QwenImage21FusionTransformer2DModel.from_pretrained(
172
+ os.path.join(root, "transformer"), torch_dtype=dtype
173
+ )
174
+ text_encoder = Qwen3_5ForConditionalGeneration.from_pretrained(
175
+ os.path.join(root, "text_encoder"), dtype=dtype
176
+ )
177
+ # The VAE stays fp32 (1.3 GB): it is the component that misbehaves in fp16.
178
+ vae = AutoencoderKLQwenImage21.from_pretrained(os.path.join(root, "vae"), torch_dtype=torch.float32)
179
+ processor = AutoProcessor.from_pretrained(os.path.join(root, "processor"))
180
+ tokenizer = AutoTokenizer.from_pretrained(os.path.join(root, "tokenizer"))
181
+ scheduler = FlowMatchEulerDiscreteScheduler.from_pretrained(os.path.join(root, "scheduler"))
182
+ return cls(
183
+ scheduler=scheduler,
184
+ vae=vae,
185
+ text_encoder=text_encoder,
186
+ processor=processor,
187
+ transformer=transformer,
188
+ tokenizer=tokenizer,
189
+ **kwargs,
190
+ )
processor/chat_template.jinja ADDED
@@ -0,0 +1,154 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {%- set image_count = namespace(value=0) %}
2
+ {%- set video_count = namespace(value=0) %}
3
+ {%- macro render_content(content, do_vision_count, is_system_content=false) %}
4
+ {%- if content is string %}
5
+ {{- content }}
6
+ {%- elif content is iterable and content is not mapping %}
7
+ {%- for item in content %}
8
+ {%- if 'image' in item or 'image_url' in item or item.type == 'image' %}
9
+ {%- if is_system_content %}
10
+ {{- raise_exception('System message cannot contain images.') }}
11
+ {%- endif %}
12
+ {%- if do_vision_count %}
13
+ {%- set image_count.value = image_count.value + 1 %}
14
+ {%- endif %}
15
+ {%- if add_vision_id %}
16
+ {{- 'Picture ' ~ image_count.value ~ ': ' }}
17
+ {%- endif %}
18
+ {{- '<|vision_start|><|image_pad|><|vision_end|>' }}
19
+ {%- elif 'video' in item or item.type == 'video' %}
20
+ {%- if is_system_content %}
21
+ {{- raise_exception('System message cannot contain videos.') }}
22
+ {%- endif %}
23
+ {%- if do_vision_count %}
24
+ {%- set video_count.value = video_count.value + 1 %}
25
+ {%- endif %}
26
+ {%- if add_vision_id %}
27
+ {{- 'Video ' ~ video_count.value ~ ': ' }}
28
+ {%- endif %}
29
+ {{- '<|vision_start|><|video_pad|><|vision_end|>' }}
30
+ {%- elif 'text' in item %}
31
+ {{- item.text }}
32
+ {%- else %}
33
+ {{- raise_exception('Unexpected item type in content.') }}
34
+ {%- endif %}
35
+ {%- endfor %}
36
+ {%- elif content is none or content is undefined %}
37
+ {{- '' }}
38
+ {%- else %}
39
+ {{- raise_exception('Unexpected content type.') }}
40
+ {%- endif %}
41
+ {%- endmacro %}
42
+ {%- if not messages %}
43
+ {{- raise_exception('No messages provided.') }}
44
+ {%- endif %}
45
+ {%- if tools and tools is iterable and tools is not mapping %}
46
+ {{- '<|im_start|>system\n' }}
47
+ {{- "# Tools\n\nYou have access to the following functions:\n\n<tools>" }}
48
+ {%- for tool in tools %}
49
+ {{- "\n" }}
50
+ {{- tool | tojson }}
51
+ {%- endfor %}
52
+ {{- "\n</tools>" }}
53
+ {{- '\n\nIf you choose to call a function ONLY reply in the following format with NO suffix:\n\n<tool_call>\n<function=example_function_name>\n<parameter=example_parameter_1>\nvalue_1\n</parameter>\n<parameter=example_parameter_2>\nThis is the value for the second parameter\nthat can span\nmultiple lines\n</parameter>\n</function>\n</tool_call>\n\n<IMPORTANT>\nReminder:\n- Function calls MUST follow the specified format: an inner <function=...></function> block must be nested within <tool_call></tool_call> XML tags\n- Required parameters MUST be specified\n- You may provide optional reasoning for your function call in natural language BEFORE the function call, but NOT after\n- If there is no function call available, answer the question like normal with your current knowledge and do not tell the user about function calls\n</IMPORTANT>' }}
54
+ {%- if messages[0].role == 'system' %}
55
+ {%- set content = render_content(messages[0].content, false, true)|trim %}
56
+ {%- if content %}
57
+ {{- '\n\n' + content }}
58
+ {%- endif %}
59
+ {%- endif %}
60
+ {{- '<|im_end|>\n' }}
61
+ {%- else %}
62
+ {%- if messages[0].role == 'system' %}
63
+ {%- set content = render_content(messages[0].content, false, true)|trim %}
64
+ {{- '<|im_start|>system\n' + content + '<|im_end|>\n' }}
65
+ {%- endif %}
66
+ {%- endif %}
67
+ {%- set ns = namespace(multi_step_tool=true, last_query_index=messages|length - 1) %}
68
+ {%- for message in messages[::-1] %}
69
+ {%- set index = (messages|length - 1) - loop.index0 %}
70
+ {%- if ns.multi_step_tool and message.role == "user" %}
71
+ {%- set content = render_content(message.content, false)|trim %}
72
+ {%- if not(content.startswith('<tool_response>') and content.endswith('</tool_response>')) %}
73
+ {%- set ns.multi_step_tool = false %}
74
+ {%- set ns.last_query_index = index %}
75
+ {%- endif %}
76
+ {%- endif %}
77
+ {%- endfor %}
78
+ {%- if ns.multi_step_tool %}
79
+ {{- raise_exception('No user query found in messages.') }}
80
+ {%- endif %}
81
+ {%- for message in messages %}
82
+ {%- set content = render_content(message.content, true)|trim %}
83
+ {%- if message.role == "system" %}
84
+ {%- if not loop.first %}
85
+ {{- raise_exception('System message must be at the beginning.') }}
86
+ {%- endif %}
87
+ {%- elif message.role == "user" %}
88
+ {{- '<|im_start|>' + message.role + '\n' + content + '<|im_end|>' + '\n' }}
89
+ {%- elif message.role == "assistant" %}
90
+ {%- set reasoning_content = '' %}
91
+ {%- if message.reasoning_content is string %}
92
+ {%- set reasoning_content = message.reasoning_content %}
93
+ {%- else %}
94
+ {%- if '</think>' in content %}
95
+ {%- set reasoning_content = content.split('</think>')[0].rstrip('\n').split('<think>')[-1].lstrip('\n') %}
96
+ {%- set content = content.split('</think>')[-1].lstrip('\n') %}
97
+ {%- endif %}
98
+ {%- endif %}
99
+ {%- set reasoning_content = reasoning_content|trim %}
100
+ {%- if loop.index0 > ns.last_query_index %}
101
+ {{- '<|im_start|>' + message.role + '\n<think>\n' + reasoning_content + '\n</think>\n\n' + content }}
102
+ {%- else %}
103
+ {{- '<|im_start|>' + message.role + '\n' + content }}
104
+ {%- endif %}
105
+ {%- if message.tool_calls and message.tool_calls is iterable and message.tool_calls is not mapping %}
106
+ {%- for tool_call in message.tool_calls %}
107
+ {%- if tool_call.function is defined %}
108
+ {%- set tool_call = tool_call.function %}
109
+ {%- endif %}
110
+ {%- if loop.first %}
111
+ {%- if content|trim %}
112
+ {{- '\n\n<tool_call>\n<function=' + tool_call.name + '>\n' }}
113
+ {%- else %}
114
+ {{- '<tool_call>\n<function=' + tool_call.name + '>\n' }}
115
+ {%- endif %}
116
+ {%- else %}
117
+ {{- '\n<tool_call>\n<function=' + tool_call.name + '>\n' }}
118
+ {%- endif %}
119
+ {%- if tool_call.arguments is defined %}
120
+ {%- for args_name, args_value in tool_call.arguments|items %}
121
+ {{- '<parameter=' + args_name + '>\n' }}
122
+ {%- set args_value = args_value | tojson | safe if args_value is mapping or (args_value is sequence and args_value is not string) else args_value | string %}
123
+ {{- args_value }}
124
+ {{- '\n</parameter>\n' }}
125
+ {%- endfor %}
126
+ {%- endif %}
127
+ {{- '</function>\n</tool_call>' }}
128
+ {%- endfor %}
129
+ {%- endif %}
130
+ {{- '<|im_end|>\n' }}
131
+ {%- elif message.role == "tool" %}
132
+ {%- if loop.previtem and loop.previtem.role != "tool" %}
133
+ {{- '<|im_start|>user' }}
134
+ {%- endif %}
135
+ {{- '\n<tool_response>\n' }}
136
+ {{- content }}
137
+ {{- '\n</tool_response>' }}
138
+ {%- if not loop.last and loop.nextitem.role != "tool" %}
139
+ {{- '<|im_end|>\n' }}
140
+ {%- elif loop.last %}
141
+ {{- '<|im_end|>\n' }}
142
+ {%- endif %}
143
+ {%- else %}
144
+ {{- raise_exception('Unexpected message role.') }}
145
+ {%- endif %}
146
+ {%- endfor %}
147
+ {%- if add_generation_prompt %}
148
+ {{- '<|im_start|>assistant\n' }}
149
+ {%- if enable_thinking is defined and enable_thinking is true %}
150
+ {{- '<think>\n' }}
151
+ {%- else %}
152
+ {{- '<think>\n\n</think>\n\n' }}
153
+ {%- endif %}
154
+ {%- endif %}
processor/merges.txt ADDED
The diff for this file is too large to render. See raw diff
 
processor/preprocessor_config.json ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "size": {
3
+ "longest_edge": 16777216,
4
+ "shortest_edge": 65536
5
+ },
6
+ "patch_size": 16,
7
+ "temporal_patch_size": 2,
8
+ "merge_size": 2,
9
+ "image_mean": [
10
+ 0.5,
11
+ 0.5,
12
+ 0.5
13
+ ],
14
+ "image_std": [
15
+ 0.5,
16
+ 0.5,
17
+ 0.5
18
+ ],
19
+ "processor_class": "Qwen3VLProcessor",
20
+ "image_processor_type": "Qwen2VLImageProcessorFast"
21
+ }
processor/tokenizer.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:5f9e4d4901a92b997e463c1f46055088b6cca5ca61a6522d1b9f64c4bb81cb42
3
+ size 12807982
processor/tokenizer_config.json ADDED
@@ -0,0 +1,305 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "add_prefix_space": false,
3
+ "added_tokens_decoder": {
4
+ "248044": {
5
+ "content": "<|endoftext|>",
6
+ "lstrip": false,
7
+ "normalized": false,
8
+ "rstrip": false,
9
+ "single_word": false,
10
+ "special": true
11
+ },
12
+ "248045": {
13
+ "content": "<|im_start|>",
14
+ "lstrip": false,
15
+ "normalized": false,
16
+ "rstrip": false,
17
+ "single_word": false,
18
+ "special": true
19
+ },
20
+ "248046": {
21
+ "content": "<|im_end|>",
22
+ "lstrip": false,
23
+ "normalized": false,
24
+ "rstrip": false,
25
+ "single_word": false,
26
+ "special": true
27
+ },
28
+ "248047": {
29
+ "content": "<|object_ref_start|>",
30
+ "lstrip": false,
31
+ "normalized": false,
32
+ "rstrip": false,
33
+ "single_word": false,
34
+ "special": true
35
+ },
36
+ "248048": {
37
+ "content": "<|object_ref_end|>",
38
+ "lstrip": false,
39
+ "normalized": false,
40
+ "rstrip": false,
41
+ "single_word": false,
42
+ "special": true
43
+ },
44
+ "248049": {
45
+ "content": "<|box_start|>",
46
+ "lstrip": false,
47
+ "normalized": false,
48
+ "rstrip": false,
49
+ "single_word": false,
50
+ "special": true
51
+ },
52
+ "248050": {
53
+ "content": "<|box_end|>",
54
+ "lstrip": false,
55
+ "normalized": false,
56
+ "rstrip": false,
57
+ "single_word": false,
58
+ "special": true
59
+ },
60
+ "248051": {
61
+ "content": "<|quad_start|>",
62
+ "lstrip": false,
63
+ "normalized": false,
64
+ "rstrip": false,
65
+ "single_word": false,
66
+ "special": true
67
+ },
68
+ "248052": {
69
+ "content": "<|quad_end|>",
70
+ "lstrip": false,
71
+ "normalized": false,
72
+ "rstrip": false,
73
+ "single_word": false,
74
+ "special": true
75
+ },
76
+ "248053": {
77
+ "content": "<|vision_start|>",
78
+ "lstrip": false,
79
+ "normalized": false,
80
+ "rstrip": false,
81
+ "single_word": false,
82
+ "special": true
83
+ },
84
+ "248054": {
85
+ "content": "<|vision_end|>",
86
+ "lstrip": false,
87
+ "normalized": false,
88
+ "rstrip": false,
89
+ "single_word": false,
90
+ "special": true
91
+ },
92
+ "248055": {
93
+ "content": "<|vision_pad|>",
94
+ "lstrip": false,
95
+ "normalized": false,
96
+ "rstrip": false,
97
+ "single_word": false,
98
+ "special": true
99
+ },
100
+ "248056": {
101
+ "content": "<|image_pad|>",
102
+ "lstrip": false,
103
+ "normalized": false,
104
+ "rstrip": false,
105
+ "single_word": false,
106
+ "special": true
107
+ },
108
+ "248057": {
109
+ "content": "<|video_pad|>",
110
+ "lstrip": false,
111
+ "normalized": false,
112
+ "rstrip": false,
113
+ "single_word": false,
114
+ "special": true
115
+ },
116
+ "248058": {
117
+ "content": "<tool_call>",
118
+ "lstrip": false,
119
+ "normalized": false,
120
+ "rstrip": false,
121
+ "single_word": false,
122
+ "special": false
123
+ },
124
+ "248059": {
125
+ "content": "</tool_call>",
126
+ "lstrip": false,
127
+ "normalized": false,
128
+ "rstrip": false,
129
+ "single_word": false,
130
+ "special": false
131
+ },
132
+ "248060": {
133
+ "content": "<|fim_prefix|>",
134
+ "lstrip": false,
135
+ "normalized": false,
136
+ "rstrip": false,
137
+ "single_word": false,
138
+ "special": false
139
+ },
140
+ "248061": {
141
+ "content": "<|fim_middle|>",
142
+ "lstrip": false,
143
+ "normalized": false,
144
+ "rstrip": false,
145
+ "single_word": false,
146
+ "special": false
147
+ },
148
+ "248062": {
149
+ "content": "<|fim_suffix|>",
150
+ "lstrip": false,
151
+ "normalized": false,
152
+ "rstrip": false,
153
+ "single_word": false,
154
+ "special": false
155
+ },
156
+ "248063": {
157
+ "content": "<|fim_pad|>",
158
+ "lstrip": false,
159
+ "normalized": false,
160
+ "rstrip": false,
161
+ "single_word": false,
162
+ "special": false
163
+ },
164
+ "248064": {
165
+ "content": "<|repo_name|>",
166
+ "lstrip": false,
167
+ "normalized": false,
168
+ "rstrip": false,
169
+ "single_word": false,
170
+ "special": false
171
+ },
172
+ "248065": {
173
+ "content": "<|file_sep|>",
174
+ "lstrip": false,
175
+ "normalized": false,
176
+ "rstrip": false,
177
+ "single_word": false,
178
+ "special": false
179
+ },
180
+ "248066": {
181
+ "content": "<tool_response>",
182
+ "lstrip": false,
183
+ "normalized": false,
184
+ "rstrip": false,
185
+ "single_word": false,
186
+ "special": false
187
+ },
188
+ "248067": {
189
+ "content": "</tool_response>",
190
+ "lstrip": false,
191
+ "normalized": false,
192
+ "rstrip": false,
193
+ "single_word": false,
194
+ "special": false
195
+ },
196
+ "248068": {
197
+ "content": "<think>",
198
+ "lstrip": false,
199
+ "normalized": false,
200
+ "rstrip": false,
201
+ "single_word": false,
202
+ "special": false
203
+ },
204
+ "248069": {
205
+ "content": "</think>",
206
+ "lstrip": false,
207
+ "normalized": false,
208
+ "rstrip": false,
209
+ "single_word": false,
210
+ "special": false
211
+ },
212
+ "248070": {
213
+ "content": "<|audio_start|>",
214
+ "lstrip": false,
215
+ "normalized": false,
216
+ "rstrip": false,
217
+ "single_word": false,
218
+ "special": true
219
+ },
220
+ "248071": {
221
+ "content": "<|audio_end|>",
222
+ "lstrip": false,
223
+ "normalized": false,
224
+ "rstrip": false,
225
+ "single_word": false,
226
+ "special": true
227
+ },
228
+ "248072": {
229
+ "content": "<tts_pad>",
230
+ "lstrip": false,
231
+ "normalized": false,
232
+ "rstrip": false,
233
+ "single_word": false,
234
+ "special": true
235
+ },
236
+ "248073": {
237
+ "content": "<tts_text_bos>",
238
+ "lstrip": false,
239
+ "normalized": false,
240
+ "rstrip": false,
241
+ "single_word": false,
242
+ "special": true
243
+ },
244
+ "248074": {
245
+ "content": "<tts_text_eod>",
246
+ "lstrip": false,
247
+ "normalized": false,
248
+ "rstrip": false,
249
+ "single_word": false,
250
+ "special": true
251
+ },
252
+ "248075": {
253
+ "content": "<tts_text_bos_single>",
254
+ "lstrip": false,
255
+ "normalized": false,
256
+ "rstrip": false,
257
+ "single_word": false,
258
+ "special": true
259
+ },
260
+ "248076": {
261
+ "content": "<|audio_pad|>",
262
+ "lstrip": false,
263
+ "normalized": false,
264
+ "rstrip": false,
265
+ "single_word": false,
266
+ "special": true
267
+ }
268
+ },
269
+ "additional_special_tokens": [
270
+ "<|im_start|>",
271
+ "<|im_end|>",
272
+ "<|object_ref_start|>",
273
+ "<|object_ref_end|>",
274
+ "<|box_start|>",
275
+ "<|box_end|>",
276
+ "<|quad_start|>",
277
+ "<|quad_end|>",
278
+ "<|vision_start|>",
279
+ "<|vision_end|>",
280
+ "<|vision_pad|>",
281
+ "<|image_pad|>",
282
+ "<|video_pad|>"
283
+ ],
284
+ "bos_token": null,
285
+ "chat_template": "{%- set image_count = namespace(value=0) %}\n{%- set video_count = namespace(value=0) %}\n{%- macro render_content(content, do_vision_count, is_system_content=false) %}\n {%- if content is string %}\n {{- content }}\n {%- elif content is iterable and content is not mapping %}\n {%- for item in content %}\n {%- if 'image' in item or 'image_url' in item or item.type == 'image' %}\n {%- if is_system_content %}\n {{- raise_exception('System message cannot contain images.') }}\n {%- endif %}\n {%- if do_vision_count %}\n {%- set image_count.value = image_count.value + 1 %}\n {%- endif %}\n {%- if add_vision_id %}\n {{- 'Picture ' ~ image_count.value ~ ': ' }}\n {%- endif %}\n {{- '<|vision_start|><|image_pad|><|vision_end|>' }}\n {%- elif 'video' in item or item.type == 'video' %}\n {%- if is_system_content %}\n {{- raise_exception('System message cannot contain videos.') }}\n {%- endif %}\n {%- if do_vision_count %}\n {%- set video_count.value = video_count.value + 1 %}\n {%- endif %}\n {%- if add_vision_id %}\n {{- 'Video ' ~ video_count.value ~ ': ' }}\n {%- endif %}\n {{- '<|vision_start|><|video_pad|><|vision_end|>' }}\n {%- elif 'text' in item %}\n {{- item.text }}\n {%- else %}\n {{- raise_exception('Unexpected item type in content.') }}\n {%- endif %}\n {%- endfor %}\n {%- elif content is none or content is undefined %}\n {{- '' }}\n {%- else %}\n {{- raise_exception('Unexpected content type.') }}\n {%- endif %}\n{%- endmacro %}\n{%- if not messages %}\n {{- raise_exception('No messages provided.') }}\n{%- endif %}\n{%- if tools and tools is iterable and tools is not mapping %}\n {{- '<|im_start|>system\\n' }}\n {{- \"# Tools\\n\\nYou have access to the following functions:\\n\\n<tools>\" }}\n {%- for tool in tools %}\n {{- \"\\n\" }}\n {{- tool | tojson }}\n {%- endfor %}\n {{- \"\\n</tools>\" }}\n {{- '\\n\\nIf you choose to call a function ONLY reply in the following format with NO suffix:\\n\\n<tool_call>\\n<function=example_function_name>\\n<parameter=example_parameter_1>\\nvalue_1\\n</parameter>\\n<parameter=example_parameter_2>\\nThis is the value for the second parameter\\nthat can span\\nmultiple lines\\n</parameter>\\n</function>\\n</tool_call>\\n\\n<IMPORTANT>\\nReminder:\\n- Function calls MUST follow the specified format: an inner <function=...></function> block must be nested within <tool_call></tool_call> XML tags\\n- Required parameters MUST be specified\\n- You may provide optional reasoning for your function call in natural language BEFORE the function call, but NOT after\\n- If there is no function call available, answer the question like normal with your current knowledge and do not tell the user about function calls\\n</IMPORTANT>' }}\n {%- if messages[0].role == 'system' %}\n {%- set content = render_content(messages[0].content, false, true)|trim %}\n {%- if content %}\n {{- '\\n\\n' + content }}\n {%- endif %}\n {%- endif %}\n {{- '<|im_end|>\\n' }}\n{%- else %}\n {%- if messages[0].role == 'system' %}\n {%- set content = render_content(messages[0].content, false, true)|trim %}\n {{- '<|im_start|>system\\n' + content + '<|im_end|>\\n' }}\n {%- endif %}\n{%- endif %}\n{%- set ns = namespace(multi_step_tool=true, last_query_index=messages|length - 1) %}\n{%- for message in messages[::-1] %}\n {%- set index = (messages|length - 1) - loop.index0 %}\n {%- if ns.multi_step_tool and message.role == \"user\" %}\n {%- set content = render_content(message.content, false)|trim %}\n {%- if not(content.startswith('<tool_response>') and content.endswith('</tool_response>')) %}\n {%- set ns.multi_step_tool = false %}\n {%- set ns.last_query_index = index %}\n {%- endif %}\n {%- endif %}\n{%- endfor %}\n{%- if ns.multi_step_tool %}\n {{- raise_exception('No user query found in messages.') }}\n{%- endif %}\n{%- for message in messages %}\n {%- set content = render_content(message.content, true)|trim %}\n {%- if message.role == \"system\" %}\n {%- if not loop.first %}\n {{- raise_exception('System message must be at the beginning.') }}\n {%- endif %}\n {%- elif message.role == \"user\" %}\n {{- '<|im_start|>' + message.role + '\\n' + content + '<|im_end|>' + '\\n' }}\n {%- elif message.role == \"assistant\" %}\n {%- set reasoning_content = '' %}\n {%- if message.reasoning_content is string %}\n {%- set reasoning_content = message.reasoning_content %}\n {%- else %}\n {%- if '</think>' in content %}\n {%- set reasoning_content = content.split('</think>')[0].rstrip('\\n').split('<think>')[-1].lstrip('\\n') %}\n {%- set content = content.split('</think>')[-1].lstrip('\\n') %}\n {%- endif %}\n {%- endif %}\n {%- set reasoning_content = reasoning_content|trim %}\n {%- if loop.index0 > ns.last_query_index %}\n {{- '<|im_start|>' + message.role + '\\n<think>\\n' + reasoning_content + '\\n</think>\\n\\n' + content }}\n {%- else %}\n {{- '<|im_start|>' + message.role + '\\n' + content }}\n {%- endif %}\n {%- if message.tool_calls and message.tool_calls is iterable and message.tool_calls is not mapping %}\n {%- for tool_call in message.tool_calls %}\n {%- if tool_call.function is defined %}\n {%- set tool_call = tool_call.function %}\n {%- endif %}\n {%- if loop.first %}\n {%- if content|trim %}\n {{- '\\n\\n<tool_call>\\n<function=' + tool_call.name + '>\\n' }}\n {%- else %}\n {{- '<tool_call>\\n<function=' + tool_call.name + '>\\n' }}\n {%- endif %}\n {%- else %}\n {{- '\\n<tool_call>\\n<function=' + tool_call.name + '>\\n' }}\n {%- endif %}\n {%- if tool_call.arguments is defined %}\n {%- for args_name, args_value in tool_call.arguments|items %}\n {{- '<parameter=' + args_name + '>\\n' }}\n {%- set args_value = args_value | tojson | safe if args_value is mapping or (args_value is sequence and args_value is not string) else args_value | string %}\n {{- args_value }}\n {{- '\\n</parameter>\\n' }}\n {%- endfor %}\n {%- endif %}\n {{- '</function>\\n</tool_call>' }}\n {%- endfor %}\n {%- endif %}\n {{- '<|im_end|>\\n' }}\n {%- elif message.role == \"tool\" %}\n {%- if loop.previtem and loop.previtem.role != \"tool\" %}\n {{- '<|im_start|>user' }}\n {%- endif %}\n {{- '\\n<tool_response>\\n' }}\n {{- content }}\n {{- '\\n</tool_response>' }}\n {%- if not loop.last and loop.nextitem.role != \"tool\" %}\n {{- '<|im_end|>\\n' }}\n {%- elif loop.last %}\n {{- '<|im_end|>\\n' }}\n {%- endif %}\n {%- else %}\n {{- raise_exception('Unexpected message role.') }}\n {%- endif %}\n{%- endfor %}\n{%- if add_generation_prompt %}\n {{- '<|im_start|>assistant\\n' }}\n {%- if enable_thinking is defined and enable_thinking is true %}\n {{- '<think>\\n' }}\n {%- else %}\n {{- '<think>\\n\\n</think>\\n\\n' }}\n {%- endif %}\n{%- endif %}",
286
+ "clean_up_tokenization_spaces": false,
287
+ "eos_token": "<|im_end|>",
288
+ "errors": "replace",
289
+ "model_max_length": 262144,
290
+ "pad_token": "<|endoftext|>",
291
+ "split_special_tokens": false,
292
+ "tokenizer_class": "Qwen2Tokenizer",
293
+ "unk_token": null,
294
+ "add_bos_token": false,
295
+ "pretokenize_regex": "(?i:'s|'t|'re|'ve|'m|'ll|'d)|[^\\r\\n\\p{L}\\p{N}]?[\\p{L}\\p{M}]+|\\p{N}| ?[^\\s\\p{L}\\p{M}\\p{N}]+[\\r\\n]*|\\s*[\\r\\n]+|\\s+(?!\\S)|\\s+",
296
+ "extra_special_tokens": {
297
+ "audio_bos_token": "<|audio_start|>",
298
+ "audio_eos_token": "<|audio_end|>",
299
+ "audio_token": "<|audio_pad|>",
300
+ "image_token": "<|image_pad|>",
301
+ "video_token": "<|video_pad|>",
302
+ "vision_bos_token": "<|vision_start|>",
303
+ "vision_eos_token": "<|vision_end|>"
304
+ }
305
+ }
processor/video_preprocessor_config.json ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "size": {
3
+ "longest_edge": 25165824,
4
+ "shortest_edge": 4096
5
+ },
6
+ "patch_size": 16,
7
+ "temporal_patch_size": 2,
8
+ "merge_size": 2,
9
+ "image_mean": [
10
+ 0.5,
11
+ 0.5,
12
+ 0.5
13
+ ],
14
+ "image_std": [
15
+ 0.5,
16
+ 0.5,
17
+ 0.5
18
+ ],
19
+ "processor_class": "Qwen3VLProcessor",
20
+ "video_processor_type": "Qwen3VLVideoProcessor"
21
+ }
processor/vocab.json ADDED
The diff for this file is too large to render. See raw diff
 
scheduler/scheduler_config.json ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "_class_name": "FlowMatchEulerDiscreteScheduler",
3
+ "_diffusers_version": "0.37.0.dev0",
4
+ "base_image_seq_len": 256,
5
+ "base_shift": 0.5,
6
+ "invert_sigmas": false,
7
+ "max_image_seq_len": 8192,
8
+ "max_shift": 0.9,
9
+ "num_train_timesteps": 1000,
10
+ "shift": 1.0,
11
+ "shift_terminal": 0.02,
12
+ "stochastic_sampling": false,
13
+ "time_shift_type": "exponential",
14
+ "use_beta_sigmas": false,
15
+ "use_dynamic_shifting": true,
16
+ "use_exponential_sigmas": false,
17
+ "use_karras_sigmas": false
18
+ }
text_encoder/config.json ADDED
@@ -0,0 +1,96 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "architectures": [
3
+ "Qwen3_5ForConditionalGeneration"
4
+ ],
5
+ "image_token_id": 248056,
6
+ "model_type": "qwen3_5",
7
+ "text_config": {
8
+ "attention_bias": false,
9
+ "attention_dropout": 0.0,
10
+ "attn_output_gate": true,
11
+ "dtype": "bfloat16",
12
+ "eos_token_id": 248044,
13
+ "full_attention_interval": 4,
14
+ "head_dim": 256,
15
+ "hidden_act": "silu",
16
+ "hidden_size": 1024,
17
+ "initializer_range": 0.02,
18
+ "intermediate_size": 3584,
19
+ "layer_types": [
20
+ "linear_attention",
21
+ "linear_attention",
22
+ "linear_attention",
23
+ "full_attention",
24
+ "linear_attention",
25
+ "linear_attention",
26
+ "linear_attention",
27
+ "full_attention",
28
+ "linear_attention",
29
+ "linear_attention",
30
+ "linear_attention",
31
+ "full_attention",
32
+ "linear_attention",
33
+ "linear_attention",
34
+ "linear_attention",
35
+ "full_attention",
36
+ "linear_attention",
37
+ "linear_attention",
38
+ "linear_attention",
39
+ "full_attention",
40
+ "linear_attention",
41
+ "linear_attention",
42
+ "linear_attention",
43
+ "full_attention"
44
+ ],
45
+ "linear_conv_kernel_dim": 4,
46
+ "linear_key_head_dim": 128,
47
+ "linear_num_key_heads": 16,
48
+ "linear_num_value_heads": 16,
49
+ "linear_value_head_dim": 128,
50
+ "max_position_embeddings": 262144,
51
+ "mlp_only_layers": [],
52
+ "model_type": "qwen3_5_text",
53
+ "mtp_num_hidden_layers": 1,
54
+ "mtp_use_dedicated_embeddings": false,
55
+ "num_attention_heads": 8,
56
+ "num_hidden_layers": 24,
57
+ "num_key_value_heads": 2,
58
+ "rms_norm_eps": 1e-06,
59
+ "tie_word_embeddings": true,
60
+ "use_cache": true,
61
+ "vocab_size": 248320,
62
+ "mamba_ssm_dtype": "float32",
63
+ "rope_parameters": {
64
+ "mrope_interleaved": true,
65
+ "mrope_section": [
66
+ 11,
67
+ 11,
68
+ 10
69
+ ],
70
+ "rope_type": "default",
71
+ "rope_theta": 10000000,
72
+ "partial_rotary_factor": 0.25
73
+ }
74
+ },
75
+ "tie_word_embeddings": true,
76
+ "transformers_version": "4.57.0.dev0",
77
+ "video_token_id": 248057,
78
+ "vision_config": {
79
+ "deepstack_visual_indexes": [],
80
+ "depth": 12,
81
+ "hidden_act": "gelu_pytorch_tanh",
82
+ "hidden_size": 768,
83
+ "in_channels": 3,
84
+ "initializer_range": 0.02,
85
+ "intermediate_size": 3072,
86
+ "model_type": "qwen3_5",
87
+ "num_heads": 12,
88
+ "num_position_embeddings": 2304,
89
+ "out_hidden_size": 1024,
90
+ "patch_size": 16,
91
+ "spatial_merge_size": 2,
92
+ "temporal_patch_size": 2
93
+ },
94
+ "vision_end_token_id": 248054,
95
+ "vision_start_token_id": 248053
96
+ }
text_encoder/model.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:22978c1272be438dc4a22dbaf3ce1f6843d1ee2dc67490387d1afc8c88384943
3
+ size 1746937368
tokenizer/chat_template.jinja ADDED
@@ -0,0 +1,154 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {%- set image_count = namespace(value=0) %}
2
+ {%- set video_count = namespace(value=0) %}
3
+ {%- macro render_content(content, do_vision_count, is_system_content=false) %}
4
+ {%- if content is string %}
5
+ {{- content }}
6
+ {%- elif content is iterable and content is not mapping %}
7
+ {%- for item in content %}
8
+ {%- if 'image' in item or 'image_url' in item or item.type == 'image' %}
9
+ {%- if is_system_content %}
10
+ {{- raise_exception('System message cannot contain images.') }}
11
+ {%- endif %}
12
+ {%- if do_vision_count %}
13
+ {%- set image_count.value = image_count.value + 1 %}
14
+ {%- endif %}
15
+ {%- if add_vision_id %}
16
+ {{- 'Picture ' ~ image_count.value ~ ': ' }}
17
+ {%- endif %}
18
+ {{- '<|vision_start|><|image_pad|><|vision_end|>' }}
19
+ {%- elif 'video' in item or item.type == 'video' %}
20
+ {%- if is_system_content %}
21
+ {{- raise_exception('System message cannot contain videos.') }}
22
+ {%- endif %}
23
+ {%- if do_vision_count %}
24
+ {%- set video_count.value = video_count.value + 1 %}
25
+ {%- endif %}
26
+ {%- if add_vision_id %}
27
+ {{- 'Video ' ~ video_count.value ~ ': ' }}
28
+ {%- endif %}
29
+ {{- '<|vision_start|><|video_pad|><|vision_end|>' }}
30
+ {%- elif 'text' in item %}
31
+ {{- item.text }}
32
+ {%- else %}
33
+ {{- raise_exception('Unexpected item type in content.') }}
34
+ {%- endif %}
35
+ {%- endfor %}
36
+ {%- elif content is none or content is undefined %}
37
+ {{- '' }}
38
+ {%- else %}
39
+ {{- raise_exception('Unexpected content type.') }}
40
+ {%- endif %}
41
+ {%- endmacro %}
42
+ {%- if not messages %}
43
+ {{- raise_exception('No messages provided.') }}
44
+ {%- endif %}
45
+ {%- if tools and tools is iterable and tools is not mapping %}
46
+ {{- '<|im_start|>system\n' }}
47
+ {{- "# Tools\n\nYou have access to the following functions:\n\n<tools>" }}
48
+ {%- for tool in tools %}
49
+ {{- "\n" }}
50
+ {{- tool | tojson }}
51
+ {%- endfor %}
52
+ {{- "\n</tools>" }}
53
+ {{- '\n\nIf you choose to call a function ONLY reply in the following format with NO suffix:\n\n<tool_call>\n<function=example_function_name>\n<parameter=example_parameter_1>\nvalue_1\n</parameter>\n<parameter=example_parameter_2>\nThis is the value for the second parameter\nthat can span\nmultiple lines\n</parameter>\n</function>\n</tool_call>\n\n<IMPORTANT>\nReminder:\n- Function calls MUST follow the specified format: an inner <function=...></function> block must be nested within <tool_call></tool_call> XML tags\n- Required parameters MUST be specified\n- You may provide optional reasoning for your function call in natural language BEFORE the function call, but NOT after\n- If there is no function call available, answer the question like normal with your current knowledge and do not tell the user about function calls\n</IMPORTANT>' }}
54
+ {%- if messages[0].role == 'system' %}
55
+ {%- set content = render_content(messages[0].content, false, true)|trim %}
56
+ {%- if content %}
57
+ {{- '\n\n' + content }}
58
+ {%- endif %}
59
+ {%- endif %}
60
+ {{- '<|im_end|>\n' }}
61
+ {%- else %}
62
+ {%- if messages[0].role == 'system' %}
63
+ {%- set content = render_content(messages[0].content, false, true)|trim %}
64
+ {{- '<|im_start|>system\n' + content + '<|im_end|>\n' }}
65
+ {%- endif %}
66
+ {%- endif %}
67
+ {%- set ns = namespace(multi_step_tool=true, last_query_index=messages|length - 1) %}
68
+ {%- for message in messages[::-1] %}
69
+ {%- set index = (messages|length - 1) - loop.index0 %}
70
+ {%- if ns.multi_step_tool and message.role == "user" %}
71
+ {%- set content = render_content(message.content, false)|trim %}
72
+ {%- if not(content.startswith('<tool_response>') and content.endswith('</tool_response>')) %}
73
+ {%- set ns.multi_step_tool = false %}
74
+ {%- set ns.last_query_index = index %}
75
+ {%- endif %}
76
+ {%- endif %}
77
+ {%- endfor %}
78
+ {%- if ns.multi_step_tool %}
79
+ {{- raise_exception('No user query found in messages.') }}
80
+ {%- endif %}
81
+ {%- for message in messages %}
82
+ {%- set content = render_content(message.content, true)|trim %}
83
+ {%- if message.role == "system" %}
84
+ {%- if not loop.first %}
85
+ {{- raise_exception('System message must be at the beginning.') }}
86
+ {%- endif %}
87
+ {%- elif message.role == "user" %}
88
+ {{- '<|im_start|>' + message.role + '\n' + content + '<|im_end|>' + '\n' }}
89
+ {%- elif message.role == "assistant" %}
90
+ {%- set reasoning_content = '' %}
91
+ {%- if message.reasoning_content is string %}
92
+ {%- set reasoning_content = message.reasoning_content %}
93
+ {%- else %}
94
+ {%- if '</think>' in content %}
95
+ {%- set reasoning_content = content.split('</think>')[0].rstrip('\n').split('<think>')[-1].lstrip('\n') %}
96
+ {%- set content = content.split('</think>')[-1].lstrip('\n') %}
97
+ {%- endif %}
98
+ {%- endif %}
99
+ {%- set reasoning_content = reasoning_content|trim %}
100
+ {%- if loop.index0 > ns.last_query_index %}
101
+ {{- '<|im_start|>' + message.role + '\n<think>\n' + reasoning_content + '\n</think>\n\n' + content }}
102
+ {%- else %}
103
+ {{- '<|im_start|>' + message.role + '\n' + content }}
104
+ {%- endif %}
105
+ {%- if message.tool_calls and message.tool_calls is iterable and message.tool_calls is not mapping %}
106
+ {%- for tool_call in message.tool_calls %}
107
+ {%- if tool_call.function is defined %}
108
+ {%- set tool_call = tool_call.function %}
109
+ {%- endif %}
110
+ {%- if loop.first %}
111
+ {%- if content|trim %}
112
+ {{- '\n\n<tool_call>\n<function=' + tool_call.name + '>\n' }}
113
+ {%- else %}
114
+ {{- '<tool_call>\n<function=' + tool_call.name + '>\n' }}
115
+ {%- endif %}
116
+ {%- else %}
117
+ {{- '\n<tool_call>\n<function=' + tool_call.name + '>\n' }}
118
+ {%- endif %}
119
+ {%- if tool_call.arguments is defined %}
120
+ {%- for args_name, args_value in tool_call.arguments|items %}
121
+ {{- '<parameter=' + args_name + '>\n' }}
122
+ {%- set args_value = args_value | tojson | safe if args_value is mapping or (args_value is sequence and args_value is not string) else args_value | string %}
123
+ {{- args_value }}
124
+ {{- '\n</parameter>\n' }}
125
+ {%- endfor %}
126
+ {%- endif %}
127
+ {{- '</function>\n</tool_call>' }}
128
+ {%- endfor %}
129
+ {%- endif %}
130
+ {{- '<|im_end|>\n' }}
131
+ {%- elif message.role == "tool" %}
132
+ {%- if loop.previtem and loop.previtem.role != "tool" %}
133
+ {{- '<|im_start|>user' }}
134
+ {%- endif %}
135
+ {{- '\n<tool_response>\n' }}
136
+ {{- content }}
137
+ {{- '\n</tool_response>' }}
138
+ {%- if not loop.last and loop.nextitem.role != "tool" %}
139
+ {{- '<|im_end|>\n' }}
140
+ {%- elif loop.last %}
141
+ {{- '<|im_end|>\n' }}
142
+ {%- endif %}
143
+ {%- else %}
144
+ {{- raise_exception('Unexpected message role.') }}
145
+ {%- endif %}
146
+ {%- endfor %}
147
+ {%- if add_generation_prompt %}
148
+ {{- '<|im_start|>assistant\n' }}
149
+ {%- if enable_thinking is defined and enable_thinking is true %}
150
+ {{- '<think>\n' }}
151
+ {%- else %}
152
+ {{- '<think>\n\n</think>\n\n' }}
153
+ {%- endif %}
154
+ {%- endif %}
tokenizer/merges.txt ADDED
The diff for this file is too large to render. See raw diff
 
tokenizer/tokenizer.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:5f9e4d4901a92b997e463c1f46055088b6cca5ca61a6522d1b9f64c4bb81cb42
3
+ size 12807982
tokenizer/tokenizer_config.json ADDED
@@ -0,0 +1,305 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "add_prefix_space": false,
3
+ "added_tokens_decoder": {
4
+ "248044": {
5
+ "content": "<|endoftext|>",
6
+ "lstrip": false,
7
+ "normalized": false,
8
+ "rstrip": false,
9
+ "single_word": false,
10
+ "special": true
11
+ },
12
+ "248045": {
13
+ "content": "<|im_start|>",
14
+ "lstrip": false,
15
+ "normalized": false,
16
+ "rstrip": false,
17
+ "single_word": false,
18
+ "special": true
19
+ },
20
+ "248046": {
21
+ "content": "<|im_end|>",
22
+ "lstrip": false,
23
+ "normalized": false,
24
+ "rstrip": false,
25
+ "single_word": false,
26
+ "special": true
27
+ },
28
+ "248047": {
29
+ "content": "<|object_ref_start|>",
30
+ "lstrip": false,
31
+ "normalized": false,
32
+ "rstrip": false,
33
+ "single_word": false,
34
+ "special": true
35
+ },
36
+ "248048": {
37
+ "content": "<|object_ref_end|>",
38
+ "lstrip": false,
39
+ "normalized": false,
40
+ "rstrip": false,
41
+ "single_word": false,
42
+ "special": true
43
+ },
44
+ "248049": {
45
+ "content": "<|box_start|>",
46
+ "lstrip": false,
47
+ "normalized": false,
48
+ "rstrip": false,
49
+ "single_word": false,
50
+ "special": true
51
+ },
52
+ "248050": {
53
+ "content": "<|box_end|>",
54
+ "lstrip": false,
55
+ "normalized": false,
56
+ "rstrip": false,
57
+ "single_word": false,
58
+ "special": true
59
+ },
60
+ "248051": {
61
+ "content": "<|quad_start|>",
62
+ "lstrip": false,
63
+ "normalized": false,
64
+ "rstrip": false,
65
+ "single_word": false,
66
+ "special": true
67
+ },
68
+ "248052": {
69
+ "content": "<|quad_end|>",
70
+ "lstrip": false,
71
+ "normalized": false,
72
+ "rstrip": false,
73
+ "single_word": false,
74
+ "special": true
75
+ },
76
+ "248053": {
77
+ "content": "<|vision_start|>",
78
+ "lstrip": false,
79
+ "normalized": false,
80
+ "rstrip": false,
81
+ "single_word": false,
82
+ "special": true
83
+ },
84
+ "248054": {
85
+ "content": "<|vision_end|>",
86
+ "lstrip": false,
87
+ "normalized": false,
88
+ "rstrip": false,
89
+ "single_word": false,
90
+ "special": true
91
+ },
92
+ "248055": {
93
+ "content": "<|vision_pad|>",
94
+ "lstrip": false,
95
+ "normalized": false,
96
+ "rstrip": false,
97
+ "single_word": false,
98
+ "special": true
99
+ },
100
+ "248056": {
101
+ "content": "<|image_pad|>",
102
+ "lstrip": false,
103
+ "normalized": false,
104
+ "rstrip": false,
105
+ "single_word": false,
106
+ "special": true
107
+ },
108
+ "248057": {
109
+ "content": "<|video_pad|>",
110
+ "lstrip": false,
111
+ "normalized": false,
112
+ "rstrip": false,
113
+ "single_word": false,
114
+ "special": true
115
+ },
116
+ "248058": {
117
+ "content": "<tool_call>",
118
+ "lstrip": false,
119
+ "normalized": false,
120
+ "rstrip": false,
121
+ "single_word": false,
122
+ "special": false
123
+ },
124
+ "248059": {
125
+ "content": "</tool_call>",
126
+ "lstrip": false,
127
+ "normalized": false,
128
+ "rstrip": false,
129
+ "single_word": false,
130
+ "special": false
131
+ },
132
+ "248060": {
133
+ "content": "<|fim_prefix|>",
134
+ "lstrip": false,
135
+ "normalized": false,
136
+ "rstrip": false,
137
+ "single_word": false,
138
+ "special": false
139
+ },
140
+ "248061": {
141
+ "content": "<|fim_middle|>",
142
+ "lstrip": false,
143
+ "normalized": false,
144
+ "rstrip": false,
145
+ "single_word": false,
146
+ "special": false
147
+ },
148
+ "248062": {
149
+ "content": "<|fim_suffix|>",
150
+ "lstrip": false,
151
+ "normalized": false,
152
+ "rstrip": false,
153
+ "single_word": false,
154
+ "special": false
155
+ },
156
+ "248063": {
157
+ "content": "<|fim_pad|>",
158
+ "lstrip": false,
159
+ "normalized": false,
160
+ "rstrip": false,
161
+ "single_word": false,
162
+ "special": false
163
+ },
164
+ "248064": {
165
+ "content": "<|repo_name|>",
166
+ "lstrip": false,
167
+ "normalized": false,
168
+ "rstrip": false,
169
+ "single_word": false,
170
+ "special": false
171
+ },
172
+ "248065": {
173
+ "content": "<|file_sep|>",
174
+ "lstrip": false,
175
+ "normalized": false,
176
+ "rstrip": false,
177
+ "single_word": false,
178
+ "special": false
179
+ },
180
+ "248066": {
181
+ "content": "<tool_response>",
182
+ "lstrip": false,
183
+ "normalized": false,
184
+ "rstrip": false,
185
+ "single_word": false,
186
+ "special": false
187
+ },
188
+ "248067": {
189
+ "content": "</tool_response>",
190
+ "lstrip": false,
191
+ "normalized": false,
192
+ "rstrip": false,
193
+ "single_word": false,
194
+ "special": false
195
+ },
196
+ "248068": {
197
+ "content": "<think>",
198
+ "lstrip": false,
199
+ "normalized": false,
200
+ "rstrip": false,
201
+ "single_word": false,
202
+ "special": false
203
+ },
204
+ "248069": {
205
+ "content": "</think>",
206
+ "lstrip": false,
207
+ "normalized": false,
208
+ "rstrip": false,
209
+ "single_word": false,
210
+ "special": false
211
+ },
212
+ "248070": {
213
+ "content": "<|audio_start|>",
214
+ "lstrip": false,
215
+ "normalized": false,
216
+ "rstrip": false,
217
+ "single_word": false,
218
+ "special": true
219
+ },
220
+ "248071": {
221
+ "content": "<|audio_end|>",
222
+ "lstrip": false,
223
+ "normalized": false,
224
+ "rstrip": false,
225
+ "single_word": false,
226
+ "special": true
227
+ },
228
+ "248072": {
229
+ "content": "<tts_pad>",
230
+ "lstrip": false,
231
+ "normalized": false,
232
+ "rstrip": false,
233
+ "single_word": false,
234
+ "special": true
235
+ },
236
+ "248073": {
237
+ "content": "<tts_text_bos>",
238
+ "lstrip": false,
239
+ "normalized": false,
240
+ "rstrip": false,
241
+ "single_word": false,
242
+ "special": true
243
+ },
244
+ "248074": {
245
+ "content": "<tts_text_eod>",
246
+ "lstrip": false,
247
+ "normalized": false,
248
+ "rstrip": false,
249
+ "single_word": false,
250
+ "special": true
251
+ },
252
+ "248075": {
253
+ "content": "<tts_text_bos_single>",
254
+ "lstrip": false,
255
+ "normalized": false,
256
+ "rstrip": false,
257
+ "single_word": false,
258
+ "special": true
259
+ },
260
+ "248076": {
261
+ "content": "<|audio_pad|>",
262
+ "lstrip": false,
263
+ "normalized": false,
264
+ "rstrip": false,
265
+ "single_word": false,
266
+ "special": true
267
+ }
268
+ },
269
+ "additional_special_tokens": [
270
+ "<|im_start|>",
271
+ "<|im_end|>",
272
+ "<|object_ref_start|>",
273
+ "<|object_ref_end|>",
274
+ "<|box_start|>",
275
+ "<|box_end|>",
276
+ "<|quad_start|>",
277
+ "<|quad_end|>",
278
+ "<|vision_start|>",
279
+ "<|vision_end|>",
280
+ "<|vision_pad|>",
281
+ "<|image_pad|>",
282
+ "<|video_pad|>"
283
+ ],
284
+ "bos_token": null,
285
+ "chat_template": "{%- set image_count = namespace(value=0) %}\n{%- set video_count = namespace(value=0) %}\n{%- macro render_content(content, do_vision_count, is_system_content=false) %}\n {%- if content is string %}\n {{- content }}\n {%- elif content is iterable and content is not mapping %}\n {%- for item in content %}\n {%- if 'image' in item or 'image_url' in item or item.type == 'image' %}\n {%- if is_system_content %}\n {{- raise_exception('System message cannot contain images.') }}\n {%- endif %}\n {%- if do_vision_count %}\n {%- set image_count.value = image_count.value + 1 %}\n {%- endif %}\n {%- if add_vision_id %}\n {{- 'Picture ' ~ image_count.value ~ ': ' }}\n {%- endif %}\n {{- '<|vision_start|><|image_pad|><|vision_end|>' }}\n {%- elif 'video' in item or item.type == 'video' %}\n {%- if is_system_content %}\n {{- raise_exception('System message cannot contain videos.') }}\n {%- endif %}\n {%- if do_vision_count %}\n {%- set video_count.value = video_count.value + 1 %}\n {%- endif %}\n {%- if add_vision_id %}\n {{- 'Video ' ~ video_count.value ~ ': ' }}\n {%- endif %}\n {{- '<|vision_start|><|video_pad|><|vision_end|>' }}\n {%- elif 'text' in item %}\n {{- item.text }}\n {%- else %}\n {{- raise_exception('Unexpected item type in content.') }}\n {%- endif %}\n {%- endfor %}\n {%- elif content is none or content is undefined %}\n {{- '' }}\n {%- else %}\n {{- raise_exception('Unexpected content type.') }}\n {%- endif %}\n{%- endmacro %}\n{%- if not messages %}\n {{- raise_exception('No messages provided.') }}\n{%- endif %}\n{%- if tools and tools is iterable and tools is not mapping %}\n {{- '<|im_start|>system\\n' }}\n {{- \"# Tools\\n\\nYou have access to the following functions:\\n\\n<tools>\" }}\n {%- for tool in tools %}\n {{- \"\\n\" }}\n {{- tool | tojson }}\n {%- endfor %}\n {{- \"\\n</tools>\" }}\n {{- '\\n\\nIf you choose to call a function ONLY reply in the following format with NO suffix:\\n\\n<tool_call>\\n<function=example_function_name>\\n<parameter=example_parameter_1>\\nvalue_1\\n</parameter>\\n<parameter=example_parameter_2>\\nThis is the value for the second parameter\\nthat can span\\nmultiple lines\\n</parameter>\\n</function>\\n</tool_call>\\n\\n<IMPORTANT>\\nReminder:\\n- Function calls MUST follow the specified format: an inner <function=...></function> block must be nested within <tool_call></tool_call> XML tags\\n- Required parameters MUST be specified\\n- You may provide optional reasoning for your function call in natural language BEFORE the function call, but NOT after\\n- If there is no function call available, answer the question like normal with your current knowledge and do not tell the user about function calls\\n</IMPORTANT>' }}\n {%- if messages[0].role == 'system' %}\n {%- set content = render_content(messages[0].content, false, true)|trim %}\n {%- if content %}\n {{- '\\n\\n' + content }}\n {%- endif %}\n {%- endif %}\n {{- '<|im_end|>\\n' }}\n{%- else %}\n {%- if messages[0].role == 'system' %}\n {%- set content = render_content(messages[0].content, false, true)|trim %}\n {{- '<|im_start|>system\\n' + content + '<|im_end|>\\n' }}\n {%- endif %}\n{%- endif %}\n{%- set ns = namespace(multi_step_tool=true, last_query_index=messages|length - 1) %}\n{%- for message in messages[::-1] %}\n {%- set index = (messages|length - 1) - loop.index0 %}\n {%- if ns.multi_step_tool and message.role == \"user\" %}\n {%- set content = render_content(message.content, false)|trim %}\n {%- if not(content.startswith('<tool_response>') and content.endswith('</tool_response>')) %}\n {%- set ns.multi_step_tool = false %}\n {%- set ns.last_query_index = index %}\n {%- endif %}\n {%- endif %}\n{%- endfor %}\n{%- if ns.multi_step_tool %}\n {{- raise_exception('No user query found in messages.') }}\n{%- endif %}\n{%- for message in messages %}\n {%- set content = render_content(message.content, true)|trim %}\n {%- if message.role == \"system\" %}\n {%- if not loop.first %}\n {{- raise_exception('System message must be at the beginning.') }}\n {%- endif %}\n {%- elif message.role == \"user\" %}\n {{- '<|im_start|>' + message.role + '\\n' + content + '<|im_end|>' + '\\n' }}\n {%- elif message.role == \"assistant\" %}\n {%- set reasoning_content = '' %}\n {%- if message.reasoning_content is string %}\n {%- set reasoning_content = message.reasoning_content %}\n {%- else %}\n {%- if '</think>' in content %}\n {%- set reasoning_content = content.split('</think>')[0].rstrip('\\n').split('<think>')[-1].lstrip('\\n') %}\n {%- set content = content.split('</think>')[-1].lstrip('\\n') %}\n {%- endif %}\n {%- endif %}\n {%- set reasoning_content = reasoning_content|trim %}\n {%- if loop.index0 > ns.last_query_index %}\n {{- '<|im_start|>' + message.role + '\\n<think>\\n' + reasoning_content + '\\n</think>\\n\\n' + content }}\n {%- else %}\n {{- '<|im_start|>' + message.role + '\\n' + content }}\n {%- endif %}\n {%- if message.tool_calls and message.tool_calls is iterable and message.tool_calls is not mapping %}\n {%- for tool_call in message.tool_calls %}\n {%- if tool_call.function is defined %}\n {%- set tool_call = tool_call.function %}\n {%- endif %}\n {%- if loop.first %}\n {%- if content|trim %}\n {{- '\\n\\n<tool_call>\\n<function=' + tool_call.name + '>\\n' }}\n {%- else %}\n {{- '<tool_call>\\n<function=' + tool_call.name + '>\\n' }}\n {%- endif %}\n {%- else %}\n {{- '\\n<tool_call>\\n<function=' + tool_call.name + '>\\n' }}\n {%- endif %}\n {%- if tool_call.arguments is defined %}\n {%- for args_name, args_value in tool_call.arguments|items %}\n {{- '<parameter=' + args_name + '>\\n' }}\n {%- set args_value = args_value | tojson | safe if args_value is mapping or (args_value is sequence and args_value is not string) else args_value | string %}\n {{- args_value }}\n {{- '\\n</parameter>\\n' }}\n {%- endfor %}\n {%- endif %}\n {{- '</function>\\n</tool_call>' }}\n {%- endfor %}\n {%- endif %}\n {{- '<|im_end|>\\n' }}\n {%- elif message.role == \"tool\" %}\n {%- if loop.previtem and loop.previtem.role != \"tool\" %}\n {{- '<|im_start|>user' }}\n {%- endif %}\n {{- '\\n<tool_response>\\n' }}\n {{- content }}\n {{- '\\n</tool_response>' }}\n {%- if not loop.last and loop.nextitem.role != \"tool\" %}\n {{- '<|im_end|>\\n' }}\n {%- elif loop.last %}\n {{- '<|im_end|>\\n' }}\n {%- endif %}\n {%- else %}\n {{- raise_exception('Unexpected message role.') }}\n {%- endif %}\n{%- endfor %}\n{%- if add_generation_prompt %}\n {{- '<|im_start|>assistant\\n' }}\n {%- if enable_thinking is defined and enable_thinking is true %}\n {{- '<think>\\n' }}\n {%- else %}\n {{- '<think>\\n\\n</think>\\n\\n' }}\n {%- endif %}\n{%- endif %}",
286
+ "clean_up_tokenization_spaces": false,
287
+ "eos_token": "<|im_end|>",
288
+ "errors": "replace",
289
+ "model_max_length": 262144,
290
+ "pad_token": "<|endoftext|>",
291
+ "split_special_tokens": false,
292
+ "tokenizer_class": "Qwen2Tokenizer",
293
+ "unk_token": null,
294
+ "add_bos_token": false,
295
+ "pretokenize_regex": "(?i:'s|'t|'re|'ve|'m|'ll|'d)|[^\\r\\n\\p{L}\\p{N}]?[\\p{L}\\p{M}]+|\\p{N}| ?[^\\s\\p{L}\\p{M}\\p{N}]+[\\r\\n]*|\\s*[\\r\\n]+|\\s+(?!\\S)|\\s+",
296
+ "extra_special_tokens": {
297
+ "audio_bos_token": "<|audio_start|>",
298
+ "audio_eos_token": "<|audio_end|>",
299
+ "audio_token": "<|audio_pad|>",
300
+ "image_token": "<|image_pad|>",
301
+ "video_token": "<|video_pad|>",
302
+ "vision_bos_token": "<|vision_start|>",
303
+ "vision_eos_token": "<|vision_end|>"
304
+ }
305
+ }
tokenizer/vocab.json ADDED
The diff for this file is too large to render. See raw diff
 
transformer.py ADDED
@@ -0,0 +1,278 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Qwen-Image-2.1 DiT with the text adapter built in: `text_fusion` right before `txt_in`.
2
+
3
+ The adapter (`image21-08b-text-encoder-adapter` v11) is a regression from Qwen3.5-0.8B hidden
4
+ states to the input of the native `txt_in = QwenImage21TextProjection`. It therefore sits
5
+ *before* `txt_in`, exactly like `Krea2TextFusion` sits before `Krea2TextProjection` in Krea 2:
6
+
7
+ student slices (B, L, K*d) -> text_fusion -> (B, L, 4096) -> txt_in -> joint stream
8
+
9
+ y = MLP(x) + Attn(x) + Mixer(x)
10
+ | | +-- attention over the slice axis (K student layers)
11
+ | +------------ self-attention over tokens, key padding mask
12
+ +---------------------- ln-per-layer over slices (norms grow ~40x with depth)
13
+
14
+ Two details matter and are easy to get wrong:
15
+
16
+ * The 14 system-prompt tokens are sliced off **after** the fusion, not before. The adapter was
17
+ trained on the full sequence (`drop_first=0`) and its attention branch indexes a learned
18
+ position table by absolute token index, so cropping first would shift every position.
19
+ * The config key is named `text_fusion_config`, not `text_fusion`: `ModelMixin.__getattr__`
20
+ returns a config value before `nn.Module` can hand back a submodule, so a same-named key made
21
+ `model.text_fusion` a `dict` and weight loading failed.
22
+ """
23
+ import torch
24
+ import torch.nn as nn
25
+ import torch.nn.functional as F
26
+ from diffusers.models.transformers.transformer_qwenimage21 import (
27
+ QwenImage21Transformer2DModel,
28
+ )
29
+
30
+
31
+ class PerLayerNorm(nn.Module):
32
+ """Normalize every slice separately, then the concatenation.
33
+
34
+ Without per-slice normalization the early layers barely reach the output: hidden-state norms
35
+ grow roughly 40x from layer 2 to layer 27.
36
+ """
37
+
38
+ def __init__(self, in_dim, n_slices):
39
+ super().__init__()
40
+ assert in_dim % n_slices == 0, f"{in_dim} is not divisible by {n_slices}"
41
+ self.n, self.d = n_slices, in_dim // n_slices
42
+ self.per = nn.LayerNorm(self.d, elementwise_affine=False)
43
+ self.all = nn.LayerNorm(in_dim)
44
+
45
+ def forward(self, x):
46
+ b, l, _ = x.shape
47
+ return self.all(self.per(x.view(b, l, self.n, self.d)).reshape(b, l, -1))
48
+
49
+
50
+ class AttnBlock(nn.Module):
51
+ """Pre-norm self-attention + FFN. No causality: text is not autoregressive and the DiT
52
+ already sees the whole sequence at once."""
53
+
54
+ def __init__(self, d_model, n_heads, ffn_mult=4):
55
+ super().__init__()
56
+ self.n1 = nn.LayerNorm(d_model)
57
+ self.attn = nn.MultiheadAttention(d_model, n_heads, batch_first=True)
58
+ self.n2 = nn.LayerNorm(d_model)
59
+ self.ffn = nn.Sequential(nn.Linear(d_model, d_model * ffn_mult),
60
+ nn.GELU(approximate="tanh"),
61
+ nn.Linear(d_model * ffn_mult, d_model))
62
+
63
+ def forward(self, x, key_padding_mask=None):
64
+ h = self.n1(x)
65
+ x = x + self.attn(h, h, h, need_weights=False, key_padding_mask=key_padding_mask)[0]
66
+ return x + self.ffn(self.n2(x))
67
+
68
+
69
+ class AttnMixer(nn.Module):
70
+ """Token branch: norm -> project to d_model -> N blocks -> project to out_dim.
71
+
72
+ The last projection is zero-initialized, so at step 0 the branch adds nothing.
73
+ """
74
+
75
+ def __init__(self, in_dim, out_dim, d_model=1024, n_heads=8, blocks=2, max_len=256):
76
+ super().__init__()
77
+ self.norm = nn.LayerNorm(in_dim)
78
+ self.inp = nn.Linear(in_dim, d_model)
79
+ self.pos = nn.Parameter(torch.zeros(1, max_len, d_model))
80
+ self.blocks = nn.ModuleList([AttnBlock(d_model, n_heads) for _ in range(blocks)])
81
+ self.out = nn.Linear(d_model, out_dim)
82
+ nn.init.zeros_(self.out.weight)
83
+ nn.init.zeros_(self.out.bias)
84
+
85
+ def forward(self, x, key_padding_mask=None):
86
+ h = self.inp(self.norm(x))
87
+ n = h.shape[1]
88
+ pos = self.pos
89
+ if n > pos.shape[1]:
90
+ # The position table was trained on `max_len` slots; the tail is padded with zeros
91
+ # (long sequences simply carry no positional signal there, but nothing crashes).
92
+ pos = F.pad(pos, (0, 0, 0, n - pos.shape[1]))
93
+ h = h + pos[:, :n]
94
+ for block in self.blocks:
95
+ h = block(h, key_padding_mask)
96
+ return self.out(h)
97
+
98
+
99
+ class SliceMixer(nn.Module):
100
+ """Attention over the slice axis (the `layerwise_blocks` + `projector` part of Krea 2 fusion).
101
+
102
+ Slices are normalized one by one and run as a sequence of length K through N self-attention
103
+ blocks; `Linear(K -> 1)` then collapses the axis. The result is added to the MLP output
104
+ (zero-initialized output projection).
105
+ """
106
+
107
+ def __init__(self, n_slices, d, out_dim, n_heads=8, blocks=2, ffn_mult=2):
108
+ super().__init__()
109
+ self.n, self.d = n_slices, d
110
+ self.per = nn.LayerNorm(d, elementwise_affine=False)
111
+ self.blocks = nn.ModuleList([AttnBlock(d, n_heads, ffn_mult) for _ in range(blocks)])
112
+ self.proj = nn.Linear(n_slices, 1, bias=False)
113
+ self.out = nn.Linear(d, out_dim)
114
+ nn.init.zeros_(self.out.weight)
115
+ nn.init.zeros_(self.out.bias)
116
+
117
+ def forward(self, x):
118
+ b, l, _ = x.shape
119
+ h = self.per(x.view(b, l, self.n, self.d)).reshape(b * l, self.n, self.d)
120
+ for block in self.blocks:
121
+ h = block(h)
122
+ h = self.proj(h.permute(0, 2, 1)).squeeze(-1)
123
+ return self.out(h).reshape(b, l, -1)
124
+
125
+
126
+ class AttnAdapter(nn.Module):
127
+ """Point-wise MLP (`self.mlp`) plus residual branches over tokens (`self.attn`) and slices (`self.mixer`)."""
128
+
129
+ def __init__(self, mods, attn=None, mixer=None):
130
+ super().__init__()
131
+ self.mlp = nn.Sequential(*mods)
132
+ self.attn = attn
133
+ self.mixer = mixer
134
+
135
+ def forward(self, x, mask=None):
136
+ """`mask`: `(B, L)` bool, True = real token. The attention branches get `key_padding_mask = ~mask`,
137
+ otherwise attention would look into the padding."""
138
+ out = self.mlp(x)
139
+ if self.attn is not None:
140
+ kpm = None if mask is None else ~mask.bool()
141
+ out = out + self.attn(x, kpm)
142
+ if self.mixer is not None:
143
+ out = out + self.mixer(x)
144
+ return out
145
+
146
+
147
+ def build_fusion(in_dim, out_dim, hidden=4096, proj_layers=2, norm="none", n_slices=1,
148
+ attention=0, attn_dim=1024, attn_heads=8, max_len=256,
149
+ mixer=0, mixer_heads=8, mixer_ffn=2, **_ignored):
150
+ """Build the fusion block from the transformer config (`text_fusion_config`).
151
+
152
+ `proj_layers` linear layers with GELU(tanh) between them; `attention`/`mixer` are the number of
153
+ residual branches. Extra config keys (`student_layers`, `drop_idx`) are ignored here: the
154
+ pipeline uses them, the block does not.
155
+ """
156
+ if proj_layers < 2:
157
+ raise ValueError("at least 2 linear layers are required")
158
+ mods = []
159
+ if norm == "ln":
160
+ mods.append(nn.LayerNorm(in_dim))
161
+ elif norm == "ln-per-layer":
162
+ mods.append(PerLayerNorm(in_dim, n_slices))
163
+ elif norm == "rms":
164
+ mods.append(nn.RMSNorm(in_dim))
165
+ elif norm != "none":
166
+ raise ValueError(f"unknown norm: {norm}")
167
+ mods += [nn.Linear(in_dim, hidden), nn.GELU(approximate="tanh")]
168
+ for _ in range(proj_layers - 2):
169
+ mods += [nn.Linear(hidden, hidden), nn.GELU(approximate="tanh")]
170
+ mods.append(nn.Linear(hidden, out_dim))
171
+ attn = AttnMixer(in_dim, out_dim, attn_dim, attn_heads, attention, max_len) if attention else None
172
+ mix = SliceMixer(n_slices, in_dim // n_slices, out_dim, mixer_heads, mixer, mixer_ffn) if mixer else None
173
+ if attn is not None or mix is not None:
174
+ return AttnAdapter(mods, attn, mix)
175
+ return nn.Sequential(*mods)
176
+
177
+
178
+ class QwenImage21FusionTransformer2DModel(QwenImage21Transformer2DModel):
179
+ """`QwenImage21Transformer2DModel` + `text_fusion` (student stack -> 4096 condition).
180
+
181
+ The config carries an extra key `text_fusion_config` (arguments of `build_fusion` plus
182
+ `student_layers` and `drop_idx` for the pipeline), so the checkpoint is self-contained: the
183
+ block weights live in the same file under the `text_fusion.` prefix.
184
+
185
+ The `__init__` signature intentionally repeats the parent's. `ConfigMixin.extract_init_dict`
186
+ builds `init_dict` from named parameters only and ignores `**kwargs`, so forwarding the config
187
+ through `**kwargs` would drop the parent keys and rebuild the model from defaults.
188
+ """
189
+
190
+ _no_split_modules = QwenImage21Transformer2DModel._no_split_modules + ["AttnAdapter"]
191
+
192
+ def __init__(
193
+ self,
194
+ patch_size: int = 1,
195
+ in_channels: int = 64,
196
+ out_channels: int | None = 64,
197
+ num_layers: int = 32,
198
+ attention_head_dim: int = 128,
199
+ num_attention_heads: int = 32,
200
+ context_in_dim: int = 4096,
201
+ mlp_ratio: int = 3,
202
+ axes_dims_rope: tuple[int, int, int] = (16, 56, 56),
203
+ eps: float = 1e-6,
204
+ causal_condition: bool = True,
205
+ text_fusion_config: dict | None = None,
206
+ ):
207
+ super().__init__(
208
+ patch_size=patch_size,
209
+ in_channels=in_channels,
210
+ out_channels=out_channels,
211
+ num_layers=num_layers,
212
+ attention_head_dim=attention_head_dim,
213
+ num_attention_heads=num_attention_heads,
214
+ context_in_dim=context_in_dim,
215
+ mlp_ratio=mlp_ratio,
216
+ axes_dims_rope=axes_dims_rope,
217
+ eps=eps,
218
+ causal_condition=causal_condition,
219
+ )
220
+ if text_fusion_config is None:
221
+ raise ValueError(
222
+ "`text_fusion_config` is required in config.json: without it there is nowhere to "
223
+ "attach the adapter, and `encoder_hidden_states` are expected to be context_in_dim"
224
+ )
225
+ self.text_fusion = build_fusion(**text_fusion_config)
226
+ self.register_to_config(text_fusion_config=dict(text_fusion_config))
227
+ self.condition_drop_idx = int(text_fusion_config.get("drop_idx", 0))
228
+
229
+ @property
230
+ def text_fusion_dtype(self):
231
+ return next(self.text_fusion.parameters()).dtype
232
+
233
+ def _condition(self, encoder_hidden_states, encoder_hidden_states_mask, img_mask):
234
+ """Student slices -> DiT condition: fusion over the full sequence, then crop the prefix.
235
+
236
+ `img_mask` arrives from the pipeline already concatenated with the target-image slots
237
+ (`append_target_slots`), so only the conditioning part is cropped — otherwise the target
238
+ slots would slide out of place.
239
+ """
240
+ length = encoder_hidden_states.shape[1]
241
+ mask = None if encoder_hidden_states_mask is None else encoder_hidden_states_mask.bool()
242
+ fused = self.text_fusion(encoder_hidden_states.to(self.text_fusion_dtype), mask)
243
+ drop = self.condition_drop_idx
244
+ if not drop:
245
+ return fused, encoder_hidden_states_mask, img_mask
246
+ fused = fused[:, drop:]
247
+ if encoder_hidden_states_mask is not None:
248
+ encoder_hidden_states_mask = encoder_hidden_states_mask[:, drop:]
249
+ img_mask = torch.cat([img_mask[:, drop:length], img_mask[:, length:]], dim=1)
250
+ return fused, encoder_hidden_states_mask, img_mask
251
+
252
+ def forward(
253
+ self,
254
+ hidden_states,
255
+ encoder_hidden_states,
256
+ timestep,
257
+ img_shapes,
258
+ img_mask,
259
+ encoder_hidden_states_mask=None,
260
+ **kwargs,
261
+ ):
262
+ """`encoder_hidden_states` here is the student stack `(B, L, K*d)`, not a ready condition.
263
+
264
+ The fusion output is cast back to the latent dtype: the block is stored in fp16 while
265
+ `txt_in` and the transformer blocks expect the model dtype.
266
+ """
267
+ fused, encoder_hidden_states_mask, img_mask = self._condition(
268
+ encoder_hidden_states, encoder_hidden_states_mask, img_mask
269
+ )
270
+ return super().forward(
271
+ hidden_states=hidden_states,
272
+ encoder_hidden_states=fused.to(hidden_states.dtype),
273
+ timestep=timestep,
274
+ img_shapes=img_shapes,
275
+ img_mask=img_mask,
276
+ encoder_hidden_states_mask=encoder_hidden_states_mask,
277
+ **kwargs,
278
+ )
transformer/config.json ADDED
@@ -0,0 +1,43 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "_class_name": "QwenImage21FusionTransformer2DModel",
3
+ "_diffusers_version": "0.37.0.dev0",
4
+ "attention_head_dim": 128,
5
+ "axes_dims_rope": [
6
+ 16,
7
+ 56,
8
+ 56
9
+ ],
10
+ "context_in_dim": 4096,
11
+ "in_channels": 64,
12
+ "num_attention_heads": 32,
13
+ "num_layers": 32,
14
+ "out_channels": 64,
15
+ "patch_size": 1,
16
+ "mlp_ratio": 3,
17
+ "eps": 1e-06,
18
+ "causal_condition": true,
19
+ "text_fusion_config": {
20
+ "in_dim": 6144,
21
+ "out_dim": 4096,
22
+ "hidden": 6144,
23
+ "proj_layers": 3,
24
+ "norm": "ln-per-layer",
25
+ "n_slices": 6,
26
+ "attention": 2,
27
+ "attn_dim": 1024,
28
+ "attn_heads": 8,
29
+ "max_len": 512,
30
+ "mixer": 2,
31
+ "mixer_heads": 8,
32
+ "mixer_ffn": 2,
33
+ "student_layers": [
34
+ 4,
35
+ 8,
36
+ 12,
37
+ 16,
38
+ 20,
39
+ 24
40
+ ],
41
+ "drop_idx": 14
42
+ }
43
+ }
transformer/diffusion_pytorch_model-00001-of-00002.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:a71f3c4eca68c67df8c8fd288cc1daf27ac0a89d6eee9f0ab7aa2ec1031adbe4
3
+ size 10284159452
transformer/diffusion_pytorch_model-00002-of-00002.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:05793f413d6bf507cee006142f88746901617e641b0c05648298c7ba17bd6e36
3
+ size 4261951792
transformer/diffusion_pytorch_model.safetensors.index.json ADDED
@@ -0,0 +1,370 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "metadata": {
3
+ "total_size": 14546069516
4
+ },
5
+ "weight_map": {
6
+ "img_in.weight": "diffusion_pytorch_model-00001-of-00002.safetensors",
7
+ "modulation.1.weight": "diffusion_pytorch_model-00001-of-00002.safetensors",
8
+ "text_fusion.attn.blocks.0.attn.in_proj_bias": "diffusion_pytorch_model-00001-of-00002.safetensors",
9
+ "text_fusion.attn.blocks.0.attn.in_proj_weight": "diffusion_pytorch_model-00001-of-00002.safetensors",
10
+ "text_fusion.attn.blocks.0.attn.out_proj.bias": "diffusion_pytorch_model-00001-of-00002.safetensors",
11
+ "text_fusion.attn.blocks.0.attn.out_proj.weight": "diffusion_pytorch_model-00001-of-00002.safetensors",
12
+ "text_fusion.attn.blocks.0.ffn.0.bias": "diffusion_pytorch_model-00001-of-00002.safetensors",
13
+ "text_fusion.attn.blocks.0.ffn.0.weight": "diffusion_pytorch_model-00001-of-00002.safetensors",
14
+ "text_fusion.attn.blocks.0.ffn.2.bias": "diffusion_pytorch_model-00001-of-00002.safetensors",
15
+ "text_fusion.attn.blocks.0.ffn.2.weight": "diffusion_pytorch_model-00001-of-00002.safetensors",
16
+ "text_fusion.attn.blocks.0.n1.bias": "diffusion_pytorch_model-00001-of-00002.safetensors",
17
+ "text_fusion.attn.blocks.0.n1.weight": "diffusion_pytorch_model-00001-of-00002.safetensors",
18
+ "text_fusion.attn.blocks.0.n2.bias": "diffusion_pytorch_model-00001-of-00002.safetensors",
19
+ "text_fusion.attn.blocks.0.n2.weight": "diffusion_pytorch_model-00001-of-00002.safetensors",
20
+ "text_fusion.attn.blocks.1.attn.in_proj_bias": "diffusion_pytorch_model-00001-of-00002.safetensors",
21
+ "text_fusion.attn.blocks.1.attn.in_proj_weight": "diffusion_pytorch_model-00001-of-00002.safetensors",
22
+ "text_fusion.attn.blocks.1.attn.out_proj.bias": "diffusion_pytorch_model-00001-of-00002.safetensors",
23
+ "text_fusion.attn.blocks.1.attn.out_proj.weight": "diffusion_pytorch_model-00001-of-00002.safetensors",
24
+ "text_fusion.attn.blocks.1.ffn.0.bias": "diffusion_pytorch_model-00001-of-00002.safetensors",
25
+ "text_fusion.attn.blocks.1.ffn.0.weight": "diffusion_pytorch_model-00001-of-00002.safetensors",
26
+ "text_fusion.attn.blocks.1.ffn.2.bias": "diffusion_pytorch_model-00001-of-00002.safetensors",
27
+ "text_fusion.attn.blocks.1.ffn.2.weight": "diffusion_pytorch_model-00001-of-00002.safetensors",
28
+ "text_fusion.attn.blocks.1.n1.bias": "diffusion_pytorch_model-00001-of-00002.safetensors",
29
+ "text_fusion.attn.blocks.1.n1.weight": "diffusion_pytorch_model-00001-of-00002.safetensors",
30
+ "text_fusion.attn.blocks.1.n2.bias": "diffusion_pytorch_model-00001-of-00002.safetensors",
31
+ "text_fusion.attn.blocks.1.n2.weight": "diffusion_pytorch_model-00001-of-00002.safetensors",
32
+ "text_fusion.attn.inp.bias": "diffusion_pytorch_model-00001-of-00002.safetensors",
33
+ "text_fusion.attn.inp.weight": "diffusion_pytorch_model-00001-of-00002.safetensors",
34
+ "text_fusion.attn.norm.bias": "diffusion_pytorch_model-00001-of-00002.safetensors",
35
+ "text_fusion.attn.norm.weight": "diffusion_pytorch_model-00001-of-00002.safetensors",
36
+ "text_fusion.attn.out.bias": "diffusion_pytorch_model-00001-of-00002.safetensors",
37
+ "text_fusion.attn.out.weight": "diffusion_pytorch_model-00001-of-00002.safetensors",
38
+ "text_fusion.attn.pos": "diffusion_pytorch_model-00001-of-00002.safetensors",
39
+ "text_fusion.mixer.blocks.0.attn.in_proj_bias": "diffusion_pytorch_model-00001-of-00002.safetensors",
40
+ "text_fusion.mixer.blocks.0.attn.in_proj_weight": "diffusion_pytorch_model-00001-of-00002.safetensors",
41
+ "text_fusion.mixer.blocks.0.attn.out_proj.bias": "diffusion_pytorch_model-00001-of-00002.safetensors",
42
+ "text_fusion.mixer.blocks.0.attn.out_proj.weight": "diffusion_pytorch_model-00001-of-00002.safetensors",
43
+ "text_fusion.mixer.blocks.0.ffn.0.bias": "diffusion_pytorch_model-00001-of-00002.safetensors",
44
+ "text_fusion.mixer.blocks.0.ffn.0.weight": "diffusion_pytorch_model-00001-of-00002.safetensors",
45
+ "text_fusion.mixer.blocks.0.ffn.2.bias": "diffusion_pytorch_model-00001-of-00002.safetensors",
46
+ "text_fusion.mixer.blocks.0.ffn.2.weight": "diffusion_pytorch_model-00001-of-00002.safetensors",
47
+ "text_fusion.mixer.blocks.0.n1.bias": "diffusion_pytorch_model-00001-of-00002.safetensors",
48
+ "text_fusion.mixer.blocks.0.n1.weight": "diffusion_pytorch_model-00001-of-00002.safetensors",
49
+ "text_fusion.mixer.blocks.0.n2.bias": "diffusion_pytorch_model-00001-of-00002.safetensors",
50
+ "text_fusion.mixer.blocks.0.n2.weight": "diffusion_pytorch_model-00001-of-00002.safetensors",
51
+ "text_fusion.mixer.blocks.1.attn.in_proj_bias": "diffusion_pytorch_model-00001-of-00002.safetensors",
52
+ "text_fusion.mixer.blocks.1.attn.in_proj_weight": "diffusion_pytorch_model-00001-of-00002.safetensors",
53
+ "text_fusion.mixer.blocks.1.attn.out_proj.bias": "diffusion_pytorch_model-00001-of-00002.safetensors",
54
+ "text_fusion.mixer.blocks.1.attn.out_proj.weight": "diffusion_pytorch_model-00001-of-00002.safetensors",
55
+ "text_fusion.mixer.blocks.1.ffn.0.bias": "diffusion_pytorch_model-00001-of-00002.safetensors",
56
+ "text_fusion.mixer.blocks.1.ffn.0.weight": "diffusion_pytorch_model-00001-of-00002.safetensors",
57
+ "text_fusion.mixer.blocks.1.ffn.2.bias": "diffusion_pytorch_model-00001-of-00002.safetensors",
58
+ "text_fusion.mixer.blocks.1.ffn.2.weight": "diffusion_pytorch_model-00001-of-00002.safetensors",
59
+ "text_fusion.mixer.blocks.1.n1.bias": "diffusion_pytorch_model-00001-of-00002.safetensors",
60
+ "text_fusion.mixer.blocks.1.n1.weight": "diffusion_pytorch_model-00001-of-00002.safetensors",
61
+ "text_fusion.mixer.blocks.1.n2.bias": "diffusion_pytorch_model-00001-of-00002.safetensors",
62
+ "text_fusion.mixer.blocks.1.n2.weight": "diffusion_pytorch_model-00001-of-00002.safetensors",
63
+ "text_fusion.mixer.out.bias": "diffusion_pytorch_model-00001-of-00002.safetensors",
64
+ "text_fusion.mixer.out.weight": "diffusion_pytorch_model-00001-of-00002.safetensors",
65
+ "text_fusion.mixer.proj.weight": "diffusion_pytorch_model-00001-of-00002.safetensors",
66
+ "text_fusion.mlp.0.all.bias": "diffusion_pytorch_model-00001-of-00002.safetensors",
67
+ "text_fusion.mlp.0.all.weight": "diffusion_pytorch_model-00001-of-00002.safetensors",
68
+ "text_fusion.mlp.1.bias": "diffusion_pytorch_model-00001-of-00002.safetensors",
69
+ "text_fusion.mlp.1.weight": "diffusion_pytorch_model-00001-of-00002.safetensors",
70
+ "text_fusion.mlp.3.bias": "diffusion_pytorch_model-00001-of-00002.safetensors",
71
+ "text_fusion.mlp.3.weight": "diffusion_pytorch_model-00001-of-00002.safetensors",
72
+ "text_fusion.mlp.5.bias": "diffusion_pytorch_model-00001-of-00002.safetensors",
73
+ "text_fusion.mlp.5.weight": "diffusion_pytorch_model-00001-of-00002.safetensors",
74
+ "time_text_embed.timestep_embedder.linear_1.weight": "diffusion_pytorch_model-00001-of-00002.safetensors",
75
+ "time_text_embed.timestep_embedder.linear_2.weight": "diffusion_pytorch_model-00001-of-00002.safetensors",
76
+ "transformer_blocks.0.attn.norm_k.weight": "diffusion_pytorch_model-00001-of-00002.safetensors",
77
+ "transformer_blocks.0.attn.norm_q.weight": "diffusion_pytorch_model-00001-of-00002.safetensors",
78
+ "transformer_blocks.0.attn.to_k.weight": "diffusion_pytorch_model-00001-of-00002.safetensors",
79
+ "transformer_blocks.0.attn.to_out.0.weight": "diffusion_pytorch_model-00001-of-00002.safetensors",
80
+ "transformer_blocks.0.attn.to_q.weight": "diffusion_pytorch_model-00001-of-00002.safetensors",
81
+ "transformer_blocks.0.attn.to_v.weight": "diffusion_pytorch_model-00001-of-00002.safetensors",
82
+ "transformer_blocks.0.img_mlp.gate_layer.weight": "diffusion_pytorch_model-00001-of-00002.safetensors",
83
+ "transformer_blocks.0.img_mlp.out.weight": "diffusion_pytorch_model-00001-of-00002.safetensors",
84
+ "transformer_blocks.0.img_mlp.proj.weight": "diffusion_pytorch_model-00001-of-00002.safetensors",
85
+ "transformer_blocks.1.attn.norm_k.weight": "diffusion_pytorch_model-00001-of-00002.safetensors",
86
+ "transformer_blocks.1.attn.norm_q.weight": "diffusion_pytorch_model-00001-of-00002.safetensors",
87
+ "transformer_blocks.1.attn.to_k.weight": "diffusion_pytorch_model-00001-of-00002.safetensors",
88
+ "transformer_blocks.1.attn.to_out.0.weight": "diffusion_pytorch_model-00001-of-00002.safetensors",
89
+ "transformer_blocks.1.attn.to_q.weight": "diffusion_pytorch_model-00001-of-00002.safetensors",
90
+ "transformer_blocks.1.attn.to_v.weight": "diffusion_pytorch_model-00001-of-00002.safetensors",
91
+ "transformer_blocks.1.img_mlp.gate_layer.weight": "diffusion_pytorch_model-00001-of-00002.safetensors",
92
+ "transformer_blocks.1.img_mlp.out.weight": "diffusion_pytorch_model-00001-of-00002.safetensors",
93
+ "transformer_blocks.1.img_mlp.proj.weight": "diffusion_pytorch_model-00001-of-00002.safetensors",
94
+ "transformer_blocks.10.attn.norm_k.weight": "diffusion_pytorch_model-00001-of-00002.safetensors",
95
+ "transformer_blocks.10.attn.norm_q.weight": "diffusion_pytorch_model-00001-of-00002.safetensors",
96
+ "transformer_blocks.10.attn.to_k.weight": "diffusion_pytorch_model-00001-of-00002.safetensors",
97
+ "transformer_blocks.10.attn.to_out.0.weight": "diffusion_pytorch_model-00001-of-00002.safetensors",
98
+ "transformer_blocks.10.attn.to_q.weight": "diffusion_pytorch_model-00001-of-00002.safetensors",
99
+ "transformer_blocks.10.attn.to_v.weight": "diffusion_pytorch_model-00001-of-00002.safetensors",
100
+ "transformer_blocks.10.img_mlp.gate_layer.weight": "diffusion_pytorch_model-00001-of-00002.safetensors",
101
+ "transformer_blocks.10.img_mlp.out.weight": "diffusion_pytorch_model-00001-of-00002.safetensors",
102
+ "transformer_blocks.10.img_mlp.proj.weight": "diffusion_pytorch_model-00001-of-00002.safetensors",
103
+ "transformer_blocks.11.attn.norm_k.weight": "diffusion_pytorch_model-00001-of-00002.safetensors",
104
+ "transformer_blocks.11.attn.norm_q.weight": "diffusion_pytorch_model-00001-of-00002.safetensors",
105
+ "transformer_blocks.11.attn.to_k.weight": "diffusion_pytorch_model-00001-of-00002.safetensors",
106
+ "transformer_blocks.11.attn.to_out.0.weight": "diffusion_pytorch_model-00001-of-00002.safetensors",
107
+ "transformer_blocks.11.attn.to_q.weight": "diffusion_pytorch_model-00001-of-00002.safetensors",
108
+ "transformer_blocks.11.attn.to_v.weight": "diffusion_pytorch_model-00001-of-00002.safetensors",
109
+ "transformer_blocks.11.img_mlp.gate_layer.weight": "diffusion_pytorch_model-00001-of-00002.safetensors",
110
+ "transformer_blocks.11.img_mlp.out.weight": "diffusion_pytorch_model-00001-of-00002.safetensors",
111
+ "transformer_blocks.11.img_mlp.proj.weight": "diffusion_pytorch_model-00001-of-00002.safetensors",
112
+ "transformer_blocks.12.attn.norm_k.weight": "diffusion_pytorch_model-00001-of-00002.safetensors",
113
+ "transformer_blocks.12.attn.norm_q.weight": "diffusion_pytorch_model-00001-of-00002.safetensors",
114
+ "transformer_blocks.12.attn.to_k.weight": "diffusion_pytorch_model-00001-of-00002.safetensors",
115
+ "transformer_blocks.12.attn.to_out.0.weight": "diffusion_pytorch_model-00001-of-00002.safetensors",
116
+ "transformer_blocks.12.attn.to_q.weight": "diffusion_pytorch_model-00001-of-00002.safetensors",
117
+ "transformer_blocks.12.attn.to_v.weight": "diffusion_pytorch_model-00001-of-00002.safetensors",
118
+ "transformer_blocks.12.img_mlp.gate_layer.weight": "diffusion_pytorch_model-00001-of-00002.safetensors",
119
+ "transformer_blocks.12.img_mlp.out.weight": "diffusion_pytorch_model-00001-of-00002.safetensors",
120
+ "transformer_blocks.12.img_mlp.proj.weight": "diffusion_pytorch_model-00001-of-00002.safetensors",
121
+ "transformer_blocks.13.attn.norm_k.weight": "diffusion_pytorch_model-00001-of-00002.safetensors",
122
+ "transformer_blocks.13.attn.norm_q.weight": "diffusion_pytorch_model-00001-of-00002.safetensors",
123
+ "transformer_blocks.13.attn.to_k.weight": "diffusion_pytorch_model-00001-of-00002.safetensors",
124
+ "transformer_blocks.13.attn.to_out.0.weight": "diffusion_pytorch_model-00001-of-00002.safetensors",
125
+ "transformer_blocks.13.attn.to_q.weight": "diffusion_pytorch_model-00001-of-00002.safetensors",
126
+ "transformer_blocks.13.attn.to_v.weight": "diffusion_pytorch_model-00001-of-00002.safetensors",
127
+ "transformer_blocks.13.img_mlp.gate_layer.weight": "diffusion_pytorch_model-00001-of-00002.safetensors",
128
+ "transformer_blocks.13.img_mlp.out.weight": "diffusion_pytorch_model-00001-of-00002.safetensors",
129
+ "transformer_blocks.13.img_mlp.proj.weight": "diffusion_pytorch_model-00001-of-00002.safetensors",
130
+ "transformer_blocks.14.attn.norm_k.weight": "diffusion_pytorch_model-00001-of-00002.safetensors",
131
+ "transformer_blocks.14.attn.norm_q.weight": "diffusion_pytorch_model-00001-of-00002.safetensors",
132
+ "transformer_blocks.14.attn.to_k.weight": "diffusion_pytorch_model-00001-of-00002.safetensors",
133
+ "transformer_blocks.14.attn.to_out.0.weight": "diffusion_pytorch_model-00001-of-00002.safetensors",
134
+ "transformer_blocks.14.attn.to_q.weight": "diffusion_pytorch_model-00001-of-00002.safetensors",
135
+ "transformer_blocks.14.attn.to_v.weight": "diffusion_pytorch_model-00001-of-00002.safetensors",
136
+ "transformer_blocks.14.img_mlp.gate_layer.weight": "diffusion_pytorch_model-00001-of-00002.safetensors",
137
+ "transformer_blocks.14.img_mlp.out.weight": "diffusion_pytorch_model-00001-of-00002.safetensors",
138
+ "transformer_blocks.14.img_mlp.proj.weight": "diffusion_pytorch_model-00001-of-00002.safetensors",
139
+ "transformer_blocks.15.attn.norm_k.weight": "diffusion_pytorch_model-00001-of-00002.safetensors",
140
+ "transformer_blocks.15.attn.norm_q.weight": "diffusion_pytorch_model-00001-of-00002.safetensors",
141
+ "transformer_blocks.15.attn.to_k.weight": "diffusion_pytorch_model-00001-of-00002.safetensors",
142
+ "transformer_blocks.15.attn.to_out.0.weight": "diffusion_pytorch_model-00001-of-00002.safetensors",
143
+ "transformer_blocks.15.attn.to_q.weight": "diffusion_pytorch_model-00001-of-00002.safetensors",
144
+ "transformer_blocks.15.attn.to_v.weight": "diffusion_pytorch_model-00001-of-00002.safetensors",
145
+ "transformer_blocks.15.img_mlp.gate_layer.weight": "diffusion_pytorch_model-00001-of-00002.safetensors",
146
+ "transformer_blocks.15.img_mlp.out.weight": "diffusion_pytorch_model-00001-of-00002.safetensors",
147
+ "transformer_blocks.15.img_mlp.proj.weight": "diffusion_pytorch_model-00001-of-00002.safetensors",
148
+ "transformer_blocks.16.attn.norm_k.weight": "diffusion_pytorch_model-00001-of-00002.safetensors",
149
+ "transformer_blocks.16.attn.norm_q.weight": "diffusion_pytorch_model-00001-of-00002.safetensors",
150
+ "transformer_blocks.16.attn.to_k.weight": "diffusion_pytorch_model-00001-of-00002.safetensors",
151
+ "transformer_blocks.16.attn.to_out.0.weight": "diffusion_pytorch_model-00001-of-00002.safetensors",
152
+ "transformer_blocks.16.attn.to_q.weight": "diffusion_pytorch_model-00001-of-00002.safetensors",
153
+ "transformer_blocks.16.attn.to_v.weight": "diffusion_pytorch_model-00001-of-00002.safetensors",
154
+ "transformer_blocks.16.img_mlp.gate_layer.weight": "diffusion_pytorch_model-00001-of-00002.safetensors",
155
+ "transformer_blocks.16.img_mlp.out.weight": "diffusion_pytorch_model-00001-of-00002.safetensors",
156
+ "transformer_blocks.16.img_mlp.proj.weight": "diffusion_pytorch_model-00001-of-00002.safetensors",
157
+ "transformer_blocks.17.attn.norm_k.weight": "diffusion_pytorch_model-00001-of-00002.safetensors",
158
+ "transformer_blocks.17.attn.norm_q.weight": "diffusion_pytorch_model-00001-of-00002.safetensors",
159
+ "transformer_blocks.17.attn.to_k.weight": "diffusion_pytorch_model-00001-of-00002.safetensors",
160
+ "transformer_blocks.17.attn.to_out.0.weight": "diffusion_pytorch_model-00001-of-00002.safetensors",
161
+ "transformer_blocks.17.attn.to_q.weight": "diffusion_pytorch_model-00001-of-00002.safetensors",
162
+ "transformer_blocks.17.attn.to_v.weight": "diffusion_pytorch_model-00001-of-00002.safetensors",
163
+ "transformer_blocks.17.img_mlp.gate_layer.weight": "diffusion_pytorch_model-00001-of-00002.safetensors",
164
+ "transformer_blocks.17.img_mlp.out.weight": "diffusion_pytorch_model-00001-of-00002.safetensors",
165
+ "transformer_blocks.17.img_mlp.proj.weight": "diffusion_pytorch_model-00001-of-00002.safetensors",
166
+ "transformer_blocks.18.attn.norm_k.weight": "diffusion_pytorch_model-00001-of-00002.safetensors",
167
+ "transformer_blocks.18.attn.norm_q.weight": "diffusion_pytorch_model-00001-of-00002.safetensors",
168
+ "transformer_blocks.18.attn.to_k.weight": "diffusion_pytorch_model-00001-of-00002.safetensors",
169
+ "transformer_blocks.18.attn.to_out.0.weight": "diffusion_pytorch_model-00001-of-00002.safetensors",
170
+ "transformer_blocks.18.attn.to_q.weight": "diffusion_pytorch_model-00001-of-00002.safetensors",
171
+ "transformer_blocks.18.attn.to_v.weight": "diffusion_pytorch_model-00001-of-00002.safetensors",
172
+ "transformer_blocks.18.img_mlp.gate_layer.weight": "diffusion_pytorch_model-00001-of-00002.safetensors",
173
+ "transformer_blocks.18.img_mlp.out.weight": "diffusion_pytorch_model-00001-of-00002.safetensors",
174
+ "transformer_blocks.18.img_mlp.proj.weight": "diffusion_pytorch_model-00001-of-00002.safetensors",
175
+ "transformer_blocks.19.attn.norm_k.weight": "diffusion_pytorch_model-00001-of-00002.safetensors",
176
+ "transformer_blocks.19.attn.norm_q.weight": "diffusion_pytorch_model-00001-of-00002.safetensors",
177
+ "transformer_blocks.19.attn.to_k.weight": "diffusion_pytorch_model-00001-of-00002.safetensors",
178
+ "transformer_blocks.19.attn.to_out.0.weight": "diffusion_pytorch_model-00001-of-00002.safetensors",
179
+ "transformer_blocks.19.attn.to_q.weight": "diffusion_pytorch_model-00001-of-00002.safetensors",
180
+ "transformer_blocks.19.attn.to_v.weight": "diffusion_pytorch_model-00001-of-00002.safetensors",
181
+ "transformer_blocks.19.img_mlp.gate_layer.weight": "diffusion_pytorch_model-00001-of-00002.safetensors",
182
+ "transformer_blocks.19.img_mlp.out.weight": "diffusion_pytorch_model-00001-of-00002.safetensors",
183
+ "transformer_blocks.19.img_mlp.proj.weight": "diffusion_pytorch_model-00001-of-00002.safetensors",
184
+ "transformer_blocks.2.attn.norm_k.weight": "diffusion_pytorch_model-00001-of-00002.safetensors",
185
+ "transformer_blocks.2.attn.norm_q.weight": "diffusion_pytorch_model-00001-of-00002.safetensors",
186
+ "transformer_blocks.2.attn.to_k.weight": "diffusion_pytorch_model-00001-of-00002.safetensors",
187
+ "transformer_blocks.2.attn.to_out.0.weight": "diffusion_pytorch_model-00001-of-00002.safetensors",
188
+ "transformer_blocks.2.attn.to_q.weight": "diffusion_pytorch_model-00001-of-00002.safetensors",
189
+ "transformer_blocks.2.attn.to_v.weight": "diffusion_pytorch_model-00001-of-00002.safetensors",
190
+ "transformer_blocks.2.img_mlp.gate_layer.weight": "diffusion_pytorch_model-00001-of-00002.safetensors",
191
+ "transformer_blocks.2.img_mlp.out.weight": "diffusion_pytorch_model-00001-of-00002.safetensors",
192
+ "transformer_blocks.2.img_mlp.proj.weight": "diffusion_pytorch_model-00001-of-00002.safetensors",
193
+ "transformer_blocks.20.attn.norm_k.weight": "diffusion_pytorch_model-00001-of-00002.safetensors",
194
+ "transformer_blocks.20.attn.norm_q.weight": "diffusion_pytorch_model-00001-of-00002.safetensors",
195
+ "transformer_blocks.20.attn.to_k.weight": "diffusion_pytorch_model-00001-of-00002.safetensors",
196
+ "transformer_blocks.20.attn.to_out.0.weight": "diffusion_pytorch_model-00001-of-00002.safetensors",
197
+ "transformer_blocks.20.attn.to_q.weight": "diffusion_pytorch_model-00001-of-00002.safetensors",
198
+ "transformer_blocks.20.attn.to_v.weight": "diffusion_pytorch_model-00001-of-00002.safetensors",
199
+ "transformer_blocks.20.img_mlp.gate_layer.weight": "diffusion_pytorch_model-00001-of-00002.safetensors",
200
+ "transformer_blocks.20.img_mlp.out.weight": "diffusion_pytorch_model-00001-of-00002.safetensors",
201
+ "transformer_blocks.20.img_mlp.proj.weight": "diffusion_pytorch_model-00001-of-00002.safetensors",
202
+ "transformer_blocks.21.attn.norm_k.weight": "diffusion_pytorch_model-00001-of-00002.safetensors",
203
+ "transformer_blocks.21.attn.norm_q.weight": "diffusion_pytorch_model-00001-of-00002.safetensors",
204
+ "transformer_blocks.21.attn.to_k.weight": "diffusion_pytorch_model-00001-of-00002.safetensors",
205
+ "transformer_blocks.21.attn.to_out.0.weight": "diffusion_pytorch_model-00001-of-00002.safetensors",
206
+ "transformer_blocks.21.attn.to_q.weight": "diffusion_pytorch_model-00001-of-00002.safetensors",
207
+ "transformer_blocks.21.attn.to_v.weight": "diffusion_pytorch_model-00001-of-00002.safetensors",
208
+ "transformer_blocks.21.img_mlp.gate_layer.weight": "diffusion_pytorch_model-00001-of-00002.safetensors",
209
+ "transformer_blocks.21.img_mlp.out.weight": "diffusion_pytorch_model-00001-of-00002.safetensors",
210
+ "transformer_blocks.21.img_mlp.proj.weight": "diffusion_pytorch_model-00001-of-00002.safetensors",
211
+ "transformer_blocks.22.attn.norm_k.weight": "diffusion_pytorch_model-00001-of-00002.safetensors",
212
+ "transformer_blocks.22.attn.norm_q.weight": "diffusion_pytorch_model-00001-of-00002.safetensors",
213
+ "transformer_blocks.22.attn.to_k.weight": "diffusion_pytorch_model-00001-of-00002.safetensors",
214
+ "transformer_blocks.22.attn.to_out.0.weight": "diffusion_pytorch_model-00001-of-00002.safetensors",
215
+ "transformer_blocks.22.attn.to_q.weight": "diffusion_pytorch_model-00001-of-00002.safetensors",
216
+ "transformer_blocks.22.attn.to_v.weight": "diffusion_pytorch_model-00001-of-00002.safetensors",
217
+ "transformer_blocks.3.attn.norm_k.weight": "diffusion_pytorch_model-00001-of-00002.safetensors",
218
+ "transformer_blocks.3.attn.norm_q.weight": "diffusion_pytorch_model-00001-of-00002.safetensors",
219
+ "transformer_blocks.3.attn.to_k.weight": "diffusion_pytorch_model-00001-of-00002.safetensors",
220
+ "transformer_blocks.3.attn.to_out.0.weight": "diffusion_pytorch_model-00001-of-00002.safetensors",
221
+ "transformer_blocks.3.attn.to_q.weight": "diffusion_pytorch_model-00001-of-00002.safetensors",
222
+ "transformer_blocks.3.attn.to_v.weight": "diffusion_pytorch_model-00001-of-00002.safetensors",
223
+ "transformer_blocks.3.img_mlp.gate_layer.weight": "diffusion_pytorch_model-00001-of-00002.safetensors",
224
+ "transformer_blocks.3.img_mlp.out.weight": "diffusion_pytorch_model-00001-of-00002.safetensors",
225
+ "transformer_blocks.3.img_mlp.proj.weight": "diffusion_pytorch_model-00001-of-00002.safetensors",
226
+ "transformer_blocks.4.attn.norm_k.weight": "diffusion_pytorch_model-00001-of-00002.safetensors",
227
+ "transformer_blocks.4.attn.norm_q.weight": "diffusion_pytorch_model-00001-of-00002.safetensors",
228
+ "transformer_blocks.4.attn.to_k.weight": "diffusion_pytorch_model-00001-of-00002.safetensors",
229
+ "transformer_blocks.4.attn.to_out.0.weight": "diffusion_pytorch_model-00001-of-00002.safetensors",
230
+ "transformer_blocks.4.attn.to_q.weight": "diffusion_pytorch_model-00001-of-00002.safetensors",
231
+ "transformer_blocks.4.attn.to_v.weight": "diffusion_pytorch_model-00001-of-00002.safetensors",
232
+ "transformer_blocks.4.img_mlp.gate_layer.weight": "diffusion_pytorch_model-00001-of-00002.safetensors",
233
+ "transformer_blocks.4.img_mlp.out.weight": "diffusion_pytorch_model-00001-of-00002.safetensors",
234
+ "transformer_blocks.4.img_mlp.proj.weight": "diffusion_pytorch_model-00001-of-00002.safetensors",
235
+ "transformer_blocks.5.attn.norm_k.weight": "diffusion_pytorch_model-00001-of-00002.safetensors",
236
+ "transformer_blocks.5.attn.norm_q.weight": "diffusion_pytorch_model-00001-of-00002.safetensors",
237
+ "transformer_blocks.5.attn.to_k.weight": "diffusion_pytorch_model-00001-of-00002.safetensors",
238
+ "transformer_blocks.5.attn.to_out.0.weight": "diffusion_pytorch_model-00001-of-00002.safetensors",
239
+ "transformer_blocks.5.attn.to_q.weight": "diffusion_pytorch_model-00001-of-00002.safetensors",
240
+ "transformer_blocks.5.attn.to_v.weight": "diffusion_pytorch_model-00001-of-00002.safetensors",
241
+ "transformer_blocks.5.img_mlp.gate_layer.weight": "diffusion_pytorch_model-00001-of-00002.safetensors",
242
+ "transformer_blocks.5.img_mlp.out.weight": "diffusion_pytorch_model-00001-of-00002.safetensors",
243
+ "transformer_blocks.5.img_mlp.proj.weight": "diffusion_pytorch_model-00001-of-00002.safetensors",
244
+ "transformer_blocks.6.attn.norm_k.weight": "diffusion_pytorch_model-00001-of-00002.safetensors",
245
+ "transformer_blocks.6.attn.norm_q.weight": "diffusion_pytorch_model-00001-of-00002.safetensors",
246
+ "transformer_blocks.6.attn.to_k.weight": "diffusion_pytorch_model-00001-of-00002.safetensors",
247
+ "transformer_blocks.6.attn.to_out.0.weight": "diffusion_pytorch_model-00001-of-00002.safetensors",
248
+ "transformer_blocks.6.attn.to_q.weight": "diffusion_pytorch_model-00001-of-00002.safetensors",
249
+ "transformer_blocks.6.attn.to_v.weight": "diffusion_pytorch_model-00001-of-00002.safetensors",
250
+ "transformer_blocks.6.img_mlp.gate_layer.weight": "diffusion_pytorch_model-00001-of-00002.safetensors",
251
+ "transformer_blocks.6.img_mlp.out.weight": "diffusion_pytorch_model-00001-of-00002.safetensors",
252
+ "transformer_blocks.6.img_mlp.proj.weight": "diffusion_pytorch_model-00001-of-00002.safetensors",
253
+ "transformer_blocks.7.attn.norm_k.weight": "diffusion_pytorch_model-00001-of-00002.safetensors",
254
+ "transformer_blocks.7.attn.norm_q.weight": "diffusion_pytorch_model-00001-of-00002.safetensors",
255
+ "transformer_blocks.7.attn.to_k.weight": "diffusion_pytorch_model-00001-of-00002.safetensors",
256
+ "transformer_blocks.7.attn.to_out.0.weight": "diffusion_pytorch_model-00001-of-00002.safetensors",
257
+ "transformer_blocks.7.attn.to_q.weight": "diffusion_pytorch_model-00001-of-00002.safetensors",
258
+ "transformer_blocks.7.attn.to_v.weight": "diffusion_pytorch_model-00001-of-00002.safetensors",
259
+ "transformer_blocks.7.img_mlp.gate_layer.weight": "diffusion_pytorch_model-00001-of-00002.safetensors",
260
+ "transformer_blocks.7.img_mlp.out.weight": "diffusion_pytorch_model-00001-of-00002.safetensors",
261
+ "transformer_blocks.7.img_mlp.proj.weight": "diffusion_pytorch_model-00001-of-00002.safetensors",
262
+ "transformer_blocks.8.attn.norm_k.weight": "diffusion_pytorch_model-00001-of-00002.safetensors",
263
+ "transformer_blocks.8.attn.norm_q.weight": "diffusion_pytorch_model-00001-of-00002.safetensors",
264
+ "transformer_blocks.8.attn.to_k.weight": "diffusion_pytorch_model-00001-of-00002.safetensors",
265
+ "transformer_blocks.8.attn.to_out.0.weight": "diffusion_pytorch_model-00001-of-00002.safetensors",
266
+ "transformer_blocks.8.attn.to_q.weight": "diffusion_pytorch_model-00001-of-00002.safetensors",
267
+ "transformer_blocks.8.attn.to_v.weight": "diffusion_pytorch_model-00001-of-00002.safetensors",
268
+ "transformer_blocks.8.img_mlp.gate_layer.weight": "diffusion_pytorch_model-00001-of-00002.safetensors",
269
+ "transformer_blocks.8.img_mlp.out.weight": "diffusion_pytorch_model-00001-of-00002.safetensors",
270
+ "transformer_blocks.8.img_mlp.proj.weight": "diffusion_pytorch_model-00001-of-00002.safetensors",
271
+ "transformer_blocks.9.attn.norm_k.weight": "diffusion_pytorch_model-00001-of-00002.safetensors",
272
+ "transformer_blocks.9.attn.norm_q.weight": "diffusion_pytorch_model-00001-of-00002.safetensors",
273
+ "transformer_blocks.9.attn.to_k.weight": "diffusion_pytorch_model-00001-of-00002.safetensors",
274
+ "transformer_blocks.9.attn.to_out.0.weight": "diffusion_pytorch_model-00001-of-00002.safetensors",
275
+ "transformer_blocks.9.attn.to_q.weight": "diffusion_pytorch_model-00001-of-00002.safetensors",
276
+ "transformer_blocks.9.attn.to_v.weight": "diffusion_pytorch_model-00001-of-00002.safetensors",
277
+ "transformer_blocks.9.img_mlp.gate_layer.weight": "diffusion_pytorch_model-00001-of-00002.safetensors",
278
+ "transformer_blocks.9.img_mlp.out.weight": "diffusion_pytorch_model-00001-of-00002.safetensors",
279
+ "transformer_blocks.9.img_mlp.proj.weight": "diffusion_pytorch_model-00001-of-00002.safetensors",
280
+ "txt_in.in_layer.weight": "diffusion_pytorch_model-00001-of-00002.safetensors",
281
+ "txt_in.out_layer.weight": "diffusion_pytorch_model-00001-of-00002.safetensors",
282
+ "txt_in.text_norm.weight": "diffusion_pytorch_model-00001-of-00002.safetensors",
283
+ "norm_out.linear.weight": "diffusion_pytorch_model-00002-of-00002.safetensors",
284
+ "proj_out.weight": "diffusion_pytorch_model-00002-of-00002.safetensors",
285
+ "transformer_blocks.22.img_mlp.gate_layer.weight": "diffusion_pytorch_model-00002-of-00002.safetensors",
286
+ "transformer_blocks.22.img_mlp.out.weight": "diffusion_pytorch_model-00002-of-00002.safetensors",
287
+ "transformer_blocks.22.img_mlp.proj.weight": "diffusion_pytorch_model-00002-of-00002.safetensors",
288
+ "transformer_blocks.23.attn.norm_k.weight": "diffusion_pytorch_model-00002-of-00002.safetensors",
289
+ "transformer_blocks.23.attn.norm_q.weight": "diffusion_pytorch_model-00002-of-00002.safetensors",
290
+ "transformer_blocks.23.attn.to_k.weight": "diffusion_pytorch_model-00002-of-00002.safetensors",
291
+ "transformer_blocks.23.attn.to_out.0.weight": "diffusion_pytorch_model-00002-of-00002.safetensors",
292
+ "transformer_blocks.23.attn.to_q.weight": "diffusion_pytorch_model-00002-of-00002.safetensors",
293
+ "transformer_blocks.23.attn.to_v.weight": "diffusion_pytorch_model-00002-of-00002.safetensors",
294
+ "transformer_blocks.23.img_mlp.gate_layer.weight": "diffusion_pytorch_model-00002-of-00002.safetensors",
295
+ "transformer_blocks.23.img_mlp.out.weight": "diffusion_pytorch_model-00002-of-00002.safetensors",
296
+ "transformer_blocks.23.img_mlp.proj.weight": "diffusion_pytorch_model-00002-of-00002.safetensors",
297
+ "transformer_blocks.24.attn.norm_k.weight": "diffusion_pytorch_model-00002-of-00002.safetensors",
298
+ "transformer_blocks.24.attn.norm_q.weight": "diffusion_pytorch_model-00002-of-00002.safetensors",
299
+ "transformer_blocks.24.attn.to_k.weight": "diffusion_pytorch_model-00002-of-00002.safetensors",
300
+ "transformer_blocks.24.attn.to_out.0.weight": "diffusion_pytorch_model-00002-of-00002.safetensors",
301
+ "transformer_blocks.24.attn.to_q.weight": "diffusion_pytorch_model-00002-of-00002.safetensors",
302
+ "transformer_blocks.24.attn.to_v.weight": "diffusion_pytorch_model-00002-of-00002.safetensors",
303
+ "transformer_blocks.24.img_mlp.gate_layer.weight": "diffusion_pytorch_model-00002-of-00002.safetensors",
304
+ "transformer_blocks.24.img_mlp.out.weight": "diffusion_pytorch_model-00002-of-00002.safetensors",
305
+ "transformer_blocks.24.img_mlp.proj.weight": "diffusion_pytorch_model-00002-of-00002.safetensors",
306
+ "transformer_blocks.25.attn.norm_k.weight": "diffusion_pytorch_model-00002-of-00002.safetensors",
307
+ "transformer_blocks.25.attn.norm_q.weight": "diffusion_pytorch_model-00002-of-00002.safetensors",
308
+ "transformer_blocks.25.attn.to_k.weight": "diffusion_pytorch_model-00002-of-00002.safetensors",
309
+ "transformer_blocks.25.attn.to_out.0.weight": "diffusion_pytorch_model-00002-of-00002.safetensors",
310
+ "transformer_blocks.25.attn.to_q.weight": "diffusion_pytorch_model-00002-of-00002.safetensors",
311
+ "transformer_blocks.25.attn.to_v.weight": "diffusion_pytorch_model-00002-of-00002.safetensors",
312
+ "transformer_blocks.25.img_mlp.gate_layer.weight": "diffusion_pytorch_model-00002-of-00002.safetensors",
313
+ "transformer_blocks.25.img_mlp.out.weight": "diffusion_pytorch_model-00002-of-00002.safetensors",
314
+ "transformer_blocks.25.img_mlp.proj.weight": "diffusion_pytorch_model-00002-of-00002.safetensors",
315
+ "transformer_blocks.26.attn.norm_k.weight": "diffusion_pytorch_model-00002-of-00002.safetensors",
316
+ "transformer_blocks.26.attn.norm_q.weight": "diffusion_pytorch_model-00002-of-00002.safetensors",
317
+ "transformer_blocks.26.attn.to_k.weight": "diffusion_pytorch_model-00002-of-00002.safetensors",
318
+ "transformer_blocks.26.attn.to_out.0.weight": "diffusion_pytorch_model-00002-of-00002.safetensors",
319
+ "transformer_blocks.26.attn.to_q.weight": "diffusion_pytorch_model-00002-of-00002.safetensors",
320
+ "transformer_blocks.26.attn.to_v.weight": "diffusion_pytorch_model-00002-of-00002.safetensors",
321
+ "transformer_blocks.26.img_mlp.gate_layer.weight": "diffusion_pytorch_model-00002-of-00002.safetensors",
322
+ "transformer_blocks.26.img_mlp.out.weight": "diffusion_pytorch_model-00002-of-00002.safetensors",
323
+ "transformer_blocks.26.img_mlp.proj.weight": "diffusion_pytorch_model-00002-of-00002.safetensors",
324
+ "transformer_blocks.27.attn.norm_k.weight": "diffusion_pytorch_model-00002-of-00002.safetensors",
325
+ "transformer_blocks.27.attn.norm_q.weight": "diffusion_pytorch_model-00002-of-00002.safetensors",
326
+ "transformer_blocks.27.attn.to_k.weight": "diffusion_pytorch_model-00002-of-00002.safetensors",
327
+ "transformer_blocks.27.attn.to_out.0.weight": "diffusion_pytorch_model-00002-of-00002.safetensors",
328
+ "transformer_blocks.27.attn.to_q.weight": "diffusion_pytorch_model-00002-of-00002.safetensors",
329
+ "transformer_blocks.27.attn.to_v.weight": "diffusion_pytorch_model-00002-of-00002.safetensors",
330
+ "transformer_blocks.27.img_mlp.gate_layer.weight": "diffusion_pytorch_model-00002-of-00002.safetensors",
331
+ "transformer_blocks.27.img_mlp.out.weight": "diffusion_pytorch_model-00002-of-00002.safetensors",
332
+ "transformer_blocks.27.img_mlp.proj.weight": "diffusion_pytorch_model-00002-of-00002.safetensors",
333
+ "transformer_blocks.28.attn.norm_k.weight": "diffusion_pytorch_model-00002-of-00002.safetensors",
334
+ "transformer_blocks.28.attn.norm_q.weight": "diffusion_pytorch_model-00002-of-00002.safetensors",
335
+ "transformer_blocks.28.attn.to_k.weight": "diffusion_pytorch_model-00002-of-00002.safetensors",
336
+ "transformer_blocks.28.attn.to_out.0.weight": "diffusion_pytorch_model-00002-of-00002.safetensors",
337
+ "transformer_blocks.28.attn.to_q.weight": "diffusion_pytorch_model-00002-of-00002.safetensors",
338
+ "transformer_blocks.28.attn.to_v.weight": "diffusion_pytorch_model-00002-of-00002.safetensors",
339
+ "transformer_blocks.28.img_mlp.gate_layer.weight": "diffusion_pytorch_model-00002-of-00002.safetensors",
340
+ "transformer_blocks.28.img_mlp.out.weight": "diffusion_pytorch_model-00002-of-00002.safetensors",
341
+ "transformer_blocks.28.img_mlp.proj.weight": "diffusion_pytorch_model-00002-of-00002.safetensors",
342
+ "transformer_blocks.29.attn.norm_k.weight": "diffusion_pytorch_model-00002-of-00002.safetensors",
343
+ "transformer_blocks.29.attn.norm_q.weight": "diffusion_pytorch_model-00002-of-00002.safetensors",
344
+ "transformer_blocks.29.attn.to_k.weight": "diffusion_pytorch_model-00002-of-00002.safetensors",
345
+ "transformer_blocks.29.attn.to_out.0.weight": "diffusion_pytorch_model-00002-of-00002.safetensors",
346
+ "transformer_blocks.29.attn.to_q.weight": "diffusion_pytorch_model-00002-of-00002.safetensors",
347
+ "transformer_blocks.29.attn.to_v.weight": "diffusion_pytorch_model-00002-of-00002.safetensors",
348
+ "transformer_blocks.29.img_mlp.gate_layer.weight": "diffusion_pytorch_model-00002-of-00002.safetensors",
349
+ "transformer_blocks.29.img_mlp.out.weight": "diffusion_pytorch_model-00002-of-00002.safetensors",
350
+ "transformer_blocks.29.img_mlp.proj.weight": "diffusion_pytorch_model-00002-of-00002.safetensors",
351
+ "transformer_blocks.30.attn.norm_k.weight": "diffusion_pytorch_model-00002-of-00002.safetensors",
352
+ "transformer_blocks.30.attn.norm_q.weight": "diffusion_pytorch_model-00002-of-00002.safetensors",
353
+ "transformer_blocks.30.attn.to_k.weight": "diffusion_pytorch_model-00002-of-00002.safetensors",
354
+ "transformer_blocks.30.attn.to_out.0.weight": "diffusion_pytorch_model-00002-of-00002.safetensors",
355
+ "transformer_blocks.30.attn.to_q.weight": "diffusion_pytorch_model-00002-of-00002.safetensors",
356
+ "transformer_blocks.30.attn.to_v.weight": "diffusion_pytorch_model-00002-of-00002.safetensors",
357
+ "transformer_blocks.30.img_mlp.gate_layer.weight": "diffusion_pytorch_model-00002-of-00002.safetensors",
358
+ "transformer_blocks.30.img_mlp.out.weight": "diffusion_pytorch_model-00002-of-00002.safetensors",
359
+ "transformer_blocks.30.img_mlp.proj.weight": "diffusion_pytorch_model-00002-of-00002.safetensors",
360
+ "transformer_blocks.31.attn.norm_k.weight": "diffusion_pytorch_model-00002-of-00002.safetensors",
361
+ "transformer_blocks.31.attn.norm_q.weight": "diffusion_pytorch_model-00002-of-00002.safetensors",
362
+ "transformer_blocks.31.attn.to_k.weight": "diffusion_pytorch_model-00002-of-00002.safetensors",
363
+ "transformer_blocks.31.attn.to_out.0.weight": "diffusion_pytorch_model-00002-of-00002.safetensors",
364
+ "transformer_blocks.31.attn.to_q.weight": "diffusion_pytorch_model-00002-of-00002.safetensors",
365
+ "transformer_blocks.31.attn.to_v.weight": "diffusion_pytorch_model-00002-of-00002.safetensors",
366
+ "transformer_blocks.31.img_mlp.gate_layer.weight": "diffusion_pytorch_model-00002-of-00002.safetensors",
367
+ "transformer_blocks.31.img_mlp.out.weight": "diffusion_pytorch_model-00002-of-00002.safetensors",
368
+ "transformer_blocks.31.img_mlp.proj.weight": "diffusion_pytorch_model-00002-of-00002.safetensors"
369
+ }
370
+ }
vae/config.json ADDED
@@ -0,0 +1,161 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "_class_name": "AutoencoderKLQwenImage21",
3
+ "_diffusers_version": "0.37.0.dev0",
4
+ "attn_scales": [],
5
+ "base_dim": 96,
6
+ "decoder_base_dim": 144,
7
+ "dim_mult": [
8
+ 1,
9
+ 2,
10
+ 4,
11
+ 8,
12
+ 8
13
+ ],
14
+ "dropout": 0.0,
15
+ "in_channels": 4,
16
+ "is_residual": true,
17
+ "latents_mean": [
18
+ 0.5126,
19
+ 0.7721,
20
+ -0.0631,
21
+ 1.3506,
22
+ -0.7855,
23
+ -2.1025,
24
+ -0.3458,
25
+ 1.3722,
26
+ 1.8873,
27
+ -1.7177,
28
+ -0.651,
29
+ 0.2732,
30
+ 0.7562,
31
+ -0.6163,
32
+ -1.0277,
33
+ 3.8363,
34
+ 2.021,
35
+ 0.0472,
36
+ 0.932,
37
+ 2.0087,
38
+ 2.4954,
39
+ -0.1391,
40
+ -1.4249,
41
+ 1.8464,
42
+ -0.5236,
43
+ 1.2826,
44
+ 3.7046,
45
+ -1.3035,
46
+ 2.7286,
47
+ -1.4518,
48
+ -1.9036,
49
+ -1.9955,
50
+ -0.0342,
51
+ -1.0265,
52
+ -0.7636,
53
+ 3.0555,
54
+ 0.0746,
55
+ -3.0751,
56
+ -0.1076,
57
+ 1.7376,
58
+ -1.0914,
59
+ -1.9435,
60
+ -0.2784,
61
+ -1.368,
62
+ 0.4809,
63
+ -0.4433,
64
+ 0.3764,
65
+ 0.5729,
66
+ -2.0595,
67
+ 1.096,
68
+ -1.326,
69
+ -2.0211,
70
+ -5.0179,
71
+ 0.5275,
72
+ 4.0162,
73
+ 1.8505,
74
+ 0.3026,
75
+ 1.9373,
76
+ 1.4937,
77
+ 0.2632,
78
+ 0.5547,
79
+ -1.7121,
80
+ -0.1562,
81
+ 0.0304
82
+ ],
83
+ "latents_std": [
84
+ 3.2001,
85
+ 3.2936,
86
+ 3.4321,
87
+ 3.0091,
88
+ 3.1061,
89
+ 4.0379,
90
+ 4.0705,
91
+ 3.791,
92
+ 3.0785,
93
+ 3.65,
94
+ 3.9308,
95
+ 3.0904,
96
+ 2.8778,
97
+ 3.7675,
98
+ 3.732,
99
+ 5.0756,
100
+ 3.2864,
101
+ 4.0397,
102
+ 3.1317,
103
+ 4.0443,
104
+ 2.9249,
105
+ 3.9454,
106
+ 3.0988,
107
+ 4.2489,
108
+ 3.4896,
109
+ 3.8513,
110
+ 3.9323,
111
+ 3.4719,
112
+ 3.7498,
113
+ 4.283,
114
+ 3.5694,
115
+ 4.2467,
116
+ 3.9037,
117
+ 3.2947,
118
+ 5.077,
119
+ 3.5075,
120
+ 3.27,
121
+ 3.4767,
122
+ 2.8063,
123
+ 5.1125,
124
+ 3.5327,
125
+ 4.7833,
126
+ 3.1286,
127
+ 4.1819,
128
+ 3.8527,
129
+ 3.8312,
130
+ 3.5605,
131
+ 4.3875,
132
+ 3.9624,
133
+ 4.0168,
134
+ 3.5643,
135
+ 4.055,
136
+ 5.5614,
137
+ 4.2963,
138
+ 4.408,
139
+ 3.4959,
140
+ 3.8747,
141
+ 3.7608,
142
+ 3.5735,
143
+ 3.149,
144
+ 3.7662,
145
+ 3.6746,
146
+ 3.4563,
147
+ 3.8161
148
+ ],
149
+ "num_res_blocks": 2,
150
+ "out_channels": 4,
151
+ "patch_size": null,
152
+ "scale_factor_spatial": 16,
153
+ "scale_factor_temporal": 8,
154
+ "temperal_downsample": [
155
+ false,
156
+ true,
157
+ true,
158
+ true
159
+ ],
160
+ "z_dim": 64
161
+ }
vae/diffusion_pytorch_model.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:a07a1b7c4ee2966a1b3bdc37de9b4f983d56937e46619f709a80b6e490675417
3
+ size 1350989512