English
Zhiminli commited on
Commit
96c8857
1 Parent(s): 38e7c3c

Upload folder using huggingface_hub

Browse files
.gitattributes CHANGED
@@ -33,3 +33,6 @@ 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
+ asset/output/canny.jpg filter=lfs diff=lfs merge=lfs -text
37
+ asset/output/depth.jpg filter=lfs diff=lfs merge=lfs -text
38
+ asset/output/pose.jpg filter=lfs diff=lfs merge=lfs -text
README.md ADDED
@@ -0,0 +1,257 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ ## Using HunyuanDiT ControlNet
3
+
4
+
5
+ ### Instructions
6
+
7
+ The dependencies and installation are basically the same as the [**base model**](https://huggingface.co/Tencent-Hunyuan/HunyuanDiT-v1.1).
8
+
9
+ We provide three types of ControlNet weights for you to test: canny, depth and pose ControlNet.
10
+
11
+ Download the model using the following commands:
12
+
13
+ ```bash
14
+ cd HunyuanDiT
15
+ # Use the huggingface-cli tool to download the model.
16
+ # We recommend using distilled weights as the base model for ControlNet inference, as our provided pretrained weights are trained on them.
17
+ huggingface-cli download Tencent-Hunyuan/HYDiT-ControlNet-v1.2 --local-dir ./ckpts/t2i/controlnet
18
+ huggingface-cli download Tencent-Hunyuan/Distillation-v1.2 ./pytorch_model_distill.pt --local-dir ./ckpts/t2i/model
19
+
20
+ # Quick start
21
+ python3 sample_controlnet.py --no-enhance --load-key distill --infer-steps 50 --control-type canny --prompt "在夜晚的酒店门前,一座古老的中国风格的狮子雕像矗立着,它的眼睛闪烁着光芒,仿佛在守护着这座建筑。背景是夜晚的酒店前,构图方式是特写,平视,居中构图。这张照片呈现了真实摄影风格,蕴含了中国雕塑文化,同时展现了神秘氛围" --condition-image-path controlnet/asset/input/canny.jpg --control-weight 1.0 --infer-mode fa
22
+ ```
23
+
24
+ Examples of condition input and ControlNet results are as follows:
25
+ <table>
26
+ <tr>
27
+ <td colspan="3" align="center">Condition Input</td>
28
+ </tr>
29
+
30
+ <tr>
31
+ <td align="center">Canny ControlNet </td>
32
+ <td align="center">Depth ControlNet </td>
33
+ <td align="center">Pose ControlNet </td>
34
+ </tr>
35
+
36
+ <tr>
37
+ <td align="center">在夜晚的酒店门前,一座古老的中国风格的狮子雕像矗立着,它的眼睛闪烁着光芒,仿佛在守护着这座建筑。背景是夜晚的酒店前,构图方式是特写,平视,居中构图。这张照片呈现了真实摄影风格,蕴含了中国雕塑文化,同时展现了神秘氛围<br>(At night, an ancient Chinese-style lion statue stands in front of the hotel, its eyes gleaming as if guarding the building. The background is the hotel entrance at night, with a close-up, eye-level, and centered composition. This photo presents a realistic photographic style, embodies Chinese sculpture culture, and reveals a mysterious atmosphere.) </td>
38
+ <td align="center">在茂密的森林中,一只黑白相间的熊猫静静地坐在绿树红花中,周围是山川和海洋。背景是白天的森林,光线充足。照片采用特写、平视和居中构图的方式,呈现出写实的效果<br>(In the dense forest, a black and white panda sits quietly among the green trees and red flowers, surrounded by mountains and oceans. The background is a daytime forest with ample light. The photo uses a close-up, eye-level, and centered composition to create a realistic effect.) </td>
39
+ <td align="center">在白天的森林中,一位穿着绿色上衣的亚洲女性站在大象旁边。照片采用了中景、平视和居中构图的方式,呈现出写实的效果。这张照片蕴含了人物摄影文化,并展现了宁静的氛围<br>(In the daytime forest, an Asian woman wearing a green shirt stands beside an elephant. The photo uses a medium shot, eye-level, and centered composition to create a realistic effect. This picture embodies the character photography culture and conveys a serene atmosphere.) </td>
40
+ </tr>
41
+
42
+ <tr>
43
+ <td align="center"><img src="asset/input/canny.jpg" alt="Image 0" width="200"/></td>
44
+ <td align="center"><img src="asset/input/depth.jpg" alt="Image 1" width="200"/></td>
45
+ <td align="center"><img src="asset/input/pose.jpg" alt="Image 2" width="200"/></td>
46
+
47
+ </tr>
48
+
49
+ <tr>
50
+ <td colspan="3" align="center">ControlNet Output</td>
51
+ </tr>
52
+
53
+ <tr>
54
+ <td align="center"><img src="asset/output/canny.jpg" alt="Image 3" width="200"/></td>
55
+ <td align="center"><img src="asset/output/depth.jpg" alt="Image 4" width="200"/></td>
56
+ <td align="center"><img src="asset/output/pose.jpg" alt="Image 5" width="200"/></td>
57
+ </tr>
58
+
59
+
60
+ </table>
61
+
62
+
63
+ ### Training
64
+
65
+ We utilize [**DWPose**](https://github.com/IDEA-Research/DWPose) for pose extraction. Please follow their guidelines to download the checkpoints and save them to `hydit/annotator/ckpts` directory. We provide serveral commands to quick install:
66
+ ```bash
67
+ mkdir ./hydit/annotator/ckpts
68
+ wget -O ./hydit/annotator/ckpts/dwpose.zip https://dit.hunyuan.tencent.com/download/HunyuanDiT/dwpose.zip
69
+ unzip ./hydit/annotator/ckpts/dwpose.zip -d ./hydit/annotator/ckpts/
70
+ ```
71
+ Additionally, ensure that you install the related dependencies.
72
+ ```bash
73
+ pip install matplotlib==3.7.5
74
+ pip install onnxruntime_gpu==1.16.3
75
+ pip install opencv-python==4.8.1.78
76
+ ```
77
+
78
+
79
+ We provide three types of weights for ControlNet training, `ema`, `module` and `distill`, and you can choose according to the actual effects. By default, we use `distill` weights.
80
+
81
+ Here is an example, we load the `distill` weights into the main model and conduct ControlNet training.
82
+
83
+ If you want to load the `module` weights into the main model, just remove the `--ema-to-module` parameter.
84
+
85
+ If apply multiple resolution training, you need to add the `--multireso` and `--reso-step 64` parameter.
86
+
87
+ ```bash
88
+ task_flag="canny_controlnet" # task flag is used to identify folders.
89
+ control_type=canny
90
+ resume=./ckpts/t2i/model/ # checkpoint root for resume
91
+ index_file=path/to/your/index_file
92
+ results_dir=./log_EXP # save root for results
93
+ batch_size=1 # training batch size
94
+ image_size=1024 # training image resolution
95
+ grad_accu_steps=2 # gradient accumulation
96
+ warmup_num_steps=0 # warm-up steps
97
+ lr=0.0001 # learning rate
98
+ ckpt_every=10000 # create a ckpt every a few steps.
99
+ ckpt_latest_every=5000 # create a ckpt named `latest.pt` every a few steps.
100
+
101
+
102
+ sh $(dirname "$0")/run_g_controlnet.sh \
103
+ --task-flag ${task_flag} \
104
+ --control-type ${control_type} \
105
+ --noise-schedule scaled_linear --beta-start 0.00085 --beta-end 0.03 \
106
+ --predict-type v_prediction \
107
+ --multireso \
108
+ --reso-step 64 \
109
+ --ema-to-module \
110
+ --uncond-p 0.44 \
111
+ --uncond-p-t5 0.44 \
112
+ --index-file ${index_file} \
113
+ --random-flip \
114
+ --lr ${lr} \
115
+ --batch-size ${batch_size} \
116
+ --image-size ${image_size} \
117
+ --global-seed 999 \
118
+ --grad-accu-steps ${grad_accu_steps} \
119
+ --warmup-num-steps ${warmup_num_steps} \
120
+ --use-flash-attn \
121
+ --use-fp16 \
122
+ --use-ema \
123
+ --ema-dtype fp32 \
124
+ --results-dir ${results_dir} \
125
+ --resume-split \
126
+ --resume ${resume} \
127
+ --ckpt-every ${ckpt_every} \
128
+ --ckpt-latest-every ${ckpt_latest_every} \
129
+ --log-every 10 \
130
+ --deepspeed \
131
+ --deepspeed-optimizer \
132
+ --use-zero-stage 2 \
133
+ "$@"
134
+ ```
135
+
136
+ Recommended parameter settings
137
+
138
+ | Parameter | Description | Recommended Parameter Value | Note|
139
+ |:---------------:|:---------:|:---------------------------------------------------:|:--:|
140
+ | `--batch-size` | Training batch size | 1 | Depends on GPU memory|
141
+ | `--grad-accu-steps` | Size of gradient accumulation | 2 | - |
142
+ | `--lr` | Learning rate | 0.0001 | - |
143
+ | `--control-type` | ControlNet condition type, support 3 types now (canny, depth and pose) | / | - |
144
+
145
+
146
+ ### Inference
147
+ You can use the following command line for inference.
148
+
149
+ a. You can use a float to specify the weight for all layers, **or use a list to separately specify the weight for each layer**, for example, '[1.0 * (0.825 ** float(19 - i)) for i in range(19)]'
150
+ ```bash
151
+ python3 sample_controlnet.py --control-weight [1.0 * (0.825 ** float(19 - i)) for i in range(19)] --no-enhance --load-key distill --infer-steps 50 --control-type canny --prompt "在夜晚的酒店门前,一座古老的中国风格的狮子雕像矗立着,它的眼睛闪烁着光芒,仿佛在守护着这座建筑。背景是夜晚的酒店前,构图方式是特写,平视,居中构图。这张照片呈现了真实摄影风格,蕴含了中国雕塑文化,同时展现了神秘氛围" --condition-image-path controlnet/asset/input/canny.jpg --infer-mode fa
152
+ ```
153
+
154
+ b. Using canny ControlNet during inference
155
+
156
+ ```bash
157
+ python3 sample_controlnet.py --no-enhance --load-key distill --infer-steps 50 --control-type canny --prompt "在夜晚的酒店门前,一座古老的中国风格的狮子雕像矗立着,它的眼睛闪烁着光芒,仿佛在守护着这座建筑。背景是夜晚的酒店前,构图方式是特写,平视,居中构图。这张照片呈现了真实摄影风格,蕴含了中国雕塑文化,同时展现了神秘氛围" --condition-image-path controlnet/asset/input/canny.jpg --control-weight 1.0 --infer-mode fa
158
+ ```
159
+
160
+ c. Using depth ControlNet during inference
161
+
162
+ ```bash
163
+ python3 sample_controlnet.py --no-enhance --load-key distill --infer-steps 50 --control-type depth --prompt "在茂密的森林中,一只黑白相间的熊猫静静地坐在绿树红花中,周围是山川和海洋。背景是白天的森林,光线充足。照片采用特写、平视和居中构图的方式,呈现出写实的效果" --condition-image-path controlnet/asset/input/depth.jpg --control-weight 1.0 --infer-mode fa
164
+ ```
165
+
166
+ d. Using pose ControlNet during inference
167
+
168
+
169
+ ```bash
170
+ python3 sample_controlnet.py --no-enhance --load-key distill --infer-steps 50 --control-type pose --prompt "在白天的森林中,一位穿着绿色上衣的亚洲女性站在大象旁边。照片采用了中景、平视和居中构图的方式,呈现出写实的效果。这张照片蕴含了人物摄影文化,并展现了宁��的氛围" --condition-image-path controlnet/asset/input/pose.jpg --control-weight 1.0 --infer-mode fa
171
+ ```
172
+
173
+ ## HunyuanDiT Controlnet v1.1
174
+
175
+ ### Instructions
176
+ Download the v1.1 base model and controlnet using the following commands:
177
+ ```bash
178
+ cd HunyuanDiT
179
+ # Use the huggingface-cli tool to download the model.
180
+ # We recommend using distilled weights as the base model for ControlNet inference, as our provided pretrained weights are trained on them.
181
+ huggingface-cli download Tencent-Hunyuan/HYDiT-ControlNet-v1.1 --local-dir ./HunyuanDiT-v1.1/t2i/controlnet
182
+ huggingface-cli download Tencent-Hunyuan/Distillation-v1.1 ./pytorch_model_distill.pt --local-dir ./HunyuanDiT-v1.1/t2i/model
183
+ ```
184
+
185
+ ### Training
186
+
187
+ ```bash
188
+ task_flag="canny_controlnet" # the task flag is used to identify folders.
189
+ control_type=canny
190
+ resume=./HunyuanDiT-v1.1/t2i/model/ # checkpoint root for resume
191
+ index_file=/path/to/your/indexfile # index file for dataloader
192
+ results_dir=./log_EXP # save root for results
193
+ batch_size=1 # training batch size
194
+ image_size=1024 # training image resolution
195
+ grad_accu_steps=2 # gradient accumulation
196
+ warmup_num_steps=0 # warm-up steps
197
+ lr=0.0001 # learning rate
198
+ ckpt_every=10000 # create a ckpt every a few steps.
199
+ ckpt_latest_every=5000 # create a ckpt named `latest.pt` every a few steps.
200
+ epochs=100 # total training epochs
201
+
202
+
203
+ sh $(dirname "$0")/run_g_controlnet.sh \
204
+ --task-flag ${task_flag} \
205
+ --control-type ${control_type} \
206
+ --noise-schedule scaled_linear --beta-start 0.00085 --beta-end 0.03 \
207
+ --predict-type v_prediction \
208
+ --multireso \
209
+ --reso-step 64 \
210
+ --ema-to-module \
211
+ --uncond-p 0.44 \
212
+ --uncond-p-t5 0.44 \
213
+ --index-file ${index_file} \
214
+ --random-flip \
215
+ --lr ${lr} \
216
+ --batch-size ${batch_size} \
217
+ --image-size ${image_size} \
218
+ --global-seed 999 \
219
+ --grad-accu-steps ${grad_accu_steps} \
220
+ --warmup-num-steps ${warmup_num_steps} \
221
+ --use-flash-attn \
222
+ --use-fp16 \
223
+ --results-dir ${results_dir} \
224
+ --resume-split \
225
+ --resume ${resume} \
226
+ --epochs ${epochs} \
227
+ --ckpt-every ${ckpt_every} \
228
+ --ckpt-latest-every ${ckpt_latest_every} \
229
+ --log-every 10 \
230
+ --deepspeed \
231
+ --deepspeed-optimizer \
232
+ --use-zero-stage 2 \
233
+ --use-style-cond \
234
+ --size-cond 1024 1024 \
235
+ "$@"
236
+ ```
237
+
238
+ ### Inference
239
+ You can use the following command line for inference.
240
+
241
+ a. Using canny ControlNet during inference
242
+
243
+ ```bash
244
+ python3 sample_controlnet.py --no-enhance --load-key distill --infer-steps 50 --control-type canny --prompt "在夜晚的酒店门前,一座古老的中国风格的狮子雕像矗立着,它的眼睛闪烁着光芒,仿佛在守护着这座建筑。背景是夜晚的酒店前,构图方式是特写,平视,居中构图。这张照片呈现了真实摄影风格,蕴含了中国雕塑文化,同时展现了神秘氛围" --condition-image-path controlnet/asset/input/canny.jpg --control-weight 1.0 --use-style-cond --size-cond 1024 1024 --beta-end 0.03
245
+ ```
246
+
247
+ b. Using depth ControlNet during inference
248
+
249
+ ```bash
250
+ python3 sample_controlnet.py --no-enhance --load-key distill --infer-steps 50 --control-type depth --prompt "在茂密的森林中,一只黑白相间的熊猫静静地坐在绿树红花中,周围是山川和海洋。背景是白天的森林,光线充足" --condition-image-path controlnet/asset/input/depth.jpg --control-weight 1.0 --use-style-cond --size-cond 1024 1024 --beta-end 0.03
251
+ ```
252
+
253
+ c. Using pose ControlNet during inference
254
+
255
+ ```bash
256
+ python3 sample_controlnet.py --no-enhance --load-key distill --infer-steps 50 --control-type pose --prompt "一位亚洲女性,身穿绿色上衣,戴着紫色头巾和紫色围巾,站在黑板前。背景是黑板。照片采用近景、平视和居中构图的方式呈现真实摄影风格" --condition-image-path controlnet/asset/input/pose.jpg --control-weight 1.0 --use-style-cond --size-cond 1024 1024 --beta-end 0.03
257
+ ```
asset/input/canny.jpg ADDED
asset/input/depth.jpg ADDED
asset/input/pose.jpg ADDED
asset/output/canny.jpg ADDED

Git LFS Details

  • SHA256: ab42a933abd7b110bb9fa9b8511bd3dd808a3ed3ff2cb5f336acef62dcd75822
  • Pointer size: 132 Bytes
  • Size of remote file: 1.46 MB
asset/output/depth.jpg ADDED

Git LFS Details

  • SHA256: c2defc26b1f5553e751ebd7c5073e7b1ea7c8f76028e928193caf28c0f964016
  • Pointer size: 132 Bytes
  • Size of remote file: 1.43 MB
asset/output/pose.jpg ADDED

Git LFS Details

  • SHA256: ca6cf6910df13bb749f0328d7e9ea751fb479a925330d3de6147c04f904be7f1
  • Pointer size: 132 Bytes
  • Size of remote file: 1.63 MB
pytorch_model_canny_distill.pt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:ae48d18fcc116e4313ea1fdfc55ef7b35fa2b9a90b738a29d2ee33cf92111695
3
+ size 1488555446
pytorch_model_depth_distill.pt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:1fd40492dc16d61fd6ea0bdfc514e67c7a64a843c9479239ddbb61bb38e07bfc
3
+ size 1488555446
pytorch_model_pose_distill.pt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:0f5410e5c11ed166d328229d698b7eb4398b671e94ed4f2126fb1d10ed745b30
3
+ size 1488555419