vijayakumaran92 commited on
Commit
c5a22df
·
verified ·
1 Parent(s): e7273b8

Add files using upload-large-folder tool

Browse files
This view is limited to 50 files because it contains too many changes.   See raw diff
Files changed (50) hide show
  1. .gitattributes +52 -0
  2. ACE_plus/.gitignore +1 -0
  3. ACE_plus/README.md +600 -0
  4. ACE_plus/__init__.py +1 -0
  5. ACE_plus/demo_fft.py +545 -0
  6. ACE_plus/demo_lora.py +523 -0
  7. ACE_plus/infer_fft.py +178 -0
  8. ACE_plus/infer_lora.py +228 -0
  9. ACE_plus/install.py +27 -0
  10. ACE_plus/model_convert.py +194 -0
  11. ACE_plus/pyproject.toml +15 -0
  12. ACE_plus/repo_requirements.txt +8 -0
  13. ACE_plus/requirements.txt +0 -0
  14. ACE_plus/run_train.py +70 -0
  15. Reference_models/ae.safetensors +3 -0
  16. Reference_models/clip_l/pytorch_model.safetensors +3 -0
  17. Reference_models/comfyui_local_lora16.safetensors +3 -0
  18. Reference_models/comfyui_subject_lora16.safetensors +3 -0
  19. Reference_models/t5_xxl/config.json +28 -0
  20. Reference_models/t5_xxl/generation_config.json +7 -0
  21. Reference_models/t5_xxl/special_tokens_map.json +1 -0
  22. Reference_models/t5_xxl/spiece.model +3 -0
  23. Reference_models/t5_xxl/tokenizer.json +0 -0
  24. Reference_models/t5_xxl/tokenizer_config.json +1 -0
  25. Training_Data/Inperson_3-Garment-V2.jpg +3 -0
  26. Training_Data/Inperson_3-Garment-V2.png +3 -0
  27. Training_Data/Inperson_3-Mask-V1.png +3 -0
  28. Training_Data/Inperson_3-V1.png +3 -0
  29. Training_Data/Inperson_4-Garment-V2.png +3 -0
  30. Training_Data/Inperson_4-Mask-V2.png +3 -0
  31. Training_Data/Inperson_4-V2.png +3 -0
  32. Training_Data/Inperson_5-Garment-V2.jpg +3 -0
  33. Training_Data/Inperson_5-Garment-V2.png +3 -0
  34. Training_Data/Inperson_5-V2.jpg +3 -0
  35. Training_Data/Inperson_5-V2.png +3 -0
  36. Training_Data/Inperson_7-Garment-V2.png +3 -0
  37. Training_Data/Inperson_7-V2.jpg +3 -0
  38. Training_Data/Inperson_7-V2.png +3 -0
  39. Training_Data/Pinaperson_1-Garment-V1.jpg +3 -0
  40. Training_Data/Pinaperson_1-V1.jpg +3 -0
  41. Training_Data/Pinaperson_2-Garment-V1.jpg +3 -0
  42. Training_Data/Pinaperson_2-V1.jpg +3 -0
  43. Training_Data/Pinaperson_3-Garment-V1.jpg +3 -0
  44. Training_Data/Pinaperson_3-V1.jpg +3 -0
  45. Training_Data/Pinaperson_4-Garment-V1.jpg +3 -0
  46. Training_Data/Pinaperson_4-V1.jpg +3 -0
  47. Training_Data/TigcPerson_1-Garment.jpg +3 -0
  48. Training_Data/TigcPerson_1-Mask.jpg +3 -0
  49. Training_Data/TigcPerson_1.jpg +3 -0
  50. Training_Data/TigcPerson_2-Mask.jpg +3 -0
.gitattributes CHANGED
@@ -48,3 +48,55 @@ Training_Data/Inperson_7-Garment-V2.jpg filter=lfs diff=lfs merge=lfs -text
48
  Training_Data/Venusperson_7-Garment.jpg filter=lfs diff=lfs merge=lfs -text
49
  Training_Data/Venusperson_1.jpg filter=lfs diff=lfs merge=lfs -text
50
  Training_Data/Venusperson_2.jpg filter=lfs diff=lfs merge=lfs -text
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
48
  Training_Data/Venusperson_7-Garment.jpg filter=lfs diff=lfs merge=lfs -text
49
  Training_Data/Venusperson_1.jpg filter=lfs diff=lfs merge=lfs -text
50
  Training_Data/Venusperson_2.jpg filter=lfs diff=lfs merge=lfs -text
51
+ Training_Data/TigcPerson_3.jpg filter=lfs diff=lfs merge=lfs -text
52
+ Training_Data/Inperson_4-V2.png filter=lfs diff=lfs merge=lfs -text
53
+ Training_Data/Venusperson_7.jpg filter=lfs diff=lfs merge=lfs -text
54
+ Training_Data/TigcPerson_3-Mask.jpg filter=lfs diff=lfs merge=lfs -text
55
+ Training_Data/TigcPerson_1-Mask.jpg filter=lfs diff=lfs merge=lfs -text
56
+ Training_Data/TigcPerson_5-Mask.jpg filter=lfs diff=lfs merge=lfs -text
57
+ Training_Data/TigcPerson_5.jpg filter=lfs diff=lfs merge=lfs -text
58
+ Training_Data/Pinaperson_1-Garment-V1.jpg filter=lfs diff=lfs merge=lfs -text
59
+ Training_Data/Pinaperson_2-Garment-V1.jpg filter=lfs diff=lfs merge=lfs -text
60
+ Training_Data/TigcPerson_5-Garment.jpg filter=lfs diff=lfs merge=lfs -text
61
+ Training_Data/Inperson_4-Garment-V2.png filter=lfs diff=lfs merge=lfs -text
62
+ Training_Data/TigcPerson_2-Mask.jpg filter=lfs diff=lfs merge=lfs -text
63
+ Training_Data/Inperson_7-V2.jpg filter=lfs diff=lfs merge=lfs -text
64
+ Training_Data/Inperson_5-Garment-V2.jpg filter=lfs diff=lfs merge=lfs -text
65
+ Training_Data/TigcPerson_1.jpg filter=lfs diff=lfs merge=lfs -text
66
+ Training_Data/Venusperson_11.jpg filter=lfs diff=lfs merge=lfs -text
67
+ Training_Data/Pinaperson_3-V1.jpg filter=lfs diff=lfs merge=lfs -text
68
+ Training_Data/Venusperson_10.jpg filter=lfs diff=lfs merge=lfs -text
69
+ Training_Data/Venusperson_2-Garment.jpg filter=lfs diff=lfs merge=lfs -text
70
+ Training_Data/Pinaperson_3-Garment-V1.jpg filter=lfs diff=lfs merge=lfs -text
71
+ Training_Data/Venusperson_6-Garment.jpg filter=lfs diff=lfs merge=lfs -text
72
+ Training_Data/Inperson_3-Mask-V1.png filter=lfs diff=lfs merge=lfs -text
73
+ Training_Data/Venusperson_9.jpg filter=lfs diff=lfs merge=lfs -text
74
+ Training_Data/Venusperson_8.jpg filter=lfs diff=lfs merge=lfs -text
75
+ Training_Data/Inperson_4-Mask-V2.png filter=lfs diff=lfs merge=lfs -text
76
+ Training_Data/Pinaperson_4-Garment-V1.jpg filter=lfs diff=lfs merge=lfs -text
77
+ Training_Data/Inperson_3-Garment-V2.png filter=lfs diff=lfs merge=lfs -text
78
+ Training_Data/Inperson_5-V2.png filter=lfs diff=lfs merge=lfs -text
79
+ Training_Data/Venusperson_4.jpg filter=lfs diff=lfs merge=lfs -text
80
+ Training_Data/Venusperson_3-Garment.jpg filter=lfs diff=lfs merge=lfs -text
81
+ Training_Data/Inperson_7-V2.png filter=lfs diff=lfs merge=lfs -text
82
+ Training_Data/Venusperson_12.jpg filter=lfs diff=lfs merge=lfs -text
83
+ Training_Data/Venusperson_1-Garment.jpg filter=lfs diff=lfs merge=lfs -text
84
+ Training_Data/Venusperson_10-Garment.jpg filter=lfs diff=lfs merge=lfs -text
85
+ Training_Data/Inperson_5-Garment-V2.png filter=lfs diff=lfs merge=lfs -text
86
+ Training_Data/TigcPerson_1-Garment.jpg filter=lfs diff=lfs merge=lfs -text
87
+ Training_Data/Inperson_5-V2.jpg filter=lfs diff=lfs merge=lfs -text
88
+ Training_Data/Pinaperson_4-V1.jpg filter=lfs diff=lfs merge=lfs -text
89
+ Training_Data/Venusperson_6.jpg filter=lfs diff=lfs merge=lfs -text
90
+ Training_Data/Venusperson_3.jpg filter=lfs diff=lfs merge=lfs -text
91
+ Training_Data/Venusperson_8-Garment.jpg filter=lfs diff=lfs merge=lfs -text
92
+ Training_Data/Inperson_3-Garment-V2.jpg filter=lfs diff=lfs merge=lfs -text
93
+ Training_Data/Venusperson_4-Garment.jpg filter=lfs diff=lfs merge=lfs -text
94
+ Training_Data/Pinaperson_2-V1.jpg filter=lfs diff=lfs merge=lfs -text
95
+ Training_Data/Venusperson_9-Garment.jpg filter=lfs diff=lfs merge=lfs -text
96
+ Training_Data/Inperson_7-Garment-V2.png filter=lfs diff=lfs merge=lfs -text
97
+ Training_Data/Venusperson_12-Garment.jpg filter=lfs diff=lfs merge=lfs -text
98
+ Training_Data/Pinaperson_1-V1.jpg filter=lfs diff=lfs merge=lfs -text
99
+ Training_Data/TigcPerson_4.jpg filter=lfs diff=lfs merge=lfs -text
100
+ Training_Data/Inperson_3-V1.png filter=lfs diff=lfs merge=lfs -text
101
+ Training_Data/Venusperson_11-Garment.jpg filter=lfs diff=lfs merge=lfs -text
102
+ Training_Data/TigcPerson_2.jpg filter=lfs diff=lfs merge=lfs -text
ACE_plus/.gitignore ADDED
@@ -0,0 +1 @@
 
 
1
+ .idea
ACE_plus/README.md ADDED
@@ -0,0 +1,600 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <p align="center">
2
+
3
+ <h2 align="center"><img src="assets/figures/icon.png" height=16> ++: Instruction-Based Image Creation and Editing <br> via Context-Aware Content Filling </h2>
4
+
5
+ <p align="center">
6
+ <a href="https://arxiv.org/abs/2501.02487"><img src='https://img.shields.io/badge/arXiv-ACE++-red' alt='Paper PDF'></a>
7
+ <a href='https://ali-vilab.github.io/ACE_plus_page/'><img src='https://img.shields.io/badge/Project_Page-ACE++-blue' alt='Project Page'></a>
8
+ <a href='https://github.com/modelscope/scepter'><img src='https://img.shields.io/badge/Scepter-ACE++-green'></a>
9
+ <a href='https://huggingface.co/spaces/scepter-studio/ACE-Plus'><img src='https://img.shields.io/badge/%F0%9F%A4%97%20Hugging%20Face-Space-orange'></a>
10
+ <a href='https://huggingface.co/ali-vilab/ACE_Plus/tree/main'><img src='https://img.shields.io/badge/%F0%9F%A4%97%20Hugging%20Face-Model-orange'></a>
11
+ <a href='https://modelscope.cn/models/iic/ACE_Plus/summary'><img src='https://img.shields.io/badge/ModelScope-Model-purple'></a>
12
+ <br>
13
+ <strong>Chaojie Mao</strong>
14
+ ·
15
+ <strong>Jingfeng Zhang</strong>
16
+ ·
17
+ <strong>Yulin Pan</strong>
18
+ ·
19
+ <strong>Zeyinzi Jiang</strong>
20
+ ·
21
+ <strong>Zhen Han</strong>
22
+ <br>
23
+ ·
24
+ <strong>Yu Liu</strong>
25
+ ·
26
+ <strong>Jingren Zhou</strong>
27
+ <br>
28
+ Tongyi Lab, Alibaba Group
29
+ </p>
30
+ <table align="center">
31
+ <tr>
32
+ <td>
33
+ <img src="assets/ace_method/method++.png">
34
+ </td>
35
+ </tr>
36
+ </table>
37
+
38
+ ## 📚 Introduction
39
+
40
+ The original intention behind the design of ACE++ was to unify reference image generation, local editing,
41
+ and controllable generation into a single framework, and to enable one model to adapt to a wider range of tasks.
42
+ A more versatile model is often capable of handling more complex tasks. We have released three LoRA models for
43
+ specific vertical domains and a more versatile FFT model (the performance of the FFT model declines compared
44
+ to the LoRA model across various tasks). Users can flexibly utilize these models and their
45
+ combinations for their own scenarios.
46
+
47
+ ## 📢 News
48
+ - [x] **[2025.01.06]** Release the code and models of ACE++.
49
+ - [x] **[2025.01.07]** Release the demo on [HuggingFace](https://huggingface.co/spaces/scepter-studio/ACE-Plus).
50
+ - [x] **[2025.01.16]** Release the training code for lora.
51
+ - [x] **[2025.02.15]** Collection of workflows in Comfyui.
52
+ - [x] **[2025.02.15]** Release the config for fully fine-tuning.
53
+ - [x] **[2025.03.03]** Release the fft model for ACE++, support more image to image tasks.
54
+ - [x] **[2025.03.11]** Release some comfyui workflow examples for ACE++ model.
55
+
56
+ - We sincerely apologize
57
+ for the delayed responses and updates regarding ACE++ issues.
58
+ Further development of the ACE model through post-training on the FLUX model must be suspended.
59
+ We have identified several significant challenges in post-training on the FLUX foundation.
60
+ The primary issue is the high degree of heterogeneity between the training dataset and the FLUX model,
61
+ which results in highly unstable training. Moreover, FLUX-Dev is a distilled model, and the influence of its original negative prompts on its final performance is uncertain.
62
+ As a result, subsequent efforts will be focused on post-training the ACE model using the Wan series of foundational models. __Due to the reasons mentioned earlier, the performance of the FFT model may decline compared
63
+ to the LoRA model across various tasks. Therefore, we recommend continuing to use the LoRA model to achieve better results.
64
+ We provide the FFT model with the hope that it may facilitate academic exploration and research in this area.__
65
+
66
+
67
+ ## Models
68
+
69
+ ### ACE++ Portrait LoRA
70
+
71
+ Portrait-consistent generation to maintain the consistency of the portrait.
72
+
73
+
74
+ <table><tbody>
75
+ <tr>
76
+ <td>Tuning Method</td>
77
+ <td>Input</td>
78
+ <td>Output</td>
79
+ <td>Instruction</td>
80
+ <td>Models</td>
81
+ </tr>
82
+ <tr>
83
+ <td>LoRA <br>+ ACE Data</td>
84
+ <td><img src="./assets/samples/portrait/human_1.jpg" width="200"></td>
85
+ <td><img src="./assets/samples/portrait/human_1_1.jpg" width="200"></td>
86
+ <td style="word-wrap:break-word;word-break:break-all;" width="250px";>"Maintain the facial features. A girl is wearing a neat police uniform and sporting a badge. She is smiling with a friendly and confident demeanor. The background is blurred, featuring a cartoon logo."</td>
87
+ <td align="center" style="word-wrap:break-word;word-break:break-all;" width="200px";><a href="https://www.modelscope.cn/models/iic/ACE_Plus/"><img src="https://img.shields.io/badge/ModelScope-Model-blue" alt="ModelScope link"> </a> <a href="https://huggingface.co/ali-vilab/ACE_Plus/tree/main/portrait/"><img src="https://img.shields.io/badge/%F0%9F%A4%97%20Hugging%20Face-Model-yellow" alt="HuggingFace link"> </a> </td>
88
+ </tr>
89
+ </tbody>
90
+ </table>
91
+
92
+
93
+ Models' scepter_path:
94
+
95
+ - **ModelScope:** ms://iic/ACE_Plus@portrait/xxxx.safetensors
96
+
97
+ - **HuggingFace:** hf://ali-vilab/ACE_Plus@portrait/xxxx.safetensors
98
+
99
+
100
+
101
+ ### ACE++ Subject LoRA
102
+
103
+ Subject-driven image generation task to maintain the consistency of a specific subject in different scenes.
104
+
105
+ <table><tbody>
106
+ <tr>
107
+ <td>Tuning Method</td>
108
+ <td>Input</td>
109
+ <td>Output</td>
110
+ <td>Instruction</td>
111
+ <td>Models</td>
112
+ </tr>
113
+ <tr>
114
+ <td>LoRA <br>+ ACE Data</td>
115
+ <td><img src="./assets/samples/subject/subject_1.jpg" width="200"></td>
116
+ <td><img src="./assets/samples/subject/subject_1_1.jpg" width="200"></td>
117
+ <td style="word-wrap:break-word;word-break:break-all;" width="250px";>"Display the logo in a minimalist style printed in white on a matte black ceramic coffee mug, alongside a steaming cup of coffee on a cozy cafe table."</td>
118
+ <td align="center" style="word-wrap:break-word;word-break:break-all;" width="200px";><a href="https://www.modelscope.cn/models/iic/ACE_Plus/"><img src="https://img.shields.io/badge/ModelScope-Model-blue" alt="ModelScope link"> </a> <a href="https://huggingface.co/ali-vilab/ACE_Plus/tree/main/subject/"><img src="https://img.shields.io/badge/%F0%9F%A4%97%20Hugging%20Face-Model-yellow" alt="HuggingFace link"> </a> </td>
119
+ </tr>
120
+ </tbody>
121
+ </table>
122
+
123
+
124
+ Models' scepter_path:
125
+
126
+ - **ModelScope:** ms://iic/ACE_Plus@subject/xxxx.safetensors
127
+
128
+ - **HuggingFace:** hf://ali-vilab/ACE_Plus@subject/xxxx.safetensors
129
+
130
+
131
+
132
+ ### ACE++ LocalEditing LoRA
133
+
134
+ Redrawing the mask area of images while maintaining the original structural information of the edited area.
135
+
136
+ <table><tbody>
137
+ <tr>
138
+ <td>Tuning Method</td>
139
+ <td>Input</td>
140
+ <td>Output</td>
141
+ <td>Instruction</td>
142
+ <td>Models</td>
143
+ </tr>
144
+ <tr>
145
+ <td>LoRA <br>+ ACE Data</td>
146
+ <td><img src="./assets/samples/local/local_1.webp" width="200"><br><img src="./assets/samples/local/local_1_m.webp" width="200"></td>
147
+ <td><img src="./assets/samples/local/local_1_1.jpg" width="200"></td>
148
+ <td style="word-wrap:break-word;word-break:break-all;" width="250px";>"By referencing the mask, restore a partial image from the doodle {image} that aligns with the textual explanation: "1 white old owl"."</td>
149
+ <td align="center" style="word-wrap:break-word;word-break:break-all;" width="200px";><a href="https://www.modelscope.cn/models/iic/ACE_Plus/"><img src="https://img.shields.io/badge/ModelScope-Model-blue" alt="ModelScope link"> </a> <a href="https://huggingface.co/ali-vilab/ACE_Plus/tree/main/local_editing/"><img src="https://img.shields.io/badge/%F0%9F%A4%97%20Hugging%20Face-Model-yellow" alt="HuggingFace link"> </a> </td>
150
+ </tr>
151
+ </tbody>
152
+
153
+ </table>
154
+
155
+
156
+ Models' scepter_path:
157
+
158
+ - **ModelScope:** ms://iic/ACE_Plus@local_editing/xxxx.safetensors
159
+
160
+ - **HuggingFace:** hf://ali-vilab/ACE_Plus@local_editing/xxxx.safetensors
161
+
162
+ ### ACE++ FFT model
163
+ Fully finetuning a composite model with ACE’s data to support various editing and reference generation tasks through an instructive approach.
164
+
165
+ We introduced 64 additional channels in the channel dimension to differentiate between the repainting task and the editing task. In these channels, we place the latent representation of the pixel space from the edited image, while keeping other channels consistent with the repainting task. One issue with this approach is that it changes the input channel number of the FLUX-Fill-Dev model from 384 to 448. The specific configuration can be referenced in the [configuration file](config/ace_plus_fft.yaml).
166
+
167
+
168
+ ### Examples
169
+ The ACE++ model supports a wide range of downstream tasks through simple adaptations. Here are some examples.
170
+
171
+ <table><tbody>
172
+ <tr>
173
+ <th align="center" colspan="1">ACE++ Model</th>
174
+ <td>Input Reference Image</td>
175
+ <td>Input Edit Image</td>
176
+ <td>Input Edit Mask</td>
177
+ <td>Output</td>
178
+ <td>Instruction</td>
179
+ <td>Function</td>
180
+ </tr>
181
+ <tr>
182
+ <td>Portrait LoRA(recommended) / FFT model</td>
183
+ <td><img src="./assets/samples/portrait/human_1.jpg" width="200"></td>
184
+ <td></td>
185
+ <td></td>
186
+ <td><img src="./assets/samples/portrait/human_1_fft.webp" width="200"></td>
187
+ <td style="word-wrap:break-word;word-break:break-all;" width="250px";>"Maintain the facial features, A girl is wearing a neat police uniform and sporting a badge. She is smiling with a friendly and confident demeanor. The background is blurred, featuring a cartoon logo."</td>
188
+ <td style="word-wrap:break-word;word-break:break-all;" width="250px";>"Character ID Consistency Generation"</td>
189
+ </tr>
190
+ <tr>
191
+ <td>Subject LoRA(recommended) / FFT model</td>
192
+ <td><img src="./assets/samples/subject/subject_1.jpg" width="200"></td>
193
+ <td></td>
194
+ <td></td>
195
+ <td><img src="./assets/samples/subject/subject_1_fft.webp" width="200"></td>
196
+ <td style="word-wrap:break-word;word-break:break-all;" width="250px";>"Display the logo in a minimalist style printed in white on a matte black ceramic coffee mug, alongside a steaming cup of coffee on a cozy cafe table."</td>
197
+ <td style="word-wrap:break-word;word-break:break-all;" width="250px";>"Subject Consistency Generation"</td>
198
+ </tr>
199
+ <tr>
200
+ <td>Subject LoRA(recommended) / FFT model</td>
201
+ <td><img src="./assets/samples/application/photo_editing/1_ref.png" width="200"></td>
202
+ <td><img src="./assets/samples/application/photo_editing/1_2_edit.jpg" width="200"></td>
203
+ <td><img src="./assets/samples/application/photo_editing/1_2_m.webp" width="200"></td>
204
+ <td><img src="./assets/samples/application/photo_editing/1_2_fft.webp" width="200"></td>
205
+ <td style="word-wrap:break-word;word-break:break-all;" width="250px";>"The item is put on the table."</td>
206
+ <td style="word-wrap:break-word;word-break:break-all;" width="250px";>"Subject Consistency Editing"</td>
207
+ </tr>
208
+ <tr>
209
+ <td>Subject LoRA(recommended) / FFT model</td>
210
+ <td><img src="./assets/samples/application/logo_paste/1_ref.png" width="200"></td>
211
+ <td><img src="./assets/samples/application/logo_paste/1_1_edit.png" width="200"></td>
212
+ <td><img src="./assets/samples/application/logo_paste/1_1_m.png" width="200"></td>
213
+ <td><img src="./assets/samples/application/logo_paste/1_1_fft.webp" width="200"></td>
214
+ <td style="word-wrap:break-word;word-break:break-all;" width="250px";>"The logo is printed on the headphones."</td>
215
+ <td style="word-wrap:break-word;word-break:break-all;" width="250px";>"Subject Consistency Editing"</td>
216
+ </tr>
217
+ <tr>
218
+ <td>Subject LoRA(recommended) / FFT model</td>
219
+ <td><img src="./assets/samples/application/try_on/1_ref.png" width="200"></td>
220
+ <td><img src="./assets/samples/application/try_on/1_1_edit.png" width="200"></td>
221
+ <td><img src="./assets/samples/application/try_on/1_1_m.png" width="200"></td>
222
+ <td><img src="./assets/samples/application/try_on/1_1_fft.webp" width="200"></td>
223
+ <td style="word-wrap:break-word;word-break:break-all;" width="250px";>"The woman dresses this skirt."</td>
224
+ <td style="word-wrap:break-word;word-break:break-all;" width="250px";>"Try On"</td>
225
+ </tr>
226
+ <tr>
227
+ <td>Portrait LoRA(recommended) / FFT model</td>
228
+ <td><img src="./assets/samples/application/movie_poster/1_ref.png" width="200"></td>
229
+ <td><img src="./assets/samples/portrait/human_1.jpg" width="200"></td>
230
+ <td><img src="./assets/samples/application/movie_poster/1_2_m.webp" width="200"></td>
231
+ <td><img src="./assets/samples/application/movie_poster/1_1_fft.webp" width="200"></td>
232
+ <td style="word-wrap:break-word;word-break:break-all;" width="250px";>"{image}, the man faces the camera."</td>
233
+ <td style="word-wrap:break-word;word-break:break-all;" width="250px";>"Face swap"</td>
234
+ </tr>
235
+ <tr>
236
+ <td>FFT model</td>
237
+ <td></td>
238
+ <td><img src="./assets/samples/application/sr/sr_tiger.png" width="200"></td>
239
+ <td><img src="./assets/samples/application/sr/sr_tiger_m.webp" width="200"></td>
240
+ <td><img src="./assets/samples/application/sr/sr_tiger_fft.webp" width="200"></td>
241
+ <td style="word-wrap:break-word;word-break:break-all;" width="250px";>"{image} features a close-up of a young, furry tiger cub on a rock. The tiger, which appears to be quite young, has distinctive orange, black, and white striped fur, typical of tigers. The cub's eyes have a bright and curious expression, and its ears are perked up, indicating alertness. The cub seems to be in the act of climbing or resting on the rock. The background is a blurred grassland with trees, but the focus is on the cub, which is vividly colored while the rest of the image is in grayscale, drawing attention to the tiger's details. The photo captures a moment in the wild, depicting the charming and tenacious nature of this young tiger, as well as its typical interaction with the environment."</td>
242
+ <td style="word-wrap:break-word;word-break:break-all;" width="250px";>"Super-resolution"</td>
243
+ </tr>
244
+ <tr>
245
+ <td>FFT model</td>
246
+ <td></td>
247
+ <td><img src="./assets/samples/application/photo_editing/1_ref.png" width="200"></td>
248
+ <td><img src="./assets/samples/application/photo_editing/1_1_orm.webp" width="200"></td>
249
+ <td><img src="./assets/samples/application/regional_editing/1_1_fft.webp" width="200"></td>
250
+ <td style="word-wrap:break-word;word-break:break-all;" width="250px";>"a blue hand"</td>
251
+ <td style="word-wrap:break-word;word-break:break-all;" width="250px";>"Regional Editing"</td>
252
+ </tr>
253
+ <tr>
254
+ <td>FFT model</td>
255
+ <td></td>
256
+ <td><img src="./assets/samples/application/photo_editing/1_ref.png" width="200"></td>
257
+ <td><img src="./assets/samples/application/photo_editing/1_1_rm.webp" width="200"></td>
258
+ <td><img src="./assets/samples/application/regional_editing/1_2_fft.webp" width="200"></td>
259
+ <td style="word-wrap:break-word;word-break:break-all;" width="250px";>"Mechanical hands like a robot"</td>
260
+ <td style="word-wrap:break-word;word-break:break-all;" width="250px";>"Regional Editing"</td>
261
+ </tr>
262
+ <tr>
263
+ <td>Local Editing LoRA/FFT model</td>
264
+ <td></td>
265
+ <td><img src="./assets/samples/control/1_1_recolor.webp" width="200"></td>
266
+ <td><img src="./assets/samples/control/1_1_m.webp" width="200"></td>
267
+ <td><img src="./assets/samples/control/1_1_fft_recolor.webp" width="200"></td>
268
+ <td style="word-wrap:break-word;word-break:break-all;" width="250px";>"{image} Beautiful female portrait, Robot with smooth White transparent carbon shell, rococo detailing, Natural lighting, Highly detailed, Cinematic, 4K."</td>
269
+ <td style="word-wrap:break-word;word-break:break-all;" width="250px";>"Recolorizing"</td>
270
+ </tr>
271
+
272
+ <tr>
273
+ <td>Local Editing LoRA/FFT model</td>
274
+ <td></td>
275
+ <td><img src="./assets/samples/control/1_1_depth.webp" width="200"></td>
276
+ <td><img src="./assets/samples/control/1_1_m.webp" width="200"></td>
277
+ <td><img src="./assets/samples/control/1_1_fft_depth.webp" width="200"></td>
278
+ <td style="word-wrap:break-word;word-break:break-all;" width="250px";>"{image} Beautiful female portrait, Robot with smooth White transparent carbon shell, rococo detailing, Natural lighting, Highly detailed, Cinematic, 4K."</td>
279
+ <td style="word-wrap:break-word;word-break:break-all;" width="250px";>"Depth Guided Generation"</td>
280
+ </tr>
281
+ <tr>
282
+ <td>Local Editing LoRA/FFT model</td>
283
+ <td></td>
284
+ <td><img src="./assets/samples/control/1_1_contourc.webp" width="200"></td>
285
+ <td><img src="./assets/samples/control/1_1_m.webp" width="200"></td>
286
+ <td><img src="./assets/samples/control/1_1_fft_contour.webp" width="200"></td>
287
+ <td style="word-wrap:break-word;word-break:break-all;" width="250px";>"{image} Beautiful female portrait, Robot with smooth White transparent carbon shell, rococo detailing, Natural lighting, Highly detailed, Cinematic, 4K."</td>
288
+ <td style="word-wrap:break-word;word-break:break-all;" width="250px";>"Contour Guided Generation"</td>
289
+ </tr>
290
+ </tbody>
291
+ </table>
292
+
293
+ ## Comfyui Workflows in community
294
+ We are deeply grateful to the community developers for building many fascinating applications based on the ACE++ series of models.
295
+ During this process, we have received valuable feedback, particularly regarding artifacts in generated images and the stability of the results.
296
+ In response to these issues, many developers have proposed creative solutions, which have greatly inspired us, and we pay tribute to them.
297
+ At the same time, we will take these concerns into account in our further optimization efforts, carefully evaluating and testing before releasing new models.
298
+
299
+ In the table below, we have briefly listed some workflows for everyone to use.
300
+
301
+ <table><tbody>
302
+ <tr>
303
+ <td>Workflow</td>
304
+ <td>Author</td>
305
+ <td>Example</td>
306
+ </tr>
307
+ <tr>
308
+ <td><a href="https://www.runninghub.cn/post/1890052281759571970"> 【飞翔鲸】王炸!FLUX+ACE++换头 </a> </td>
309
+ <td><a href="https://www.runninghub.cn/user-center/1851827947798740994"> 飞翔鲸 </a></td>
310
+ <td><img src="./assets/comfyui/feixiangjing_face.png" height="200"></td>
311
+ </tr>
312
+ <tr>
313
+ <td><a href="https://www.runninghub.cn/post/1890014204382916609"> 最新ACE++ Redux 万物迁移 AI模特换装 UP 楚门的AI世界 </a> </td>
314
+ <td><a href="https://www.runninghub.cn/user-center/1865415077888405506"> 楚门的AI世界 </a></td>
315
+ <td><img src="./assets/comfyui/chumen_tryon.jpg" height="200"></td>
316
+ </tr>
317
+ <tr>
318
+ <td><a href="https://openart.ai/workflows/t8star/ace-plusfillredux/bgQDNz8SeySMDqn13ZBv"> Ace Plus+Fill+Redux稳定无抽卡换装工作流</a> </td>
319
+ <td><a href="https://openart.ai/workflows/profile/t8star?sort=latest"> T8star-Aix </a></td>
320
+ <td><img src="./assets/comfyui/t8_star_tryon.jpg" height="200"></td>
321
+ </tr>
322
+ <tr>
323
+ <td><a href="https://openart.ai/workflows/t8star/ace-plusfillredux/ifIvaWXW9QkLtNV405j7"> Ace Plus+Fill+Redux稳定少抽卡标志工作流</a> </td>
324
+ <td><a href="https://openart.ai/workflows/profile/t8star?sort=latest"> T8star-Aix </a></td>
325
+ <td><img src="./assets/comfyui/t8_star_logo.jpg" height="200"></td>
326
+ </tr>
327
+ <tr>
328
+ <td><a href="https://openart.ai/workflows/t8star/ace-plusfillredux/WdwUwGXPLHhnSOlSEfTg"> Ace Plus+Fill+Redux稳定无抽卡换脸工作流</a> </td>
329
+ <td><a href="https://openart.ai/workflows/profile/t8star?sort=latest"> T8star-Aix </a></td>
330
+ <td><img src="./assets/comfyui/t8_star_face.jpg" height="200"></td>
331
+ </tr>
332
+ <tr>
333
+ <td><a href="https://openart.ai/workflows/cat_untimely_42/ace-face-swap-in-different-styles/VocvdfQrvDhmKNLEBwJY"> ace++ face swap in different styles </a> </td>
334
+ <td><a href="https://openart.ai/workflows/profile/cat_untimely_42?sort=latest"> jax </a></td>
335
+ <td><img src="./assets/comfyui/jax_face_swap.jpg" height="200"></td>
336
+ </tr>
337
+ <tr>
338
+ <td><a href="https://openart.ai/workflows/leeguandong/fllux-ace-subject-without-reference-image/HjYf6Eae2PRGACJWXdrE"> fllux ace++ subject without reference image </a> </td>
339
+ <td><a href="https://openart.ai/workflows/profile/leeguandong?sort=latest"> leeguandong </a></td>
340
+ <td><img src="./assets/comfyui/leeguandong_subject.jpg" height="200"></td>
341
+ </tr>
342
+ <tr>
343
+ <td><a href="https://openart.ai/workflows/whale_waterlogged_60/scepter-ace-more-convenient-replacement-of-everything/gjAsh5rGjfC6OEB2AUZv"> Scepter-ACE++ More convenient replacement of everything</a> </td>
344
+ <td><a href="https://openart.ai/workflows/profile/whale_waterlogged_60?sort=latest"> HaoBeen </a></td>
345
+ <td><img src="./assets/comfyui/haobeen_ace_plus.jpg" height="200"></td>
346
+ </tr>
347
+ </tbody>
348
+ </table>
349
+
350
+ Additionally, many bloggers have published tutorials on how to use it, which are listed in the table below.
351
+
352
+ <table><tbody>
353
+ <tr>
354
+ <td>Tutorial</td>
355
+ </tr>
356
+ <tr>
357
+ <td><a href="https://www.youtube.com/watch?v=5OwcxugdWxI"> Best Faceswapper I've Seen. ACE++ in ComfyUI. </a> </td>
358
+ </tr>
359
+ <tr>
360
+ <td><a href="https://www.youtube.com/watch?v=2fgT35H_tuE&pp=ygUIYWNlIHBsdXM%3D"> ACE ++ In ComfyUI All-round Creator & Editor - More Than Just A Faceswap AI </a> </td>
361
+ </tr>
362
+ <tr>
363
+ <td><a href="https://www.youtube.com/watch?v=XU376PzgnXc"> Ai绘画进阶140-咦?大家用的都不对?!Ace Plus工作流正确搭建方式及逻辑,参数详解,Flux Fill,Redux联用-T8 Comfyui教程</a> </td>
364
+ </tr>
365
+ <tr>
366
+ <td><a href="https://www.youtube.com/watch?v=1cbOkN0mTw0"> ace++:告别 Lora 训练,无需pulid,轻松打造专属角色! | No Lora Training, Easily Create Exclusive Characters!</a> </td>
367
+ </tr>
368
+ <tr>
369
+ <td><a href="https://www.youtube.com/watch?v=0wMoWSTm5Hc"> Ace++ and Flux Fill: Advanced Face Swapping Made Easy in ComfyUI | No Lora Training, Easily Create Exclusive Characters!</a> </td>
370
+ </tr>
371
+ <tr>
372
+ <td><a href="https://www.youtube.com/watch?v=7GrkIFuRQAc"> ComfyUI - ACE Plus Subject Portrait Lora </a> </td>
373
+ </tr>
374
+ <tr>
375
+ <td><a href="https://www.bilibili.com/video/BV1HiKpeuE8o/?spm_id_from=333.337.search-card.all.click&vd_source=927630f34c77eee560afd69cfdba3f47"> 🤗AI一致性技术新突破!ACE++技术一致性comfyui工作流🍋‍ </a> </td>
376
+ </tr>
377
+ <tr>
378
+ <td><a href="https://www.bilibili.com/video/BV1obN9enEvp/?spm_id_from=333.337.search-card.all.click&vd_source=927630f34c77eee560afd69cfdba3f47"> ComfyUI 第55集 人像换脸 FLUX的FILL模型+ACE LORA </a> </td>
379
+ </tr>
380
+ <tr>
381
+ <td><a href="https://www.bilibili.com/video/BV1pPN3eBEtr/?spm_id_from=333.337.search-card.all.click&vd_source=927630f34c77eee560afd69cfdba3f47"> 换装变脸贴logo,无所不能的Ace_Plus lora </a> </td>
382
+ </tr>
383
+ </tbody>
384
+ </table>
385
+
386
+ ## ComfyUI Workflow Examples
387
+
388
+ Copy the workflow/ComfyUI-ACE_Plus folder into ComfyUI’s custom_nodes directory. Launch ComfyUI, and we have provided some example workflows in workflow_example with the following explanations. It is recommended to use the LoRA model workflow, as it offers more stable results compared to the FFT model.
389
+
390
+ <table><tbody>
391
+ <tr>
392
+ <td>Workflow</td>
393
+ <td>Description</td>
394
+ <td>Other dependency models</td>
395
+ <td>Setting</td>
396
+ </tr>
397
+ <tr>
398
+ <td>ACE_Plus_LoRA_workflow_reference_generation.json</td>
399
+ <td>Reference image generation capability for portrait or subject.</td>
400
+ <td>Potrait or subject LoRA Model + FLUX.1-Fill-dev</td>
401
+ <td>Task_type: repainting (you don't need to install dependencies like scepter)</td>
402
+ </tr>
403
+ <tr>
404
+ <td>ACE_Plus_LoRA_workflow_redux_reference_generation.json</td>
405
+ <td>Reference image generation capability for portrait or subject used in conjunction with Redux.</td>
406
+ <td>Potrait or subject LoRA Model + FLUX.1-Fill-dev + FLUX.1-Redux</td>
407
+ <td>Task_type: repainting (you don't need to install dependencies like scepter)</td>
408
+ </tr>
409
+ <tr>
410
+ <td>ACE_Plus_LoRA_workflow_reference_editing.json</td>
411
+ <td>Reference image editing capability such as logo paste, face swap.</td>
412
+ <td>Potrait or subject LoRA Model + FLUX.1-Fill-dev</td>
413
+ <td>Task_type: repainting (you don't need to install dependencies like scepter)</td>
414
+ </tr>
415
+ <tr>
416
+ <td>ACE_Plus_LoRA_workflow_redux_reference_editing.json</td>
417
+ <td>Reference image editing capability such as logo paste, face swap used in conjunction with Redux.</td>
418
+ <td>Potrait or subject LoRA Model + FLUX.1-Fill-dev + FLUX.1-Redux</td>
419
+ <td>Task_type: repainting (you don't need to install dependencies like scepter)</td>
420
+ </tr>
421
+ <tr>
422
+ <td>ACE_Plus_LoRA_workflow_localcontrol_generation.json</td>
423
+ <td>Controllable image-to-image translation capability. To preprocess depth and contour information from images,
424
+ we use externally-provided models that are typically downloaded from the ModelScope Hub. Because download success
425
+ can vary depending on the user's environment, we offer alternatives: users can either leverage existing community
426
+ nodes (depth extration node or contour extraction node) for this task (then choosing the 'no_preprocess' option),
427
+ or users can pre-download the required models
428
+ <a href="https://www.modelscope.cn/models/iic/scepter_annotator/file/view/master?fileName=annotator%252Fckpts%252Finformative_drawing_contour_style.pth&status=2">contour</a> and
429
+ <a href="https://www.modelscope.cn/models/iic/scepter_annotator/file/view/master?fileName=annotator%252Fckpts%252Fdpt_hybrid-midas-501f0c75.pt&status=2">depth</a>
430
+ and adjust
431
+ the configuration file 'workflow/ComfyUI-ACE_Plus/config/ace_plus_fft_processor.yaml' to
432
+ specify the models' local paths.</td>
433
+ <td>Local editing LoRA Model + FLUX.1-Fill-dev + Preprocessing model (depth or contour) </td>
434
+ <td>Task_type: contour_repainting/depth_repainting/recolorizing (you need to install dependencies like scepter)</td>
435
+ </tr>
436
+ <tr>
437
+ <td>ACE_Plus_FFT_workflow_referenceediting_generation.json</td>
438
+ <td>Reference image editing capability</td>
439
+ <td>FFT model</td>
440
+ <td>Task_type: repainting (you don't need to install dependencies like scepter)</td>
441
+ </tr>
442
+ <tr>
443
+ <td>ACE_Plus_FFT_workflow_no_preprocess.json</td>
444
+ <td>Use the preprocessed images, such as depth and contour, as input, or the super-resolution.</td>
445
+ <td>FFT model</td>
446
+ <td>Task_type: no_preprocess (you don't need to install dependencies like scepter)</td>
447
+ </tr>
448
+ <tr>
449
+ <td>ACE_Plus_FFT_workflow_controlpreprocess.json</td>
450
+ <td>Controllable image-to-image translation capability. To preprocess depth and contour information from images,
451
+ we use externally-provided models that are typically downloaded from the ModelScope Hub. Because download success
452
+ can vary depending on the user's environment, we offer alternatives: users can either leverage existing community
453
+ nodes (depth extration node or contour extraction node) for this task (then choosing the 'no_preprocess' option),
454
+ or users can pre-download the required models
455
+ <a href="https://www.modelscope.cn/models/iic/scepter_annotator/file/view/master?fileName=annotator%252Fckpts%252Finformative_drawing_contour_style.pth&status=2">contour</a> and
456
+ <a href="https://www.modelscope.cn/models/iic/scepter_annotator/file/view/master?fileName=annotator%252Fckpts%252Fdpt_hybrid-midas-501f0c75.pt&status=2">depth</a>
457
+ and adjust
458
+ the configuration file 'workflow/ComfyUI-ACE_Plus/config/ace_plus_fft_processor.yaml' to
459
+ specify the models' local paths.</td>
460
+ <td>FFT model</td>
461
+ <td>Task_type: contour_repainting/depth_repainting/recolorizing (you need to install dependencies like scepter)</td>
462
+ </tr>
463
+ <tr>
464
+ <td>ACE_Plus_FFT_workflow_reference_generation.json</td>
465
+ <td>Reference image generation capability for portrait or subject.</td>
466
+ <td>FFT model</td>
467
+ <td>Task_type: repainting (you don't need to install dependencies like scepter)</td>
468
+ </tr>
469
+ <tr>
470
+ <td>ACE_Plus_FFT_workflow_referenceediting_generation.json</td>
471
+ <td>Reference image editing capability</td>
472
+ <td>FFT model</td>
473
+ <td>Task_type: repainting (you don't need to install dependencies like scepter)</td>
474
+ </tr>
475
+ <tbody>
476
+ <table>
477
+
478
+ As shown in the figure below, max_seq_length controls the length of the token sequence during inference, thereby controlling the model's inference memory consumption.
479
+ The range of this value is from 2048 to 8192, and it correspondingly affects the clarity of the generated image. The smaller the value, the lower the image clarity.
480
+
481
+ <img src="./assets/comfyui/snapshot.jpg" width="200">
482
+
483
+
484
+ ## ⚙️️ Installation
485
+ Download the code using the following command:
486
+ ```bash
487
+ git clone https://github.com/ali-vilab/ACE_plus.git
488
+ ```
489
+
490
+ Install the necessary packages with `pip`:
491
+ ```bash
492
+ cd ACE_plus
493
+ pip install -r repo_requirements.txt
494
+ ```
495
+ ACE++ depends on FLUX.1-Fill-dev as its base model, which you can download from [![HuggingFace link](https://img.shields.io/badge/%F0%9F%A4%97%20Hugging%20Face-Model-yellow)](https://huggingface.co/black-forest-labs/FLUX.1-Fill-dev).
496
+ In order to run the inference code or Gradio demo normally, we have defined the relevant environment variables to specify the location of the model.
497
+ For model preparation, we provide three methods for downloading the model. The summary of relevant settings is as follows.
498
+
499
+ | Model Downloading Method | Clone to Local Path | Automatic Downloading during Runtime<br>(Setting the Environment Variables using scepter_path in [ACE Models](#-ace-models)) |
500
+ |:-----------------------------:|:------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|:-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
501
+ | Environment Variables Setting | <pre><code>export FLUX_FILL_PATH="path/to/FLUX.1-Fill-dev"<br>export PORTRAIT_MODEL_PATH="path/to/ACE++ PORTRAIT PATH"<br>export SUBJECT_MODEL_PATH="path/to/ACE++ SUBJECT PATH"<br>export LOCAL_MODEL_PATH="path/to/ACE++ LOCAL EDITING PATH"</code></pre> | <pre><code>export FLUX_FILL_PATH="hf://black-forest-labs/FLUX.1-Fill-dev"<br>export PORTRAIT_MODEL_PATH="${scepter_path}"<br>export SUBJECT_MODEL_PATH="${scepter_path}"<br>export LOCAL_MODEL_PATH="${scepter_path}"</code></pre> |
502
+
503
+ ## 🚀 Inference
504
+ Under the condition that the environment variables defined in [Installation](#-installation), users can run examples and test your own samples by executing infer.py.
505
+ The relevant commands for lora models are as follows:
506
+ ```bash
507
+ export FLUX_FILL_PATH="hf://black-forest-labs/FLUX.1-Fill-dev"
508
+ export PORTRAIT_MODEL_PATH="ms://iic/ACE_Plus@portrait/comfyui_portrait_lora64.safetensors"
509
+ export SUBJECT_MODEL_PATH="ms://iic/ACE_Plus@subject/comfyui_subject_lora16.safetensors"
510
+ export LOCAL_MODEL_PATH="ms://iic/ACE_Plus@local_editing/comfyui_local_lora16.safetensors"
511
+ # Use the model from huggingface
512
+ # export PORTRAIT_MODEL_PATH="hf://ali-vilab/ACE_Plus@portrait/comfyui_portrait_lora64.safetensors"
513
+ # export SUBJECT_MODEL_PATH="hf://ali-vilab/ACE_Plus@subject/comfyui_subject_lora16.safetensors"
514
+ # export LOCAL_MODEL_PATH="hf://ali-vilab/ACE_Plus@local_editing/comfyui_local_lora16.safetensors"
515
+ python infer_lora.py
516
+ ```
517
+ The relevant commands for fft models are as follows:
518
+ ```bash
519
+ export FLUX_FILL_PATH="hf://black-forest-labs/FLUX.1-Fill-dev"
520
+ export ACE_PLUS_FFT_MODEL="ms://iic/ACE_Plus@ace_plus_fft.safetensors.safetensors"
521
+ python infer_fft.py
522
+ ```
523
+
524
+ ## 🚀 Train
525
+ We provide training code that allows users to train on their own data. Reference the data in 'data/train.csv' and 'data/eval.csv' to construct the training data and test data, respectively. We use '#;#' to separate fields.
526
+ The required fields include the following six, with their explanations as follows.
527
+ ```angular2html
528
+ "edit_image": represents the input image for the editing task. If it is not an editing task but a reference generation, this field can be left empty.
529
+ "edit_mask": represents the input image mask for the editing task, used to specify the editing area. If it is not an editing task but rather for reference generation, this field can be left empty.
530
+ "ref_image": represents the input image for the reference image generation task; if it is a pure editing task, this field can be left empty.
531
+ "target_image": represents the generated target image and cannot be empty.
532
+ "prompt": represents the prompt for the generation task.
533
+ "data_type": represents the type of data, which can be 'portrait', 'subject', or 'local'. This field is not used in training phase.
534
+ ```
535
+
536
+ All parameters related to training are stored in 'train_config/ace_plus_lora.yaml'. With the following default configuration, the memory usage for LoRA training is between 38GB and 40GB.
537
+
538
+ | Hyperparameter | Value | Description |
539
+ | --- | --- | --- |
540
+ | ATTN_BACKEND | flash_attn / pytorch |Set 'flash_attn' to use flash_attn2(Make sure you have installed flash-attn2 correctly). If the version of PyTorch is greater than 2.4.0, use 'pytorch' to utilize PyTorch's implementation.|
541
+ | USE_GRAD_CHECKPOINT | True / False |Using gradient checkpointing can also significantly reduce GPU memory usage, but it may slow down the training speed. |
542
+ | MAX_SEQ_LEN | 2048 | The MAX_SEQ_LEN refers to the sequence size limit for a single input image (calculated as H/16 * W/16). A larger value indicates a longer computation sequence and a higher training resolution. The default value I provided is 2048.|
543
+
544
+ To run the training code, execute the following command.
545
+
546
+
547
+ ```bash
548
+ export FLUX_FILL_PATH="{path to FLUX.1-Fill-dev}"
549
+ python run_train.py --cfg train_config/ace_plus_lora.yaml
550
+ # Training from fft model
551
+ export FLUX_FILL_PATH="{path to FLUX.1-Fill-dev}"
552
+ export ACE_PLUS_FFT_MODEL="path to ace_plus_fft.safetensors.safetensors"
553
+ python run_train.py --cfg train_config/ace_plus_fft.yaml
554
+ ```
555
+
556
+ The models trained by ACE++ can be found in ./examples/exp_example/xxxx/checkpoints/xxxx/0_SwiftLoRA/comfyui_model.safetensors.
557
+
558
+ ## 💻 Demo
559
+ We have built a GUI demo based on Gradio to help users better utilize the ACE++ model. Just execute the following command.
560
+ ```bash
561
+ export FLUX_FILL_PATH="hf://black-forest-labs/FLUX.1-Fill-dev"
562
+ export PORTRAIT_MODEL_PATH="ms://iic/ACE_Plus@portrait/comfyui_portrait_lora64.safetensors"
563
+ export SUBJECT_MODEL_PATH="ms://iic/ACE_Plus@subject/comfyui_subject_lora16.safetensors"
564
+ export LOCAL_MODEL_PATH="ms://iic/ACE_Plus@local_editing/comfyui_local_lora16.safetensors"
565
+ # Use the model from huggingface
566
+ # export PORTRAIT_MODEL_PATH="hf://ali-vilab/ACE_Plus@portrait/comfyui_portrait_lora64.safetensors"
567
+ # export SUBJECT_MODEL_PATH="hf://ali-vilab/ACE_Plus@subject/comfyui_subject_lora16.safetensors"
568
+ # export LOCAL_MODEL_PATH="hf://ali-vilab/ACE_Plus@local_editing/comfyui_local_lora16.safetensors"
569
+ python demo_lora.py
570
+ # Use the fft model
571
+ export FLUX_FILL_PATH="hf://black-forest-labs/FLUX.1-Fill-dev"
572
+ export ACE_PLUS_FFT_MODEL="ms://iic/ACE_Plus@ace_plus_fft.safetensors.safetensors"
573
+ python demo_fft.py
574
+ ```
575
+
576
+
577
+ ## 📚 Limitations
578
+ * For certain tasks, such as deleting and adding objects, there are flaws in instruction following. For adding and replacing objects, we recommend trying the repainting method of the local editing model to achieve this.
579
+ * The generated results may contain artifacts, especially when it comes to the generation of hands, which still exhibit distortions.
580
+
581
+ ## 📝 Citation
582
+ ACE++ is a post-training model based on the FLUX.1-dev series from black-forest-labs. Please adhere to its open-source license. The test materials used in ACE++ come from the internet and are intended for academic research and communication purposes. If the original creators feel uncomfortable, please contact us to have them removed.
583
+
584
+ If you use this model in your research, please cite the works of FLUX.1-dev and the following papers:
585
+ ```bibtex
586
+ @article{mao2025ace++,
587
+ title={ACE++: Instruction-Based Image Creation and Editing via Context-Aware Content Filling},
588
+ author={Mao, Chaojie and Zhang, Jingfeng and Pan, Yulin and Jiang, Zeyinzi and Han, Zhen and Liu, Yu and Zhou, Jingren},
589
+ journal={arXiv preprint arXiv:2501.02487},
590
+ year={2025}
591
+ }
592
+ ```
593
+ ```bibtex
594
+ @article{han2024ace,
595
+ title={ACE: All-round Creator and Editor Following Instructions via Diffusion Transformer},
596
+ author={Han, Zhen and Jiang, Zeyinzi and Pan, Yulin and Zhang, Jingfeng and Mao, Chaojie and Xie, Chenwei and Liu, Yu and Zhou, Jingren},
597
+ journal={arXiv preprint arXiv:2410.00086},
598
+ year={2024}
599
+ }
600
+ ```
ACE_plus/__init__.py ADDED
@@ -0,0 +1 @@
 
 
1
+ from . import modules
ACE_plus/demo_fft.py ADDED
@@ -0,0 +1,545 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # -*- coding: utf-8 -*-
2
+ # Copyright (c) Alibaba, Inc. and its affiliates.
3
+ import argparse
4
+ import csv
5
+ import glob
6
+ import os
7
+ import sys
8
+ import threading
9
+ import time
10
+
11
+ import gradio as gr
12
+ import numpy as np
13
+ import torch, importlib
14
+ from PIL import Image
15
+ from scepter.modules.transform.io import pillow_convert
16
+ from scepter.modules.utils.config import Config
17
+ from scepter.modules.utils.distribute import we
18
+ from scepter.modules.utils.file_system import FS
19
+
20
+ if os.path.exists('__init__.py'):
21
+ package_name = 'scepter_ext'
22
+ spec = importlib.util.spec_from_file_location(package_name, '__init__.py')
23
+ package = importlib.util.module_from_spec(spec)
24
+ sys.modules[package_name] = package
25
+ spec.loader.exec_module(package)
26
+
27
+ from examples.examples import fft_examples
28
+ from inference.registry import INFERENCES
29
+ from inference.utils import edit_preprocess
30
+
31
+
32
+ fs_list = [
33
+ Config(cfg_dict={"NAME": "HuggingfaceFs", "TEMP_DIR": os.environ["TEMP_DIR"]}, load=False),
34
+ Config(cfg_dict={"NAME": "ModelscopeFs", "TEMP_DIR": os.environ["TEMP_DIR"]}, load=False),
35
+ Config(cfg_dict={"NAME": "HttpFs", "TEMP_DIR": os.environ["TEMP_DIR"]}, load=False),
36
+ Config(cfg_dict={"NAME": "LocalFs", "TEMP_DIR": os.environ["TEMP_DIR"]}, load=False),
37
+ Config(cfg_dict={"NAME": "LocalFs", "TEMP_DIR": os.environ["TEMP_DIR"]}, load=False)
38
+ ]
39
+
40
+ for one_fs in fs_list:
41
+ FS.init_fs_client(one_fs)
42
+
43
+
44
+ csv.field_size_limit(sys.maxsize)
45
+ refresh_sty = '\U0001f504' # 🔄
46
+ clear_sty = '\U0001f5d1' # 🗑️
47
+ upload_sty = '\U0001f5bc' # 🖼️
48
+ sync_sty = '\U0001f4be' # 💾
49
+ chat_sty = '\U0001F4AC' # 💬
50
+ video_sty = '\U0001f3a5' # 🎥
51
+
52
+ lock = threading.Lock()
53
+ class DemoUI(object):
54
+ def __init__(self,
55
+ infer_dir = "./config/ace_plus_fft.yaml"
56
+ ):
57
+ self.model_yamls = [infer_dir]
58
+ self.model_choices = dict()
59
+ self.default_model_name = ''
60
+ self.edit_type_dict = {}
61
+ self.edit_type_list = []
62
+ self.default_type_list = []
63
+ for i in self.model_yamls:
64
+ model_cfg = Config(load=True, cfg_file=i)
65
+ model_name = model_cfg.VERSION
66
+ if model_cfg.IS_DEFAULT: self.default_model_name = model_name
67
+ self.model_choices[model_name] = model_cfg
68
+ for preprocessor in model_cfg.get("PREPROCESSOR", []):
69
+ if preprocessor["TYPE"] in self.edit_type_dict:
70
+ continue
71
+ self.edit_type_dict[preprocessor["TYPE"]] = preprocessor
72
+ self.default_type_list.append(preprocessor["TYPE"])
73
+ print('Models: ', self.model_choices.keys())
74
+ assert len(self.model_choices) > 0
75
+ if self.default_model_name == "": self.default_model_name = list(self.model_choices.keys())[0]
76
+ self.model_name = self.default_model_name
77
+ pipe_cfg = self.model_choices[self.default_model_name]
78
+ self.pipe = INFERENCES.build(pipe_cfg)
79
+ # reformat examples
80
+ self.all_examples = [
81
+ [
82
+ one_example["edit_type"], one_example["instruction"],
83
+ one_example["input_reference_image"], one_example["input_image"],
84
+ one_example["input_mask"], one_example["output_h"],
85
+ one_example["output_w"], one_example["seed"]
86
+ ]
87
+ for one_example in fft_examples
88
+ ]
89
+
90
+ def construct_edit_image(self, edit_image, edit_mask):
91
+ if edit_image is not None and edit_mask is not None:
92
+ edit_image_rgb = pillow_convert(edit_image, "RGB")
93
+ edit_image_rgba = pillow_convert(edit_image, "RGBA")
94
+ edit_mask = pillow_convert(edit_mask, "L")
95
+
96
+ arr1 = np.array(edit_image_rgb)
97
+ arr2 = np.array(edit_mask)[:, :, np.newaxis]
98
+ result_array = np.concatenate((arr1, arr2), axis=2)
99
+ layer = Image.fromarray(result_array)
100
+
101
+ ret_data = {
102
+ "background": edit_image_rgba,
103
+ "composite": edit_image_rgba,
104
+ "layers": [layer]
105
+ }
106
+ return ret_data
107
+ else:
108
+ return None
109
+
110
+ def create_ui(self):
111
+ with gr.Row(equal_height=True, visible=True):
112
+ with gr.Column(scale=2):
113
+ self.gallery_image = gr.Image(
114
+ height=600,
115
+ interactive=False,
116
+ type='pil',
117
+ elem_id='Reference_image'
118
+ )
119
+ with gr.Column(scale=1, visible=True) as self.edit_preprocess_panel:
120
+ with gr.Row():
121
+ with gr.Accordion(label='Related Input Image', open=False):
122
+ self.edit_preprocess_preview = gr.Image(
123
+ height=600,
124
+ interactive=False,
125
+ type='pil',
126
+ elem_id='preprocess_image',
127
+ label='edit image'
128
+ )
129
+
130
+ self.edit_preprocess_mask_preview = gr.Image(
131
+ height=600,
132
+ interactive=False,
133
+ type='pil',
134
+ elem_id='preprocess_image_mask',
135
+ label='edit mask'
136
+ )
137
+
138
+ self.change_preprocess_preview = gr.Image(
139
+ height=600,
140
+ interactive=False,
141
+ type='pil',
142
+ elem_id='preprocess_change_image',
143
+ label='change image'
144
+ )
145
+ with gr.Row():
146
+ instruction = """
147
+ **Instruction**:
148
+ Users can perform reference generation or editing tasks by uploading reference images
149
+ and editing images. When uploading the editing image, various editing types are available
150
+ for selection. Users can choose different dimensions of information preservation,
151
+ such as edge information, color information, and more. Pre-processing information
152
+ can be viewed in the 'related input image' tab.
153
+ """
154
+ self.instruction = gr.Markdown(value=instruction)
155
+ with gr.Row():
156
+ self.icon = gr.Image(
157
+ value=None,
158
+ interactive=False,
159
+ height=150,
160
+ type='pil',
161
+ elem_id='icon',
162
+ label='icon'
163
+ )
164
+ with gr.Row():
165
+ self.model_name_dd = gr.Dropdown(
166
+ choices=self.model_choices,
167
+ value=self.default_model_name,
168
+ label='Model Version')
169
+ self.edit_type = gr.Dropdown(choices=self.default_type_list,
170
+ interactive=True,
171
+ value=self.default_type_list[0],
172
+ label='Edit Type')
173
+ with gr.Row():
174
+ self.step = gr.Slider(minimum=1,
175
+ maximum=1000,
176
+ value=self.pipe.input.get("sample_steps", 20),
177
+ visible=self.pipe.input.get("sample_steps", None) is not None,
178
+ label='Sample Step')
179
+ self.cfg_scale = gr.Slider(
180
+ minimum=1.0,
181
+ maximum=100.0,
182
+ value=self.pipe.input.get("guide_scale", 4.5),
183
+ visible=self.pipe.input.get("guide_scale", None) is not None,
184
+ label='Guidance Scale')
185
+ self.seed = gr.Slider(minimum=-1,
186
+ maximum=1000000000000,
187
+ value=-1,
188
+ label='Seed')
189
+ self.output_height = gr.Slider(
190
+ minimum=256,
191
+ maximum=1440,
192
+ value=self.pipe.input.get("image_size", [1024, 1024])[0],
193
+ visible=self.pipe.input.get("image_size", None) is not None,
194
+ label='Output Height')
195
+ self.output_width = gr.Slider(
196
+ minimum=256,
197
+ maximum=1440,
198
+ value=self.pipe.input.get("image_size", [1024, 1024])[1],
199
+ visible=self.pipe.input.get("image_size", None) is not None,
200
+ label='Output Width')
201
+
202
+ self.repainting_scale = gr.Slider(
203
+ minimum=0.0,
204
+ maximum=1.0,
205
+ value=self.pipe.input.get("repainting_scale", 1.0),
206
+ visible=True,
207
+ label='Repainting Scale')
208
+ self.use_change = gr.Checkbox(
209
+ value=self.pipe.input.get("use_change", True),
210
+ visible=True,
211
+ label='Use Change')
212
+ self.keep_pixel = gr.Checkbox(
213
+ value=self.pipe.input.get("keep_pixel", True),
214
+ visible=True,
215
+ label='Keep Pixels')
216
+ self.keep_pixels_rate = gr.Slider(
217
+ minimum=0.5,
218
+ maximum=1.0,
219
+ value=0.8,
220
+ visible=True,
221
+ label='keep_pixel rate')
222
+ with gr.Row():
223
+ self.generation_info_preview = gr.Markdown(
224
+ label='System Log.',
225
+ show_label=True)
226
+ with gr.Row(variant='panel',
227
+ equal_height=True,
228
+ show_progress=False):
229
+ with gr.Column(scale=10, min_width=500):
230
+ self.text = gr.Textbox(
231
+ placeholder='Input "@" find history of image',
232
+ label='Instruction',
233
+ container=False,
234
+ lines = 1)
235
+ with gr.Column(scale=2, min_width=100):
236
+ with gr.Row():
237
+ with gr.Column(scale=1, min_width=100):
238
+ self.chat_btn = gr.Button(value='Generate', variant = "primary")
239
+
240
+ with gr.Accordion(label='Advance', open=True):
241
+ with gr.Row(visible=True):
242
+ with gr.Column():
243
+ self.reference_image = gr.Image(
244
+ height=1000,
245
+ interactive=True,
246
+ image_mode='RGB',
247
+ type='pil',
248
+ label='Reference Image',
249
+ elem_id='reference_image'
250
+ )
251
+ with gr.Column():
252
+ self.edit_image = gr.ImageMask(
253
+ height=1000,
254
+ interactive=True,
255
+ value=None,
256
+ sources=['upload'],
257
+ type='pil',
258
+ layers=False,
259
+ label='Edit Image',
260
+ elem_id='image_editor',
261
+ show_fullscreen_button=True,
262
+ format="png"
263
+ )
264
+
265
+
266
+ with gr.Row():
267
+ self.eg = gr.Column(visible=True)
268
+
269
+
270
+
271
+ def set_callbacks(self, *args, **kwargs):
272
+ ########################################
273
+ def change_model(model_name):
274
+ if model_name not in self.model_choices:
275
+ gr.Info('The provided model name is not a valid choice!')
276
+ return model_name, gr.update(), gr.update()
277
+
278
+ if model_name != self.model_name:
279
+ lock.acquire()
280
+ del self.pipe
281
+ torch.cuda.empty_cache()
282
+ torch.cuda.ipc_collect()
283
+ pipe_cfg = self.model_choices[model_name]
284
+ self.pipe = INFERENCES.build(pipe_cfg)
285
+ self.model_name = model_name
286
+ lock.release()
287
+
288
+ return (model_name, gr.update(),
289
+ gr.Slider(
290
+ value=self.pipe.input.get("sample_steps", 20),
291
+ visible=self.pipe.input.get("sample_steps", None) is not None),
292
+ gr.Slider(
293
+ value=self.pipe.input.get("guide_scale", 4.5),
294
+ visible=self.pipe.input.get("guide_scale", None) is not None),
295
+ gr.Slider(
296
+ value=self.pipe.input.get("image_size", [1024, 1024])[0],
297
+ visible=self.pipe.input.get("image_size", None) is not None),
298
+ gr.Slider(
299
+ value=self.pipe.input.get("image_size", [1024, 1024])[1],
300
+ visible=self.pipe.input.get("image_size", None) is not None),
301
+ gr.Slider(value=self.pipe.input.get("repainting_scale", 1.0))
302
+ )
303
+
304
+ self.model_name_dd.change(
305
+ change_model,
306
+ inputs=[self.model_name_dd],
307
+ outputs=[
308
+ self.model_name_dd, self.text,
309
+ self.step,
310
+ self.cfg_scale,
311
+ self.output_height,
312
+ self.output_width,
313
+ self.repainting_scale])
314
+
315
+ def change_edit_type(edit_type):
316
+ edit_info = self.edit_type_dict[edit_type]
317
+ edit_info = edit_info or {}
318
+ repainting_scale = edit_info.get("REPAINTING_SCALE", 1.0)
319
+ return gr.Slider(value=repainting_scale)
320
+
321
+ self.edit_type.change(change_edit_type, inputs=[self.edit_type], outputs=[self.repainting_scale])
322
+
323
+ def resize_image(image, h):
324
+ ow, oh = image.size
325
+ w = int(h * ow / oh)
326
+ image = image.resize((w, h), Image.LANCZOS)
327
+ return image
328
+
329
+ def preprocess_input(ref_image, edit_image_dict, preprocess = None):
330
+ err_msg = ""
331
+ is_suc = True
332
+ if ref_image is not None:
333
+ ref_image = pillow_convert(ref_image, "RGB")
334
+
335
+ if edit_image_dict is None:
336
+ edit_image = None
337
+ edit_mask = None
338
+ else:
339
+ edit_image = edit_image_dict["background"]
340
+ edit_mask = np.array(edit_image_dict["layers"][0])[:, :, 3]
341
+ if np.sum(np.array(edit_image)) < 1:
342
+ edit_image = None
343
+ edit_mask = None
344
+ elif np.sum(np.array(edit_mask)) < 1:
345
+ edit_image = pillow_convert(edit_image, "RGB")
346
+ w, h = edit_image.size
347
+ edit_mask = Image.new("L", (w, h), 255)
348
+ else:
349
+ edit_image = pillow_convert(edit_image, "RGB")
350
+ edit_mask = Image.fromarray(edit_mask).convert('L')
351
+ if ref_image is None and edit_image is None:
352
+ err_msg = "Please provide the reference image or edited image."
353
+ return None, None, None, False, err_msg
354
+ return edit_image, edit_mask, ref_image, is_suc, err_msg
355
+
356
+ def run_chat(
357
+ prompt,
358
+ ref_image,
359
+ edit_image,
360
+ edit_type,
361
+ cfg_scale,
362
+ step,
363
+ seed,
364
+ output_h,
365
+ output_w,
366
+ repainting_scale,
367
+ use_change,
368
+ keep_pixel,
369
+ keep_pixels_rate,
370
+ progress=gr.Progress(track_tqdm=True)
371
+ ):
372
+ edit_info = self.edit_type_dict[edit_type]
373
+ pre_edit_image, pre_edit_mask, pre_ref_image, is_suc, err_msg = preprocess_input(ref_image, edit_image)
374
+ icon = pre_edit_image or pre_ref_image
375
+ if not is_suc:
376
+ err_msg = f"<mark>{err_msg}</mark>"
377
+ return (gr.Image(), gr.Column(visible=True),
378
+ gr.Image(),
379
+ gr.Image(),
380
+ gr.Image(),
381
+ gr.Text(value=err_msg))
382
+ pre_edit_image = edit_preprocess(edit_info.ANNOTATOR, we.device_id, pre_edit_image, pre_edit_mask)
383
+ # edit_image["background"] = pre_edit_image
384
+ st = time.time()
385
+ image, edit_image, change_image, mask, seed = self.pipe(
386
+ reference_image=pre_ref_image,
387
+ edit_image=pre_edit_image,
388
+ edit_mask=pre_edit_mask,
389
+ prompt=prompt,
390
+ output_height=output_h,
391
+ output_width=output_w,
392
+ sampler='flow_euler',
393
+ sample_steps=step,
394
+ guide_scale=cfg_scale,
395
+ seed=seed,
396
+ repainting_scale=repainting_scale,
397
+ use_change=use_change,
398
+ keep_pixels=keep_pixel,
399
+ keep_pixels_rate=keep_pixels_rate
400
+ )
401
+ et = time.time()
402
+ msg = f"prompt: {prompt}; seed: {seed}; cost time: {et - st}s; repaiting scale: {repainting_scale}"
403
+
404
+ if icon is not None:
405
+ icon = resize_image(icon, 150)
406
+
407
+ return (gr.Image(value=image), gr.Column(visible=True),
408
+ gr.Image(value=edit_image if edit_image is not None else edit_image),
409
+ gr.Image(value=change_image),
410
+ gr.Image(value=pre_edit_mask if pre_edit_mask is not None else None),
411
+ gr.Text(value=msg),
412
+ gr.Image(value=icon))
413
+
414
+ chat_inputs = [
415
+ self.reference_image,
416
+ self.edit_image,
417
+ self.edit_type,
418
+ self.cfg_scale,
419
+ self.step,
420
+ self.seed,
421
+ self.output_height,
422
+ self.output_width,
423
+ self.repainting_scale,
424
+ self.use_change,
425
+ self.keep_pixel,
426
+ self.keep_pixels_rate
427
+ ]
428
+
429
+ chat_outputs = [
430
+ self.gallery_image, self.edit_preprocess_panel, self.edit_preprocess_preview,
431
+ self.change_preprocess_preview,
432
+ self.edit_preprocess_mask_preview, self.generation_info_preview,
433
+ self.icon
434
+ ]
435
+
436
+ self.chat_btn.click(run_chat,
437
+ inputs=[self.text] + chat_inputs,
438
+ outputs=chat_outputs,
439
+ queue=True)
440
+
441
+ self.text.submit(run_chat,
442
+ inputs=[self.text] + chat_inputs,
443
+ outputs=chat_outputs,
444
+ queue=True)
445
+
446
+ def run_example(edit_type, prompt, ref_image, edit_image, edit_mask,
447
+ output_h, output_w, seed, use_change, keep_pixel,
448
+ keep_pixels_rate,
449
+ progress=gr.Progress(track_tqdm=True)):
450
+
451
+ step = self.pipe.input.get("sample_steps", 20)
452
+ cfg_scale = self.pipe.input.get("guide_scale", 20)
453
+ edit_info = self.edit_type_dict[edit_type]
454
+
455
+ edit_image = self.construct_edit_image(edit_image, edit_mask)
456
+
457
+ pre_edit_image, pre_edit_mask, pre_ref_image, _, _ = preprocess_input(ref_image, edit_image)
458
+
459
+ icon = pre_edit_image or pre_ref_image
460
+
461
+ pre_edit_image = edit_preprocess(edit_info.ANNOTATOR, we.device_id, pre_edit_image, pre_edit_mask)
462
+ edit_info = edit_info or {}
463
+ repainting_scale = edit_info.get("REPAINTING_SCALE", 1.0)
464
+ st = time.time()
465
+ image, edit_image, change_image, mask, seed = self.pipe(
466
+ reference_image=pre_ref_image,
467
+ edit_image=pre_edit_image,
468
+ edit_mask=pre_edit_mask,
469
+ prompt=prompt,
470
+ output_height=output_h,
471
+ output_width=output_w,
472
+ sampler='flow_euler',
473
+ sample_steps=step,
474
+ guide_scale=cfg_scale,
475
+ seed=seed,
476
+ repainting_scale=repainting_scale,
477
+ use_change=use_change,
478
+ keep_pixels=keep_pixel,
479
+ keep_pixels_rate=keep_pixels_rate
480
+ )
481
+ et = time.time()
482
+ msg = f"prompt: {prompt}; seed: {seed}; cost time: {et - st}s; repaiting scale: {repainting_scale}"
483
+ if pre_edit_image is not None:
484
+ ret_image = Image.composite(Image.new("RGB", pre_edit_image.size, (0, 0, 0)), pre_edit_image, pre_edit_mask)
485
+ else:
486
+ ret_image = None
487
+
488
+ if icon is not None:
489
+ icon = resize_image(icon, 150)
490
+ return (gr.Image(value=image), gr.Column(visible=True),
491
+ gr.Image(value=edit_image if edit_image is not None else edit_image),
492
+ gr.Image(value=change_image),
493
+ gr.Image(value=pre_edit_mask if pre_edit_mask is not None else None),
494
+ gr.Text(value=msg),
495
+ gr.update(value=ret_image),
496
+ gr.Image(value= icon))
497
+
498
+ with self.eg:
499
+ self.example_edit_image = gr.Image(label='Edit Image',
500
+ type='pil',
501
+ image_mode='RGB',
502
+ visible=False)
503
+ self.example_edit_mask = gr.Image(label='Edit Image Mask',
504
+ type='pil',
505
+ image_mode='L',
506
+ visible=False)
507
+
508
+ self.examples = gr.Examples(
509
+ fn=run_example,
510
+ examples=self.all_examples,
511
+ inputs=[
512
+ self.edit_type, self.text, self.reference_image, self.example_edit_image,
513
+ self.example_edit_mask, self.output_height, self.output_width, self.seed,
514
+ self.use_change, self.keep_pixel, self.keep_pixels_rate
515
+ ],
516
+ outputs=[self.gallery_image, self.edit_preprocess_panel, self.edit_preprocess_preview,
517
+ self.change_preprocess_preview,
518
+ self.edit_preprocess_mask_preview, self.generation_info_preview,
519
+ self.edit_image,
520
+ self.icon],
521
+ examples_per_page=15,
522
+ cache_examples=False,
523
+ run_on_click=True)
524
+
525
+
526
+ def run_gr(cfg):
527
+ with gr.Blocks() as demo:
528
+ chatbot = DemoUI()
529
+ chatbot.create_ui()
530
+ chatbot.set_callbacks()
531
+ demo.launch(server_name='0.0.0.0',
532
+ server_port=cfg.args.server_port,
533
+ root_path=cfg.args.root_path)
534
+
535
+
536
+ if __name__ == '__main__':
537
+ parser = argparse.ArgumentParser(description='Argparser for Scepter:\n')
538
+ parser.add_argument('--server_port',
539
+ dest='server_port',
540
+ help='',
541
+ type=int,
542
+ default=2345)
543
+ parser.add_argument('--root_path', dest='root_path', help='', default='')
544
+ cfg = Config(load=True, parser_ins=parser)
545
+ run_gr(cfg)
ACE_plus/demo_lora.py ADDED
@@ -0,0 +1,523 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # -*- coding: utf-8 -*-
2
+ # Copyright (c) Alibaba, Inc. and its affiliates.
3
+ import argparse
4
+ import csv
5
+ import glob
6
+ import os
7
+ import sys
8
+ import threading
9
+ import time
10
+
11
+ import gradio as gr
12
+ import numpy as np
13
+ import torch, importlib
14
+ from PIL import Image
15
+ from scepter.modules.transform.io import pillow_convert
16
+ from scepter.modules.utils.config import Config
17
+ from scepter.modules.utils.distribute import we
18
+ from scepter.modules.utils.file_system import FS
19
+
20
+ if os.path.exists('__init__.py'):
21
+ package_name = 'scepter_ext'
22
+ spec = importlib.util.spec_from_file_location(package_name, '__init__.py')
23
+ package = importlib.util.module_from_spec(spec)
24
+ sys.modules[package_name] = package
25
+ spec.loader.exec_module(package)
26
+
27
+ from inference.ace_plus_diffusers import ACEPlusDiffuserInference
28
+ from inference.utils import edit_preprocess
29
+ from examples.examples import all_examples
30
+
31
+ inference_dict = {
32
+ "ACE_DIFFUSER_PLUS": ACEPlusDiffuserInference
33
+ }
34
+
35
+ fs_list = [
36
+ Config(cfg_dict={"NAME": "HuggingfaceFs", "TEMP_DIR": "./cache"}, load=False),
37
+ Config(cfg_dict={"NAME": "ModelscopeFs", "TEMP_DIR": "./cache"}, load=False),
38
+ Config(cfg_dict={"NAME": "HttpFs", "TEMP_DIR": "./cache"}, load=False),
39
+ Config(cfg_dict={"NAME": "LocalFs", "TEMP_DIR": "./cache"}, load=False),
40
+ ]
41
+
42
+ for one_fs in fs_list:
43
+ FS.init_fs_client(one_fs)
44
+
45
+
46
+ csv.field_size_limit(sys.maxsize)
47
+ refresh_sty = '\U0001f504' # 🔄
48
+ clear_sty = '\U0001f5d1' # 🗑️
49
+ upload_sty = '\U0001f5bc' # 🖼️
50
+ sync_sty = '\U0001f4be' # 💾
51
+ chat_sty = '\U0001F4AC' # 💬
52
+ video_sty = '\U0001f3a5' # 🎥
53
+
54
+ lock = threading.Lock()
55
+ class DemoUI(object):
56
+ def __init__(self,
57
+ infer_dir = "./config/ace_plus_diffusers_infer.yaml",
58
+ model_list='./models/model_zoo.yaml'
59
+ ):
60
+ self.model_yamls = [infer_dir]
61
+ self.model_choices = dict()
62
+ self.default_model_name = ''
63
+ for i in self.model_yamls:
64
+ model_cfg = Config(load=True, cfg_file=i)
65
+ model_name = model_cfg.NAME
66
+ if model_cfg.IS_DEFAULT: self.default_model_name = model_name
67
+ self.model_choices[model_name] = model_cfg
68
+ print('Models: ', self.model_choices.keys())
69
+ assert len(self.model_choices) > 0
70
+ if self.default_model_name == "": self.default_model_name = list(self.model_choices.keys())[0]
71
+ self.model_name = self.default_model_name
72
+ pipe_cfg = self.model_choices[self.default_model_name]
73
+ infer_name = pipe_cfg.get("INFERENCE_TYPE", "ACE")
74
+ self.pipe = inference_dict[infer_name]()
75
+ self.pipe.init_from_cfg(pipe_cfg)
76
+
77
+ # choose different model
78
+ self.task_model_cfg = Config(load=True, cfg_file=model_list)
79
+ self.task_model = {}
80
+ self.task_model_list = []
81
+ self.edit_type_dict = {"repainting": None}
82
+ self.edit_type_list = ["repainting"]
83
+ for task_name, task_model in self.task_model_cfg.MODEL.items():
84
+ self.task_model[task_name.lower()] = task_model
85
+ self.task_model_list.append(task_name.lower())
86
+ for preprocessor in task_model.get("PREPROCESSOR", []):
87
+ if preprocessor["TYPE"] in self.edit_type_dict:
88
+ continue
89
+ preprocessor["REPAINTING_SCALE"] = task_model.get("REPAINTING_SCALE", 1.0)
90
+ self.edit_type_dict[preprocessor["TYPE"]] = preprocessor
91
+ self.max_msgs = 20
92
+ # reformat examples
93
+ self.all_examples = [
94
+ [
95
+ one_example["task_type"], one_example["edit_type"], one_example["instruction"],
96
+ one_example["input_reference_image"], one_example["input_image"],
97
+ one_example["input_mask"], one_example["output_h"],
98
+ one_example["output_w"], one_example["seed"]
99
+ ]
100
+ for one_example in all_examples
101
+ ]
102
+
103
+ def construct_edit_image(self, edit_image, edit_mask):
104
+ if edit_image is not None and edit_mask is not None:
105
+ edit_image_rgb = pillow_convert(edit_image, "RGB")
106
+ edit_image_rgba = pillow_convert(edit_image, "RGBA")
107
+ edit_mask = pillow_convert(edit_mask, "L")
108
+
109
+ arr1 = np.array(edit_image_rgb)
110
+ arr2 = np.array(edit_mask)[:, :, np.newaxis]
111
+ result_array = np.concatenate((arr1, arr2), axis=2)
112
+ layer = Image.fromarray(result_array)
113
+
114
+ ret_data = {
115
+ "background": edit_image_rgba,
116
+ "composite": edit_image_rgba,
117
+ "layers": [layer]
118
+ }
119
+ return ret_data
120
+ else:
121
+ return None
122
+
123
+
124
+
125
+
126
+ def create_ui(self):
127
+ with gr.Row(equal_height=True, visible=True):
128
+ with gr.Column(scale=2):
129
+ self.gallery_image = gr.Image(
130
+ height=600,
131
+ interactive=False,
132
+ type='pil',
133
+ elem_id='Reference_image'
134
+ )
135
+ with gr.Column(scale=1, visible=True) as self.edit_preprocess_panel:
136
+ with gr.Row():
137
+ with gr.Accordion(label='Related Input Image', open=False):
138
+ self.edit_preprocess_preview = gr.Image(
139
+ height=600,
140
+ interactive=False,
141
+ type='pil',
142
+ elem_id='preprocess_image'
143
+ )
144
+
145
+ self.edit_preprocess_mask_preview = gr.Image(
146
+ height=600,
147
+ interactive=False,
148
+ type='pil',
149
+ elem_id='preprocess_image_mask'
150
+ )
151
+ with gr.Row():
152
+ instruction = """
153
+ **Instruction**:
154
+ 1. Please choose the Task Type based on the scenario of the generation task. We provide three types of generation capabilities: Portrait ID Preservation Generation(portrait),
155
+ Object ID Preservation Generation(subject), and Local Controlled Generation(local editing), which can be selected from the task dropdown menu.
156
+ 2. When uploading images in the Reference Image section, the generated image will reference the ID information of that image. Please ensure that the ID information is clear.
157
+ In the Edit Image section, the uploaded image will maintain its structural and content information, and you must draw a mask area to specify the region to be regenerated.
158
+ 3. When the task type is local editing, there are various editing types to choose from. Users can select different information preserving dimensions, such as edge information,
159
+ color information, and more. The pre-processing information can be viewed in the 'related input image' tab.
160
+ """
161
+ self.instruction = gr.Markdown(value=instruction)
162
+ with gr.Row():
163
+ self.model_name_dd = gr.Dropdown(
164
+ choices=self.model_choices,
165
+ value=self.default_model_name,
166
+ label='Model Version')
167
+ self.task_type = gr.Dropdown(choices=self.task_model_list,
168
+ interactive=True,
169
+ value=self.task_model_list[0],
170
+ label='Task Type')
171
+ self.edit_type = gr.Dropdown(choices=self.edit_type_list,
172
+ interactive=True,
173
+ value=self.edit_type_list[0],
174
+ label='Edit Type')
175
+ with gr.Row():
176
+ self.generation_info_preview = gr.Markdown(
177
+ label='System Log.',
178
+ show_label=True)
179
+ with gr.Row(variant='panel',
180
+ equal_height=True,
181
+ show_progress=False):
182
+ with gr.Column(scale=10, min_width=500):
183
+ self.text = gr.Textbox(
184
+ placeholder='Input "@" find history of image',
185
+ label='Instruction',
186
+ container=False,
187
+ lines = 1)
188
+ with gr.Column(scale=2, min_width=100):
189
+ with gr.Row():
190
+ with gr.Column(scale=1, min_width=100):
191
+ self.chat_btn = gr.Button(value='Generate', variant = "primary")
192
+
193
+ with gr.Accordion(label='Advance', open=True):
194
+ with gr.Row(visible=True):
195
+ with gr.Column():
196
+ self.reference_image = gr.Image(
197
+ height=1000,
198
+ interactive=True,
199
+ image_mode='RGB',
200
+ type='pil',
201
+ label='Reference Image',
202
+ elem_id='reference_image'
203
+ )
204
+ with gr.Column():
205
+ self.edit_image = gr.ImageMask(
206
+ height=1000,
207
+ interactive=True,
208
+ value=None,
209
+ sources=['upload'],
210
+ type='pil',
211
+ layers=False,
212
+ label='Edit Image',
213
+ elem_id='image_editor',
214
+ show_fullscreen_button=True,
215
+ format="png"
216
+ )
217
+
218
+ with gr.Row():
219
+ self.step = gr.Slider(minimum=1,
220
+ maximum=1000,
221
+ value=self.pipe.input.get("sample_steps", 20),
222
+ visible=self.pipe.input.get("sample_steps", None) is not None,
223
+ label='Sample Step')
224
+ self.cfg_scale = gr.Slider(
225
+ minimum=1.0,
226
+ maximum=100.0,
227
+ value=self.pipe.input.get("guide_scale", 4.5),
228
+ visible=self.pipe.input.get("guide_scale", None) is not None,
229
+ label='Guidance Scale')
230
+ self.seed = gr.Slider(minimum=-1,
231
+ maximum=10000000,
232
+ value=-1,
233
+ label='Seed')
234
+ self.output_height = gr.Slider(
235
+ minimum=256,
236
+ maximum=1440,
237
+ value=self.pipe.input.get("output_height", 1024),
238
+ visible=self.pipe.input.get("output_height", None) is not None,
239
+ label='Output Height')
240
+ self.output_width = gr.Slider(
241
+ minimum=256,
242
+ maximum=1440,
243
+ value=self.pipe.input.get("output_width", 1024),
244
+ visible=self.pipe.input.get("output_width", None) is not None,
245
+ label='Output Width')
246
+
247
+ self.repainting_scale = gr.Slider(
248
+ minimum=0.0,
249
+ maximum=1.0,
250
+ value=self.pipe.input.get("repainting_scale", 1.0),
251
+ visible=True,
252
+ label='Repainting Scale')
253
+ with gr.Row():
254
+ self.eg = gr.Column(visible=True)
255
+
256
+
257
+
258
+ def set_callbacks(self, *args, **kwargs):
259
+ ########################################
260
+ def change_model(model_name):
261
+ if model_name not in self.model_choices:
262
+ gr.Info('The provided model name is not a valid choice!')
263
+ return model_name, gr.update(), gr.update()
264
+
265
+ if model_name != self.model_name:
266
+ lock.acquire()
267
+ del self.pipe
268
+ torch.cuda.empty_cache()
269
+ torch.cuda.ipc_collect()
270
+ pipe_cfg = self.model_choices[model_name]
271
+ infer_name = pipe_cfg.get("INFERENCE_TYPE", "ACE")
272
+ self.pipe = inference_dict[infer_name]()
273
+ self.pipe.init_from_cfg(pipe_cfg)
274
+ self.model_name = model_name
275
+ lock.release()
276
+
277
+ return (model_name, gr.update(),
278
+ gr.Slider(
279
+ value=self.pipe.input.get("sample_steps", 20),
280
+ visible=self.pipe.input.get("sample_steps", None) is not None),
281
+ gr.Slider(
282
+ value=self.pipe.input.get("guide_scale", 4.5),
283
+ visible=self.pipe.input.get("guide_scale", None) is not None),
284
+ gr.Slider(
285
+ value=self.pipe.input.get("output_height", 1024),
286
+ visible=self.pipe.input.get("output_height", None) is not None),
287
+ gr.Slider(
288
+ value=self.pipe.input.get("output_width", 1024),
289
+ visible=self.pipe.input.get("output_width", None) is not None),
290
+ gr.Slider(value=self.pipe.input.get("repainting_scale", 1.0))
291
+ )
292
+
293
+ self.model_name_dd.change(
294
+ change_model,
295
+ inputs=[self.model_name_dd],
296
+ outputs=[
297
+ self.model_name_dd, self.text,
298
+ self.step,
299
+ self.cfg_scale,
300
+ self.output_height,
301
+ self.output_width,
302
+ self.repainting_scale])
303
+
304
+ def change_task_type(task_type):
305
+ task_info = self.task_model[task_type]
306
+ edit_type_list = [self.edit_type_list[0]]
307
+ for preprocessor in task_info.get("PREPROCESSOR", []):
308
+ preprocessor["REPAINTING_SCALE"] = task_info.get("REPAINTING_SCALE", 1.0)
309
+ self.edit_type_dict[preprocessor["TYPE"]] = preprocessor
310
+ edit_type_list.append(preprocessor["TYPE"])
311
+
312
+ return gr.update(choices=edit_type_list, value=edit_type_list[0])
313
+
314
+ self.task_type.change(change_task_type, inputs=[self.task_type], outputs=[self.edit_type])
315
+
316
+ def change_edit_type(edit_type):
317
+ edit_info = self.edit_type_dict[edit_type]
318
+ edit_info = edit_info or {}
319
+ repainting_scale = edit_info.get("REPAINTING_SCALE", 1.0)
320
+ if edit_type == self.edit_type_list[0]:
321
+ return gr.Slider(value=1.0)
322
+ else:
323
+ return gr.Slider(
324
+ value=repainting_scale)
325
+
326
+ self.edit_type.change(change_edit_type, inputs=[self.edit_type], outputs=[self.repainting_scale])
327
+
328
+ def preprocess_input(ref_image, edit_image_dict, preprocess = None):
329
+ err_msg = ""
330
+ is_suc = True
331
+ if ref_image is not None:
332
+ ref_image = pillow_convert(ref_image, "RGB")
333
+
334
+ if edit_image_dict is None:
335
+ edit_image = None
336
+ edit_mask = None
337
+ else:
338
+ edit_image = edit_image_dict["background"]
339
+ edit_mask = np.array(edit_image_dict["layers"][0])[:, :, 3]
340
+ if np.sum(np.array(edit_image)) < 1:
341
+ edit_image = None
342
+ edit_mask = None
343
+ elif np.sum(np.array(edit_mask)) < 1:
344
+ err_msg = "You must draw the repainting area for the edited image."
345
+ return None, None, None, False, err_msg
346
+ else:
347
+ edit_image = pillow_convert(edit_image, "RGB")
348
+ edit_mask = Image.fromarray(edit_mask).convert('L')
349
+ if ref_image is None and edit_image is None:
350
+ err_msg = "Please provide the reference image or edited image."
351
+ return None, None, None, False, err_msg
352
+ return edit_image, edit_mask, ref_image, is_suc, err_msg
353
+
354
+ def run_chat(
355
+ prompt,
356
+ ref_image,
357
+ edit_image,
358
+ task_type,
359
+ edit_type,
360
+ cfg_scale,
361
+ step,
362
+ seed,
363
+ output_h,
364
+ output_w,
365
+ repainting_scale,
366
+ progress=gr.Progress(track_tqdm=True)
367
+ ):
368
+ model_path = self.task_model[task_type]["MODEL_PATH"]
369
+ edit_info = self.edit_type_dict[edit_type]
370
+
371
+ if task_type in ["portrait", "subject"] and ref_image is None:
372
+ err_msg = "<mark>Please provide the reference image.</mark>"
373
+ return (gr.Image(), gr.Column(visible=True),
374
+ gr.Image(),
375
+ gr.Image(),
376
+ gr.Text(value=err_msg))
377
+
378
+ pre_edit_image, pre_edit_mask, pre_ref_image, is_suc, err_msg = preprocess_input(ref_image, edit_image)
379
+ if not is_suc:
380
+ err_msg = f"<mark>{err_msg}</mark>"
381
+ return (gr.Image(), gr.Column(visible=True),
382
+ gr.Image(),
383
+ gr.Image(),
384
+ gr.Text(value=err_msg))
385
+ pre_edit_image = edit_preprocess(edit_info, we.device_id, pre_edit_image, pre_edit_mask)
386
+ # edit_image["background"] = pre_edit_image
387
+ st = time.time()
388
+ image, seed = self.pipe(
389
+ reference_image=pre_ref_image,
390
+ edit_image=pre_edit_image,
391
+ edit_mask=pre_edit_mask,
392
+ prompt=prompt,
393
+ output_height=output_h,
394
+ output_width=output_w,
395
+ sampler='flow_euler',
396
+ sample_steps=step,
397
+ guide_scale=cfg_scale,
398
+ seed=seed,
399
+ repainting_scale=repainting_scale,
400
+ lora_path = model_path
401
+ )
402
+ et = time.time()
403
+ msg = f"prompt: {prompt}; seed: {seed}; cost time: {et - st}s; repaiting scale: {repainting_scale}"
404
+
405
+ return (gr.Image(value=image), gr.Column(visible=True),
406
+ gr.Image(value=pre_edit_image if pre_edit_image is not None else pre_ref_image),
407
+ gr.Image(value=pre_edit_mask if pre_edit_mask is not None else None),
408
+ gr.Text(value=msg))
409
+
410
+ chat_inputs = [
411
+ self.reference_image,
412
+ self.edit_image,
413
+ self.task_type,
414
+ self.edit_type,
415
+ self.cfg_scale,
416
+ self.step,
417
+ self.seed,
418
+ self.output_height,
419
+ self.output_width,
420
+ self.repainting_scale
421
+ ]
422
+
423
+ chat_outputs = [
424
+ self.gallery_image, self.edit_preprocess_panel, self.edit_preprocess_preview,
425
+ self.edit_preprocess_mask_preview, self.generation_info_preview
426
+ ]
427
+
428
+ self.chat_btn.click(run_chat,
429
+ inputs=[self.text] + chat_inputs,
430
+ outputs=chat_outputs,
431
+ queue=True)
432
+
433
+ self.text.submit(run_chat,
434
+ inputs=[self.text] + chat_inputs,
435
+ outputs=chat_outputs,
436
+ queue=True)
437
+
438
+ def run_example(task_type, edit_type, prompt, ref_image, edit_image, edit_mask,
439
+ output_h, output_w, seed, progress=gr.Progress(track_tqdm=True)):
440
+ model_path = self.task_model[task_type]["MODEL_PATH"]
441
+
442
+ step = self.pipe.input.get("sample_steps", 20)
443
+ cfg_scale = self.pipe.input.get("guide_scale", 20)
444
+
445
+ edit_info = self.edit_type_dict[edit_type]
446
+
447
+ edit_image = self.construct_edit_image(edit_image, edit_mask)
448
+
449
+ pre_edit_image, pre_edit_mask, pre_ref_image, _, _ = preprocess_input(ref_image, edit_image)
450
+ pre_edit_image = edit_preprocess(edit_info, we.device_id, pre_edit_image, pre_edit_mask)
451
+ edit_info = edit_info or {}
452
+ repainting_scale = edit_info.get("REPAINTING_SCALE", 1.0)
453
+ st = time.time()
454
+ image, seed = self.pipe(
455
+ reference_image=pre_ref_image,
456
+ edit_image=pre_edit_image,
457
+ edit_mask=pre_edit_mask,
458
+ prompt=prompt,
459
+ output_height=output_h,
460
+ output_width=output_w,
461
+ sampler='flow_euler',
462
+ sample_steps=step,
463
+ guide_scale=cfg_scale,
464
+ seed=seed,
465
+ repainting_scale=repainting_scale,
466
+ lora_path=model_path
467
+ )
468
+ et = time.time()
469
+ msg = f"prompt: {prompt}; seed: {seed}; cost time: {et - st}s; repaiting scale: {repainting_scale}"
470
+ if pre_edit_image is not None:
471
+ ret_image = Image.composite(Image.new("RGB", pre_edit_image.size, (0, 0, 0)), pre_edit_image, pre_edit_mask)
472
+ else:
473
+ ret_image = None
474
+ return (gr.Image(value=image), gr.Column(visible=True),
475
+ gr.Image(value=pre_edit_image if pre_edit_image is not None else pre_ref_image),
476
+ gr.Image(value=pre_edit_mask if pre_edit_mask is not None else None),
477
+ gr.Text(value=msg),
478
+ gr.update(value=ret_image))
479
+
480
+ with self.eg:
481
+ self.example_edit_image = gr.Image(label='Edit Image',
482
+ type='pil',
483
+ image_mode='RGB',
484
+ visible=False)
485
+ self.example_edit_mask = gr.Image(label='Edit Image Mask',
486
+ type='pil',
487
+ image_mode='L',
488
+ visible=False)
489
+
490
+ self.examples = gr.Examples(
491
+ fn=run_example,
492
+ examples=self.all_examples,
493
+ inputs=[
494
+ self.task_type, self.edit_type, self.text, self.reference_image, self.example_edit_image,
495
+ self.example_edit_mask, self.output_height, self.output_width, self.seed
496
+ ],
497
+ outputs=[self.gallery_image, self.edit_preprocess_panel, self.edit_preprocess_preview,
498
+ self.edit_preprocess_mask_preview, self.generation_info_preview, self.edit_image],
499
+ examples_per_page=6,
500
+ cache_examples=False,
501
+ run_on_click=True)
502
+
503
+
504
+ def run_gr(cfg):
505
+ with gr.Blocks() as demo:
506
+ chatbot = DemoUI()
507
+ chatbot.create_ui()
508
+ chatbot.set_callbacks()
509
+ demo.launch(server_name='0.0.0.0',
510
+ server_port=cfg.args.server_port,
511
+ root_path=cfg.args.root_path)
512
+
513
+
514
+ if __name__ == '__main__':
515
+ parser = argparse.ArgumentParser(description='Argparser for Scepter:\n')
516
+ parser.add_argument('--server_port',
517
+ dest='server_port',
518
+ help='',
519
+ type=int,
520
+ default=2345)
521
+ parser.add_argument('--root_path', dest='root_path', help='', default='')
522
+ cfg = Config(load=True, parser_ins=parser)
523
+ run_gr(cfg)
ACE_plus/infer_fft.py ADDED
@@ -0,0 +1,178 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # -*- coding: utf-8 -*-
2
+ # Copyright (c) Alibaba, Inc. and its affiliates.
3
+ import argparse
4
+ import glob
5
+ import importlib
6
+ import io
7
+ import os
8
+ import sys
9
+
10
+ from PIL import Image
11
+ from scepter.modules.transform.io import pillow_convert
12
+ from scepter.modules.utils.config import Config
13
+ from scepter.modules.utils.file_system import FS
14
+
15
+ if os.path.exists('__init__.py'):
16
+ package_name = 'scepter_ext'
17
+ spec = importlib.util.spec_from_file_location(package_name, '__init__.py')
18
+ package = importlib.util.module_from_spec(spec)
19
+ sys.modules[package_name] = package
20
+ spec.loader.exec_module(package)
21
+
22
+ from examples.examples import fft_examples as all_examples
23
+ from inference.registry import INFERENCES
24
+ fs_list = [
25
+ Config(cfg_dict={"NAME": "HuggingfaceFs", "TEMP_DIR": "./cache"}, load=False),
26
+ Config(cfg_dict={"NAME": "ModelscopeFs", "TEMP_DIR": "./cache"}, load=False),
27
+ Config(cfg_dict={"NAME": "HttpFs", "TEMP_DIR": "./cache"}, load=False),
28
+ Config(cfg_dict={"NAME": "LocalFs", "TEMP_DIR": "./cache"}, load=False),
29
+ ]
30
+
31
+ for one_fs in fs_list:
32
+ FS.init_fs_client(one_fs)
33
+
34
+
35
+ def run_one_case(pipe,
36
+ input_image = None,
37
+ input_mask = None,
38
+ input_reference_image = None,
39
+ save_path = "examples/output/example.png",
40
+ instruction = "",
41
+ output_h = 1024,
42
+ output_w = 1024,
43
+ seed = -1,
44
+ sample_steps = None,
45
+ guide_scale = None,
46
+ repainting_scale = None,
47
+ use_change=True,
48
+ keep_pixels=True,
49
+ keep_pixels_rate=0.8,
50
+ **kwargs):
51
+ if input_image is not None:
52
+ input_image = Image.open(io.BytesIO(FS.get_object(input_image)))
53
+ input_image = pillow_convert(input_image, "RGB")
54
+ if input_mask is not None:
55
+ input_mask = Image.open(io.BytesIO(FS.get_object(input_mask)))
56
+ input_mask = pillow_convert(input_mask, "L")
57
+ if input_reference_image is not None:
58
+ input_reference_image = Image.open(io.BytesIO(FS.get_object(input_reference_image)))
59
+ input_reference_image = pillow_convert(input_reference_image, "RGB")
60
+ print(repainting_scale)
61
+ image, _, _, _, seed = pipe(
62
+ reference_image=input_reference_image,
63
+ edit_image=input_image,
64
+ edit_mask=input_mask,
65
+ prompt=instruction,
66
+ output_height=output_h,
67
+ output_width=output_w,
68
+ sampler='flow_euler',
69
+ sample_steps=sample_steps or pipe.input.get("sample_steps", 28),
70
+ guide_scale=guide_scale or pipe.input.get("guide_scale", 50),
71
+ seed=seed,
72
+ repainting_scale=repainting_scale,
73
+ use_change=use_change,
74
+ keep_pixels=keep_pixels,
75
+ keep_pixels_rate=keep_pixels_rate
76
+ )
77
+ with FS.put_to(save_path) as local_path:
78
+ image.save(local_path)
79
+ return local_path, seed
80
+
81
+
82
+ def run():
83
+ parser = argparse.ArgumentParser(description='Argparser for Scepter:\n')
84
+ parser.add_argument('--instruction',
85
+ dest='instruction',
86
+ help='The instruction for editing or generating!',
87
+ default="")
88
+ parser.add_argument('--output_h',
89
+ dest='output_h',
90
+ help='The height of output image for generation tasks!',
91
+ type=int,
92
+ default=1024)
93
+ parser.add_argument('--output_w',
94
+ dest='output_w',
95
+ help='The width of output image for generation tasks!',
96
+ type=int,
97
+ default=1024)
98
+ parser.add_argument('--input_reference_image',
99
+ dest='input_reference_image',
100
+ help='The input reference image!',
101
+ default=None
102
+ )
103
+ parser.add_argument('--input_image',
104
+ dest='input_image',
105
+ help='The input image!',
106
+ default=None
107
+ )
108
+ parser.add_argument('--input_mask',
109
+ dest='input_mask',
110
+ help='The input mask!',
111
+ default=None
112
+ )
113
+ parser.add_argument('--save_path',
114
+ dest='save_path',
115
+ help='The save path for output image!',
116
+ default='examples/output_images/output.png'
117
+ )
118
+ parser.add_argument('--seed',
119
+ dest='seed',
120
+ help='The seed for generation!',
121
+ type=int,
122
+ default=-1)
123
+
124
+ parser.add_argument('--step',
125
+ dest='step',
126
+ help='The sample step for generation!',
127
+ type=int,
128
+ default=None)
129
+
130
+ parser.add_argument('--guide_scale',
131
+ dest='guide_scale',
132
+ help='The guide scale for generation!',
133
+ type=int,
134
+ default=None)
135
+
136
+ parser.add_argument('--repainting_scale',
137
+ dest='repainting_scale',
138
+ help='The repainting scale for content filling generation!',
139
+ type=int,
140
+ default=None)
141
+
142
+ cfg = Config(load=True, parser_ins=parser)
143
+ model_cfg = Config(load=True, cfg_file="config/ace_plus_fft.yaml")
144
+ pipe = INFERENCES.build(model_cfg)
145
+
146
+
147
+ if cfg.args.instruction == "" and cfg.args.input_image is None and cfg.args.input_reference_image is None:
148
+ params = {
149
+ "output_h": cfg.args.output_h,
150
+ "output_w": cfg.args.output_w,
151
+ "sample_steps": cfg.args.step,
152
+ "guide_scale": cfg.args.guide_scale
153
+ }
154
+ # run examples
155
+
156
+ for example in all_examples:
157
+ example.update(params)
158
+ local_path, seed = run_one_case(pipe, **example)
159
+
160
+ else:
161
+ params = {
162
+ "input_image": cfg.args.input_image,
163
+ "input_mask": cfg.args.input_mask,
164
+ "input_reference_image": cfg.args.input_reference_image,
165
+ "save_path": cfg.args.save_path,
166
+ "instruction": cfg.args.instruction,
167
+ "output_h": cfg.args.output_h,
168
+ "output_w": cfg.args.output_w,
169
+ "sample_steps": cfg.args.step,
170
+ "guide_scale": cfg.args.guide_scale,
171
+ "repainting_scale": cfg.args.repainting_scale,
172
+ }
173
+ local_path, seed = run_one_case(pipe, **params)
174
+ print(local_path, seed)
175
+
176
+ if __name__ == '__main__':
177
+ run()
178
+
ACE_plus/infer_lora.py ADDED
@@ -0,0 +1,228 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # -*- coding: utf-8 -*-
2
+ # Copyright (c) Alibaba, Inc. and its affiliates.
3
+ import argparse
4
+ import glob
5
+ import io
6
+ import os
7
+
8
+ from PIL import Image
9
+ from scepter.modules.transform.io import pillow_convert
10
+ from scepter.modules.utils.config import Config
11
+ from scepter.modules.utils.file_system import FS
12
+
13
+ from examples.examples import all_examples
14
+ from inference.ace_plus_diffusers import ACEPlusDiffuserInference
15
+ inference_dict = {
16
+ "ACE_DIFFUSER_PLUS": ACEPlusDiffuserInference
17
+ }
18
+
19
+ fs_list = [
20
+ Config(cfg_dict={"NAME": "HuggingfaceFs", "TEMP_DIR": "./cache"}, load=False),
21
+ Config(cfg_dict={"NAME": "ModelscopeFs", "TEMP_DIR": "./cache"}, load=False),
22
+ Config(cfg_dict={"NAME": "HttpFs", "TEMP_DIR": "./cache"}, load=False),
23
+ Config(cfg_dict={"NAME": "LocalFs", "TEMP_DIR": "./cache"}, load=False),
24
+ ]
25
+
26
+ for one_fs in fs_list:
27
+ FS.init_fs_client(one_fs)
28
+
29
+
30
+ def run_one_case(pipe,
31
+ input_image = None,
32
+ input_mask = None,
33
+ input_reference_image = None,
34
+ save_path = "examples/output/example.png",
35
+ instruction = "",
36
+ output_h = 1024,
37
+ output_w = 1024,
38
+ seed = -1,
39
+ sample_steps = None,
40
+ guide_scale = None,
41
+ repainting_scale = None,
42
+ model_path = None,
43
+ **kwargs):
44
+ if input_image is not None:
45
+ input_image = Image.open(io.BytesIO(FS.get_object(input_image)))
46
+ input_image = pillow_convert(input_image, "RGB")
47
+ if input_mask is not None:
48
+ input_mask = Image.open(io.BytesIO(FS.get_object(input_mask)))
49
+ input_mask = pillow_convert(input_mask, "L")
50
+ if input_reference_image is not None:
51
+ input_reference_image = Image.open(io.BytesIO(FS.get_object(input_reference_image)))
52
+ input_reference_image = pillow_convert(input_reference_image, "RGB")
53
+
54
+ image, seed = pipe(
55
+ reference_image=input_reference_image,
56
+ edit_image=input_image,
57
+ edit_mask=input_mask,
58
+ prompt=instruction,
59
+ output_height=output_h,
60
+ output_width=output_w,
61
+ sampler='flow_euler',
62
+ sample_steps=sample_steps or pipe.input.get("sample_steps", 28),
63
+ guide_scale=guide_scale or pipe.input.get("guide_scale", 50),
64
+ seed=seed,
65
+ repainting_scale=repainting_scale or pipe.input.get("repainting_scale", 1.0),
66
+ lora_path = model_path
67
+ )
68
+ with FS.put_to(save_path) as local_path:
69
+ image.save(local_path)
70
+ return local_path, seed
71
+
72
+
73
+ def run():
74
+ parser = argparse.ArgumentParser(description='Argparser for Scepter:\n')
75
+ parser.add_argument('--instruction',
76
+ dest='instruction',
77
+ help='The instruction for editing or generating!',
78
+ default="")
79
+ parser.add_argument('--output_h',
80
+ dest='output_h',
81
+ help='The height of output image for generation tasks!',
82
+ type=int,
83
+ default=1024)
84
+ parser.add_argument('--output_w',
85
+ dest='output_w',
86
+ help='The width of output image for generation tasks!',
87
+ type=int,
88
+ default=1024)
89
+ parser.add_argument('--input_reference_image',
90
+ dest='input_reference_image',
91
+ help='The input reference image!',
92
+ default=None
93
+ )
94
+ parser.add_argument('--input_image',
95
+ dest='input_image',
96
+ help='The input image!',
97
+ default=None
98
+ )
99
+ parser.add_argument('--input_mask',
100
+ dest='input_mask',
101
+ help='The input mask!',
102
+ default=None
103
+ )
104
+ parser.add_argument('--save_path',
105
+ dest='save_path',
106
+ help='The save path for output image!',
107
+ default='examples/output_images/output.png'
108
+ )
109
+ parser.add_argument('--seed',
110
+ dest='seed',
111
+ help='The seed for generation!',
112
+ type=int,
113
+ default=-1)
114
+
115
+ parser.add_argument('--step',
116
+ dest='step',
117
+ help='The sample step for generation!',
118
+ type=int,
119
+ default=None)
120
+
121
+ parser.add_argument('--guide_scale',
122
+ dest='guide_scale',
123
+ help='The guide scale for generation!',
124
+ type=int,
125
+ default=None)
126
+
127
+ parser.add_argument('--repainting_scale',
128
+ dest='repainting_scale',
129
+ help='The repainting scale for content filling generation!',
130
+ type=int,
131
+ default=None)
132
+
133
+ parser.add_argument('--task_type',
134
+ dest='task_type',
135
+ choices=['portrait', 'subject', 'local_editing'],
136
+ help="Choose the task type.",
137
+ default='')
138
+
139
+ parser.add_argument('--task_model',
140
+ dest='task_model',
141
+ help='The models list for different tasks!',
142
+ default="./models/model_zoo.yaml")
143
+
144
+
145
+ parser.add_argument('--infer_type',
146
+ dest='infer_type',
147
+ choices=['diffusers'],
148
+ default='diffusers',
149
+ help="Choose the inference scripts. 'native' refers to using the official implementation of ace++, "
150
+ "while 'diffusers' refers to using the adaptation for diffusers")
151
+
152
+ parser.add_argument('--cfg_folder',
153
+ dest='cfg_folder',
154
+ help='The inference config!',
155
+ default="./config")
156
+
157
+ cfg = Config(load=True, parser_ins=parser)
158
+
159
+ model_yamls = glob.glob(os.path.join(cfg.args.cfg_folder, '*.yaml'))
160
+ model_choices = dict()
161
+ for i in model_yamls:
162
+ model_cfg = Config(load=True, cfg_file=i)
163
+ model_name = model_cfg.NAME
164
+ model_choices[model_name] = model_cfg
165
+
166
+ if cfg.args.infer_type == "native":
167
+ infer_name = "ace_plus_native_infer"
168
+ elif cfg.args.infer_type == "diffusers":
169
+ infer_name = "ace_plus_diffuser_infer"
170
+ else:
171
+ raise ValueError("infer_type should be native or diffusers")
172
+
173
+ assert infer_name in model_choices
174
+
175
+ # choose different model
176
+ task_model_cfg = Config(load=True, cfg_file=cfg.args.task_model)
177
+
178
+ task_model_dict = {}
179
+ for task_name, task_model in task_model_cfg.MODEL.items():
180
+ task_model_dict[task_name] = task_model
181
+
182
+
183
+ # choose the inference scripts.
184
+ pipe_cfg = model_choices[infer_name]
185
+ infer_name = pipe_cfg.get("INFERENCE_TYPE", "ACE_PLUS")
186
+ pipe = inference_dict[infer_name]()
187
+ pipe.init_from_cfg(pipe_cfg)
188
+
189
+ if cfg.args.instruction == "" and cfg.args.input_image is None and cfg.args.input_reference_image is None:
190
+ params = {
191
+ "output_h": cfg.args.output_h,
192
+ "output_w": cfg.args.output_w,
193
+ "sample_steps": cfg.args.step,
194
+ "guide_scale": cfg.args.guide_scale
195
+ }
196
+ # run examples
197
+
198
+ for example in all_examples:
199
+ example["model_path"] = FS.get_from(task_model_dict[example["task_type"].upper()]["MODEL_PATH"])
200
+ example.update(params)
201
+ if example["edit_type"] == "repainting":
202
+ example["repainting_scale"] = 1.0
203
+ else:
204
+ example["repainting_scale"] = task_model_dict[example["task_type"].upper()].get("REPAINTING_SCALE", 1.0)
205
+ print(example)
206
+ local_path, seed = run_one_case(pipe, **example)
207
+
208
+ else:
209
+ assert cfg.args.task_type.upper() in task_model_cfg
210
+ params = {
211
+ "input_image": cfg.args.input_image,
212
+ "input_mask": cfg.args.input_mask,
213
+ "input_reference_image": cfg.args.input_reference_image,
214
+ "save_path": cfg.args.save_path,
215
+ "instruction": cfg.args.instruction,
216
+ "output_h": cfg.args.output_h,
217
+ "output_w": cfg.args.output_w,
218
+ "sample_steps": cfg.args.step,
219
+ "guide_scale": cfg.args.guide_scale,
220
+ "repainting_scale": cfg.args.repainting_scale,
221
+ "model_path": FS.get_from(task_model_dict[cfg.args.task_type.upper()]["MODEL_PATH"])
222
+ }
223
+ local_path, seed = run_one_case(pipe, **params)
224
+ print(local_path, seed)
225
+
226
+ if __name__ == '__main__':
227
+ run()
228
+
ACE_plus/install.py ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # -*- coding: utf-8 -*-
2
+ # Copyright (c) Alibaba, Inc. and its affiliates.
3
+ import os
4
+ import shutil
5
+ import sys
6
+
7
+
8
+ if sys.argv[0] == 'install.py':
9
+ sys.path.append('.')
10
+
11
+ current_dir = os.path.dirname(__file__)
12
+ source_folder = os.path.join(current_dir, "workflow/ComfyUI-ACE_Plus")
13
+ target_folder = os.path.join(os.path.dirname(current_dir), "ComfyUI-ACE_Plus")
14
+
15
+ if not os.path.exists(target_folder):
16
+ shutil.move(source_folder, target_folder)
17
+ print(f"{os.path.abspath(source_folder)} copy to {os.path.abspath(target_folder)} success!")
18
+ else:
19
+ print(f"{os.path.abspath(target_folder)} exist.")
20
+
21
+ try:
22
+ if os.path.exists(current_dir):
23
+ shutil.rmtree(current_dir)
24
+ else:
25
+ print(f"source_folder: '{current_dir}' not exist.")
26
+ except Exception as e:
27
+ print(f"delete source_folder error: {e}")
ACE_plus/model_convert.py ADDED
@@ -0,0 +1,194 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Copy from https://gist.github.com/Stella2211/10f5bd870387ec1ddb9932235321068e
2
+ # This is a great work.
3
+ import json
4
+ from pathlib import Path
5
+ import torch
6
+ from tqdm import tqdm
7
+ import struct
8
+ from typing import Dict, Any
9
+ import sys
10
+
11
+ # input file
12
+ if(len(sys.argv) < 3):
13
+ print("Usage: mem_eff_fp8_convert.py {fp16 model path} {output path}")
14
+ sys.exit(1)
15
+
16
+ path = sys.argv[1]
17
+ output =sys.argv[2]
18
+ model_file = Path(path)
19
+
20
+ class MemoryEfficientSafeOpen:
21
+ # does not support metadata loading
22
+ def __init__(self, filename):
23
+ self.filename = filename
24
+ self.header, self.header_size = self._read_header()
25
+ self.file = open(filename, "rb")
26
+
27
+ def __enter__(self):
28
+ return self
29
+
30
+ def __exit__(self, exc_type, exc_val, exc_tb):
31
+ self.file.close()
32
+
33
+ def keys(self):
34
+ return [k for k in self.header.keys() if k != "__metadata__"]
35
+
36
+ def get_tensor(self, key):
37
+ if key not in self.header:
38
+ raise KeyError(f"Tensor '{key}' not found in the file")
39
+
40
+ metadata = self.header[key]
41
+ offset_start, offset_end = metadata["data_offsets"]
42
+
43
+ if offset_start == offset_end:
44
+ tensor_bytes = None
45
+ else:
46
+ # adjust offset by header size
47
+ self.file.seek(self.header_size + 8 + offset_start)
48
+ tensor_bytes = self.file.read(offset_end - offset_start)
49
+
50
+ return self._deserialize_tensor(tensor_bytes, metadata)
51
+
52
+ def _read_header(self):
53
+ with open(self.filename, "rb") as f:
54
+ header_size = struct.unpack("<Q", f.read(8))[0]
55
+ header_json = f.read(header_size).decode("utf-8")
56
+ return json.loads(header_json), header_size
57
+
58
+ def _deserialize_tensor(self, tensor_bytes, metadata):
59
+ dtype = self._get_torch_dtype(metadata["dtype"])
60
+ shape = metadata["shape"]
61
+
62
+ if tensor_bytes is None:
63
+ byte_tensor = torch.empty(0, dtype=torch.uint8)
64
+ else:
65
+ tensor_bytes = bytearray(tensor_bytes) # make it writable
66
+ byte_tensor = torch.frombuffer(tensor_bytes, dtype=torch.uint8)
67
+
68
+ # process float8 types
69
+ if metadata["dtype"] in ["F8_E5M2", "F8_E4M3"]:
70
+ return self._convert_float8(byte_tensor, metadata["dtype"], shape)
71
+
72
+ # convert to the target dtype and reshape
73
+ return byte_tensor.view(dtype).reshape(shape)
74
+
75
+ @staticmethod
76
+ def _get_torch_dtype(dtype_str):
77
+ dtype_map = {
78
+ "F64": torch.float64,
79
+ "F32": torch.float32,
80
+ "F16": torch.float16,
81
+ "BF16": torch.bfloat16,
82
+ "I64": torch.int64,
83
+ "I32": torch.int32,
84
+ "I16": torch.int16,
85
+ "I8": torch.int8,
86
+ "U8": torch.uint8,
87
+ "BOOL": torch.bool,
88
+ }
89
+ # add float8 types if available
90
+ if hasattr(torch, "float8_e5m2"):
91
+ dtype_map["F8_E5M2"] = torch.float8_e5m2
92
+ if hasattr(torch, "float8_e4m3fn"):
93
+ dtype_map["F8_E4M3"] = torch.float8_e4m3fn
94
+ return dtype_map.get(dtype_str)
95
+
96
+ @staticmethod
97
+ def _convert_float8(byte_tensor, dtype_str, shape):
98
+ if dtype_str == "F8_E5M2" and hasattr(torch, "float8_e5m2"):
99
+ return byte_tensor.view(torch.float8_e5m2).reshape(shape)
100
+ elif dtype_str == "F8_E4M3" and hasattr(torch, "float8_e4m3fn"):
101
+ return byte_tensor.view(torch.float8_e4m3fn).reshape(shape)
102
+ else:
103
+ # # convert to float16 if float8 is not supported
104
+ # print(f"Warning: {dtype_str} is not supported in this PyTorch version. Converting to float16.")
105
+ # return byte_tensor.view(torch.uint8).to(torch.float16).reshape(shape)
106
+ raise ValueError(f"Unsupported float8 type: {dtype_str} (upgrade PyTorch to support float8 types)")
107
+
108
+
109
+ def mem_eff_save_file(tensors: Dict[str, torch.Tensor], filename: str, metadata: Dict[str, Any] = None):
110
+ _TYPES = {
111
+ torch.float64: "F64",
112
+ torch.float32: "F32",
113
+ torch.float16: "F16",
114
+ torch.bfloat16: "BF16",
115
+ torch.int64: "I64",
116
+ torch.int32: "I32",
117
+ torch.int16: "I16",
118
+ torch.int8: "I8",
119
+ torch.uint8: "U8",
120
+ torch.bool: "BOOL",
121
+ getattr(torch, "float8_e5m2", None): "F8_E5M2",
122
+ getattr(torch, "float8_e4m3fn", None): "F8_E4M3",
123
+ }
124
+ _ALIGN = 256
125
+
126
+ def validate_metadata(metadata: Dict[str, Any]) -> Dict[str, str]:
127
+ validated = {}
128
+ for key, value in metadata.items():
129
+ if not isinstance(key, str):
130
+ raise ValueError(f"Metadata key must be a string, got {type(key)}")
131
+ if not isinstance(value, str):
132
+ print(f"Warning: Metadata value for key '{key}' is not a string. Converting to string.")
133
+ validated[key] = str(value)
134
+ else:
135
+ validated[key] = value
136
+ return validated
137
+
138
+ header = {}
139
+ offset = 0
140
+ if metadata:
141
+ header["__metadata__"] = validate_metadata(metadata)
142
+ for k, v in tensors.items():
143
+ if v.numel() == 0: # empty tensor
144
+ header[k] = {"dtype": _TYPES[v.dtype], "shape": list(v.shape), "data_offsets": [offset, offset]}
145
+ else:
146
+ size = v.numel() * v.element_size()
147
+ header[k] = {"dtype": _TYPES[v.dtype], "shape": list(v.shape), "data_offsets": [offset, offset + size]}
148
+ offset += size
149
+
150
+ hjson = json.dumps(header).encode("utf-8")
151
+ hjson += b" " * (-(len(hjson) + 8) % _ALIGN)
152
+
153
+ with open(filename, "wb") as f:
154
+ f.write(struct.pack("<Q", len(hjson)))
155
+ f.write(hjson)
156
+
157
+ for k, v in tensors.items():
158
+ if v.numel() == 0:
159
+ continue
160
+ if v.is_cuda:
161
+ # Direct GPU to disk save
162
+ with torch.cuda.device(v.device):
163
+ if v.dim() == 0: # if scalar, need to add a dimension to work with view
164
+ v = v.unsqueeze(0)
165
+ tensor_bytes = v.contiguous().view(torch.uint8)
166
+ tensor_bytes.cpu().numpy().tofile(f)
167
+ else:
168
+ # CPU tensor save
169
+ if v.dim() == 0: # if scalar, need to add a dimension to work with view
170
+ v = v.unsqueeze(0)
171
+ v.contiguous().view(torch.uint8).numpy().tofile(f)
172
+
173
+
174
+ # read safetensors metadata
175
+ def read_safetensors_metadata(path: str):
176
+ with open(path, 'rb') as f:
177
+ header_size = int.from_bytes(f.read(8), 'little')
178
+ header_json = f.read(header_size).decode('utf-8')
179
+ header = json.loads(header_json)
180
+ metadata = header.get('__metadata__', {})
181
+ return metadata
182
+
183
+ metadata = read_safetensors_metadata(path)
184
+ print(json.dumps(metadata, indent=4)) #show metadata
185
+
186
+ sd_pruned = dict() #initialize empty dict
187
+
188
+ with MemoryEfficientSafeOpen(path) as reader:
189
+ keys = reader.keys()
190
+ for key in tqdm(keys): #for each key in the safetensors file
191
+ sd_pruned[key] = reader.get_tensor(key).to(torch.float8_e4m3fn) #convert to fp8
192
+
193
+ # save the pruned safetensors file
194
+ mem_eff_save_file(sd_pruned, output, metadata={"format": "pt", **metadata})
ACE_plus/pyproject.toml ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ [project]
2
+ name = "ace_plus"
3
+ description = "Custom nodes for various visual generation and editing tasks using ACE_Plus FFT Model."
4
+ version = "1.0.0"
5
+ license = {file = "LICENSE"}
6
+ dependencies = []
7
+
8
+ [project.urls]
9
+ Repository = "https://github.com/ali-vilab/ACE_plus"
10
+ # Used by Comfy Registry https://comfyregistry.org
11
+
12
+ [tool.comfy]
13
+ PublisherId = ""
14
+ DisplayName = "ACE_plus"
15
+ Icon = ""
ACE_plus/repo_requirements.txt ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
 
1
+ huggingface_hub
2
+ diffusers
3
+ transformers
4
+ torch>=2.4.1
5
+ xformers>=0.0.27.post2
6
+ gradio>=4.44.1
7
+ scepter
8
+ ms_swift
ACE_plus/requirements.txt ADDED
File without changes
ACE_plus/run_train.py ADDED
@@ -0,0 +1,70 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # -*- coding: utf-8 -*-
2
+ # Copyright (c) Alibaba, Inc. and its affiliates.
3
+ import argparse
4
+ import importlib
5
+ import os
6
+ import sys
7
+ from datetime import datetime
8
+ sys.dont_write_bytecode = True
9
+ from scepter.modules.solver.registry import SOLVERS
10
+ from scepter.modules.utils.config import Config
11
+ from scepter.modules.utils.distribute import we
12
+ from scepter.modules.utils.file_system import FS
13
+ from scepter.modules.utils.logger import get_logger
14
+
15
+ if os.path.exists('__init__.py'):
16
+ package_name = 'scepter_ext'
17
+ spec = importlib.util.spec_from_file_location(package_name, '__init__.py')
18
+ package = importlib.util.module_from_spec(spec)
19
+ sys.modules[package_name] = package
20
+ spec.loader.exec_module(package)
21
+
22
+ def run_task(cfg):
23
+ std_logger = get_logger(name='scepter')
24
+ solver = SOLVERS.build(cfg.SOLVER, logger=std_logger)
25
+ solver.set_up_pre()
26
+ solver.set_up()
27
+ if we.rank == 0:
28
+ FS.put_object_from_local_file(cfg.args.cfg_file, os.path.join(solver.work_dir, "train.yaml"))
29
+ if cfg.args.stage == "train":
30
+ solver.solve()
31
+ elif cfg.args.stage == "eval":
32
+ solver.run_eval()
33
+
34
+
35
+ def update_config(cfg):
36
+ if hasattr(cfg.args, 'learning_rate') and cfg.args.learning_rate:
37
+ print(
38
+ f'learning_rate change from {cfg.SOLVER.OPTIMIZER.LEARNING_RATE} to {cfg.args.learning_rate}'
39
+ )
40
+ cfg.SOLVER.OPTIMIZER.LEARNING_RATE = float(cfg.args.learning_rate)
41
+ if hasattr(cfg.args, 'max_steps') and cfg.args.max_steps:
42
+ print(
43
+ f'max_steps change from {cfg.SOLVER.MAX_STEPS} to {cfg.args.max_steps}'
44
+ )
45
+ cfg.SOLVER.MAX_STEPS = int(cfg.args.max_steps)
46
+ cfg.SOLVER.WORK_DIR = os.path.join(cfg.SOLVER.WORK_DIR, "{0:%Y%m%d%H%M%S}".format(datetime.now()))
47
+ return cfg
48
+
49
+
50
+ if __name__ == '__main__':
51
+ parser = argparse.ArgumentParser(description='Argparser for Scepter:\n')
52
+ parser.add_argument(
53
+ "--stage",
54
+ dest="stage",
55
+ help="Running stage!",
56
+ default="train",
57
+ choices=["train", "eval"]
58
+ )
59
+ parser.add_argument('--learning_rate',
60
+ dest='learning_rate',
61
+ help='The learning rate for our network!',
62
+ default=None)
63
+ parser.add_argument('--max_steps',
64
+ dest='max_steps',
65
+ help='The max steps for training!',
66
+ default=None)
67
+
68
+ cfg = Config(load=True, parser_ins=parser)
69
+ cfg = update_config(cfg)
70
+ we.init_env(cfg, logger=None, fn=run_task)
Reference_models/ae.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:afc8e28272cd15db3919bacdb6918ce9c1ed22e96cb12c4d5ed0fba823529e38
3
+ size 335304388
Reference_models/clip_l/pytorch_model.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:660c6f5b1abae9dc498ac2d21e1347d2abdb0cf6c0c0c8576cd796491d9a6cdd
3
+ size 246144152
Reference_models/comfyui_local_lora16.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:a935ef5dd61e54e014375cd6ac05e1433a22bcfa8e7a04bbcc1fff17cf4a4873
3
+ size 153268392
Reference_models/comfyui_subject_lora16.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:dbb24ec6fe7d84514e22ca19fd571a1168fd107d7160dc7728a94777bf1a8707
3
+ size 153268392
Reference_models/t5_xxl/config.json ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "_name_or_path": "./",
3
+ "architectures": [
4
+ "T5ForConditionalGeneration"
5
+ ],
6
+ "d_ff": 10240,
7
+ "d_kv": 64,
8
+ "d_model": 4096,
9
+ "decoder_start_token_id": 0,
10
+ "dropout_rate": 0.1,
11
+ "eos_token_id": 1,
12
+ "feed_forward_proj": "gated-gelu",
13
+ "initializer_factor": 1.0,
14
+ "is_encoder_decoder": true,
15
+ "layer_norm_epsilon": 1e-06,
16
+ "model_type": "t5",
17
+ "num_decoder_layers": 24,
18
+ "num_heads": 64,
19
+ "num_layers": 24,
20
+ "output_past": true,
21
+ "pad_token_id": 0,
22
+ "relative_attention_num_buckets": 32,
23
+ "tie_word_embeddings": false,
24
+ "torch_dtype": "float32",
25
+ "transformers_version": "4.13.0.dev0",
26
+ "use_cache": true,
27
+ "vocab_size": 32128
28
+ }
Reference_models/t5_xxl/generation_config.json ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
 
1
+ {
2
+ "_from_model_config": true,
3
+ "decoder_start_token_id": 0,
4
+ "eos_token_id": 1,
5
+ "pad_token_id": 0,
6
+ "transformers_version": "4.27.0.dev0"
7
+ }
Reference_models/t5_xxl/special_tokens_map.json ADDED
@@ -0,0 +1 @@
 
 
1
+ {"eos_token": "</s>", "unk_token": "<unk>", "pad_token": "<pad>", "additional_special_tokens": ["<extra_id_0>", "<extra_id_1>", "<extra_id_2>", "<extra_id_3>", "<extra_id_4>", "<extra_id_5>", "<extra_id_6>", "<extra_id_7>", "<extra_id_8>", "<extra_id_9>", "<extra_id_10>", "<extra_id_11>", "<extra_id_12>", "<extra_id_13>", "<extra_id_14>", "<extra_id_15>", "<extra_id_16>", "<extra_id_17>", "<extra_id_18>", "<extra_id_19>", "<extra_id_20>", "<extra_id_21>", "<extra_id_22>", "<extra_id_23>", "<extra_id_24>", "<extra_id_25>", "<extra_id_26>", "<extra_id_27>", "<extra_id_28>", "<extra_id_29>", "<extra_id_30>", "<extra_id_31>", "<extra_id_32>", "<extra_id_33>", "<extra_id_34>", "<extra_id_35>", "<extra_id_36>", "<extra_id_37>", "<extra_id_38>", "<extra_id_39>", "<extra_id_40>", "<extra_id_41>", "<extra_id_42>", "<extra_id_43>", "<extra_id_44>", "<extra_id_45>", "<extra_id_46>", "<extra_id_47>", "<extra_id_48>", "<extra_id_49>", "<extra_id_50>", "<extra_id_51>", "<extra_id_52>", "<extra_id_53>", "<extra_id_54>", "<extra_id_55>", "<extra_id_56>", "<extra_id_57>", "<extra_id_58>", "<extra_id_59>", "<extra_id_60>", "<extra_id_61>", "<extra_id_62>", "<extra_id_63>", "<extra_id_64>", "<extra_id_65>", "<extra_id_66>", "<extra_id_67>", "<extra_id_68>", "<extra_id_69>", "<extra_id_70>", "<extra_id_71>", "<extra_id_72>", "<extra_id_73>", "<extra_id_74>", "<extra_id_75>", "<extra_id_76>", "<extra_id_77>", "<extra_id_78>", "<extra_id_79>", "<extra_id_80>", "<extra_id_81>", "<extra_id_82>", "<extra_id_83>", "<extra_id_84>", "<extra_id_85>", "<extra_id_86>", "<extra_id_87>", "<extra_id_88>", "<extra_id_89>", "<extra_id_90>", "<extra_id_91>", "<extra_id_92>", "<extra_id_93>", "<extra_id_94>", "<extra_id_95>", "<extra_id_96>", "<extra_id_97>", "<extra_id_98>", "<extra_id_99>"]}
Reference_models/t5_xxl/spiece.model ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:d60acb128cf7b7f2536e8f38a5b18a05535c9e14c7a355904270e15b0945ea86
3
+ size 791656
Reference_models/t5_xxl/tokenizer.json ADDED
The diff for this file is too large to render. See raw diff
 
Reference_models/t5_xxl/tokenizer_config.json ADDED
@@ -0,0 +1 @@
 
 
1
+ {"eos_token": "</s>", "unk_token": "<unk>", "pad_token": "<pad>", "extra_ids": 100, "additional_special_tokens": ["<extra_id_0>", "<extra_id_1>", "<extra_id_2>", "<extra_id_3>", "<extra_id_4>", "<extra_id_5>", "<extra_id_6>", "<extra_id_7>", "<extra_id_8>", "<extra_id_9>", "<extra_id_10>", "<extra_id_11>", "<extra_id_12>", "<extra_id_13>", "<extra_id_14>", "<extra_id_15>", "<extra_id_16>", "<extra_id_17>", "<extra_id_18>", "<extra_id_19>", "<extra_id_20>", "<extra_id_21>", "<extra_id_22>", "<extra_id_23>", "<extra_id_24>", "<extra_id_25>", "<extra_id_26>", "<extra_id_27>", "<extra_id_28>", "<extra_id_29>", "<extra_id_30>", "<extra_id_31>", "<extra_id_32>", "<extra_id_33>", "<extra_id_34>", "<extra_id_35>", "<extra_id_36>", "<extra_id_37>", "<extra_id_38>", "<extra_id_39>", "<extra_id_40>", "<extra_id_41>", "<extra_id_42>", "<extra_id_43>", "<extra_id_44>", "<extra_id_45>", "<extra_id_46>", "<extra_id_47>", "<extra_id_48>", "<extra_id_49>", "<extra_id_50>", "<extra_id_51>", "<extra_id_52>", "<extra_id_53>", "<extra_id_54>", "<extra_id_55>", "<extra_id_56>", "<extra_id_57>", "<extra_id_58>", "<extra_id_59>", "<extra_id_60>", "<extra_id_61>", "<extra_id_62>", "<extra_id_63>", "<extra_id_64>", "<extra_id_65>", "<extra_id_66>", "<extra_id_67>", "<extra_id_68>", "<extra_id_69>", "<extra_id_70>", "<extra_id_71>", "<extra_id_72>", "<extra_id_73>", "<extra_id_74>", "<extra_id_75>", "<extra_id_76>", "<extra_id_77>", "<extra_id_78>", "<extra_id_79>", "<extra_id_80>", "<extra_id_81>", "<extra_id_82>", "<extra_id_83>", "<extra_id_84>", "<extra_id_85>", "<extra_id_86>", "<extra_id_87>", "<extra_id_88>", "<extra_id_89>", "<extra_id_90>", "<extra_id_91>", "<extra_id_92>", "<extra_id_93>", "<extra_id_94>", "<extra_id_95>", "<extra_id_96>", "<extra_id_97>", "<extra_id_98>", "<extra_id_99>"], "sp_model_kwargs": {}, "model_max_length": 512, "name_or_path": "./", "special_tokens_map_file": "/home/patrick/.cache/huggingface/transformers/5995b096c7f019eb696851d1af1c82271c3083fac6538e159d9b07ed718214d0.c94798918c92ded6aeef2d2f0e666d2cc4145eca1aa6e1336fde07f2e13e2f46", "tokenizer_class": "T5Tokenizer"}
Training_Data/Inperson_3-Garment-V2.jpg ADDED

Git LFS Details

  • SHA256: 159757eae47948bdbbb5c862a1885468d5214175710d48f1ead95ac99191aa91
  • Pointer size: 131 Bytes
  • Size of remote file: 178 kB
Training_Data/Inperson_3-Garment-V2.png ADDED

Git LFS Details

  • SHA256: 4ba52216c028fe63eec7dcd2802d7cb7780f6119c58a623d1336c7729e9d7f56
  • Pointer size: 132 Bytes
  • Size of remote file: 2.89 MB
Training_Data/Inperson_3-Mask-V1.png ADDED

Git LFS Details

  • SHA256: 43478194cce012f198494be9396d5b2ce220f32023b3c17a68ba1e0084c76427
  • Pointer size: 131 Bytes
  • Size of remote file: 202 kB
Training_Data/Inperson_3-V1.png ADDED

Git LFS Details

  • SHA256: 9a63f7c06f94349c4f1475592001b46bb832ecca1a99ce40e6f8146db7fbed28
  • Pointer size: 132 Bytes
  • Size of remote file: 3.74 MB
Training_Data/Inperson_4-Garment-V2.png ADDED

Git LFS Details

  • SHA256: 85de34cb34392c36aa32ebdf6af90cbf332b8ea8a62d9126b4defe0246a20be4
  • Pointer size: 132 Bytes
  • Size of remote file: 3.01 MB
Training_Data/Inperson_4-Mask-V2.png ADDED

Git LFS Details

  • SHA256: 48c2945bd809b6fe9565686cbbe11f14ed8e7cd04382f43c6f68230ab5ac27a4
  • Pointer size: 131 Bytes
  • Size of remote file: 264 kB
Training_Data/Inperson_4-V2.png ADDED

Git LFS Details

  • SHA256: 9c071323bb27a403d7b9330e00db6e86739531fb8cfefb5042f19b1ea5c8e2cc
  • Pointer size: 132 Bytes
  • Size of remote file: 5.83 MB
Training_Data/Inperson_5-Garment-V2.jpg ADDED

Git LFS Details

  • SHA256: ad318654bd2ae9c9d0e97ac6adedc4803f11977f4712523f9c86c73acc910b81
  • Pointer size: 131 Bytes
  • Size of remote file: 134 kB
Training_Data/Inperson_5-Garment-V2.png ADDED

Git LFS Details

  • SHA256: cf4e9510ac031ca2789f54796106e04594db4cb6d928418b167293da5becdb51
  • Pointer size: 132 Bytes
  • Size of remote file: 2.25 MB
Training_Data/Inperson_5-V2.jpg ADDED

Git LFS Details

  • SHA256: b7adc60b6a6a5fe902e638fff3984c7347c69e4bb15e51835761711c54db472a
  • Pointer size: 131 Bytes
  • Size of remote file: 692 kB
Training_Data/Inperson_5-V2.png ADDED

Git LFS Details

  • SHA256: 9330eff749773df1b686d2662513a6cb3aa764d6beb3ce65064966f5d308ff6e
  • Pointer size: 132 Bytes
  • Size of remote file: 6.68 MB
Training_Data/Inperson_7-Garment-V2.png ADDED

Git LFS Details

  • SHA256: 57f0c53ea664aebe75ce8bf113b2c77245a03c51a12ca640dd4abe23cc67e432
  • Pointer size: 132 Bytes
  • Size of remote file: 3.04 MB
Training_Data/Inperson_7-V2.jpg ADDED

Git LFS Details

  • SHA256: f3f1eb7fa898ee19cf92274aa3cf7448242d63267096ecc2e91b5374df574bf5
  • Pointer size: 131 Bytes
  • Size of remote file: 290 kB
Training_Data/Inperson_7-V2.png ADDED

Git LFS Details

  • SHA256: 8858917c60c21abb7caa12a4a4a20c521fc1a21e090c8f039807108f341bd0dd
  • Pointer size: 132 Bytes
  • Size of remote file: 4.15 MB
Training_Data/Pinaperson_1-Garment-V1.jpg ADDED

Git LFS Details

  • SHA256: b84fbaff58ea8f101d0a5bdcbdb4d5113a31315a3fe8a3cf7b9f7e88a697581c
  • Pointer size: 131 Bytes
  • Size of remote file: 879 kB
Training_Data/Pinaperson_1-V1.jpg ADDED

Git LFS Details

  • SHA256: 452a24268c6389c7b0d93cede51f02e01937d1304f32f757b5eaed0b5a3d5644
  • Pointer size: 131 Bytes
  • Size of remote file: 684 kB
Training_Data/Pinaperson_2-Garment-V1.jpg ADDED

Git LFS Details

  • SHA256: b84fbaff58ea8f101d0a5bdcbdb4d5113a31315a3fe8a3cf7b9f7e88a697581c
  • Pointer size: 131 Bytes
  • Size of remote file: 879 kB
Training_Data/Pinaperson_2-V1.jpg ADDED

Git LFS Details

  • SHA256: 48c5a724c156e80905fb6de11fcf533219decc45da89cd1bfcc96b3f83db2543
  • Pointer size: 131 Bytes
  • Size of remote file: 571 kB
Training_Data/Pinaperson_3-Garment-V1.jpg ADDED

Git LFS Details

  • SHA256: d5a46fa3a70dd719dc809f1dee2ec1bc3ba1c728f22b7d83482590bb6acc5b84
  • Pointer size: 131 Bytes
  • Size of remote file: 564 kB
Training_Data/Pinaperson_3-V1.jpg ADDED

Git LFS Details

  • SHA256: 827e9e8919ceb8bdd41b6d9166a50537a459322efbd806758ec7e0debd9ad995
  • Pointer size: 131 Bytes
  • Size of remote file: 698 kB
Training_Data/Pinaperson_4-Garment-V1.jpg ADDED

Git LFS Details

  • SHA256: d5a46fa3a70dd719dc809f1dee2ec1bc3ba1c728f22b7d83482590bb6acc5b84
  • Pointer size: 131 Bytes
  • Size of remote file: 564 kB
Training_Data/Pinaperson_4-V1.jpg ADDED

Git LFS Details

  • SHA256: 43b6d480fc6f8cfdbd25ceb0c8075c214eecee08ce04bc843b557719b3e30256
  • Pointer size: 131 Bytes
  • Size of remote file: 634 kB
Training_Data/TigcPerson_1-Garment.jpg ADDED

Git LFS Details

  • SHA256: bdea3158c0e0fa4212077c37bb744ef8851e417ba06b966445a6634be416bc26
  • Pointer size: 131 Bytes
  • Size of remote file: 284 kB
Training_Data/TigcPerson_1-Mask.jpg ADDED

Git LFS Details

  • SHA256: b1296c817b4a585581be2131d547d7578c5b799b176615030f4c15ce7dc20c62
  • Pointer size: 131 Bytes
  • Size of remote file: 291 kB
Training_Data/TigcPerson_1.jpg ADDED

Git LFS Details

  • SHA256: eccbf397a75d6f2535ac53e7c654551aa7388d8babf63467f882036d7a43964e
  • Pointer size: 132 Bytes
  • Size of remote file: 5.89 MB
Training_Data/TigcPerson_2-Mask.jpg ADDED

Git LFS Details

  • SHA256: 53c44a8b8e8d1825b79e5d6e7532a7024e355ee166a8e88a7c4d25125fb7a01d
  • Pointer size: 131 Bytes
  • Size of remote file: 274 kB