Upload folder using huggingface_hub
Browse files- LICENSE +74 -0
- README.md +576 -3
- t2i/model/pytorch_model_ema.pt +3 -0
- t2i/model/pytorch_model_module.pt +3 -0
LICENSE
CHANGED
@@ -0,0 +1,74 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
TENCENT HUNYUAN COMMUNITY LICENSE AGREEMENT
|
2 |
+
Tencent Hunyuan Release Date: 2024/5/14
|
3 |
+
By clicking to agree or by using, reproducing, modifying, distributing, performing or displaying any portion or element of the Tencent Hunyuan Works, including via any Hosted Service, You will be deemed to have recognized and accepted the content of this Agreement, which is effective immediately.
|
4 |
+
1. DEFINITIONS.
|
5 |
+
a. “Acceptable Use Policy” shall mean the policy made available by Tencent as set forth in the Exhibit A.
|
6 |
+
b. “Agreement” shall mean the terms and conditions for use, reproduction, distribution, modification, performance and displaying of the Hunyuan Works or any portion or element thereof set forth herein.
|
7 |
+
c. “Documentation” shall mean the specifications, manuals and documentation for Tencent Hunyuan made publicly available by Tencent.
|
8 |
+
d. “Hosted Service” shall mean a hosted service offered via an application programming interface (API), web access, or any other electronic or remote means.
|
9 |
+
e. “Licensee,” “You” or “Your” shall mean a natural person or legal entity exercising the rights granted by this Agreement and/or using the Tencent Hunyuan Works for any purpose and in any field of use.
|
10 |
+
f. “Materials” shall mean, collectively, Tencent’s proprietary Tencent Hunyuan and Documentation (and any portion thereof) as made available by Tencent under this Agreement.
|
11 |
+
g. “Model Derivatives” shall mean all: (i) modifications to Tencent Hunyuan or any Model Derivative of Tencent Hunyuan; (ii) works based on Tencent Hunyuan or any Model Derivative of Tencent Hunyuan; or (iii) any other machine learning model which is created by transfer of patterns of the weights, parameters, operations, or Output of Tencent Hunyuan or any Model Derivative of Tencent Hunyuan, to that model in order to cause that model to perform similarly to Tencent Hunyuan or a Model Derivative of Tencent Hunyuan, including distillation methods, methods that use intermediate data representations, or methods based on the generation of synthetic data Outputs by Tencent Hunyuan or a Model Derivative of Tencent Hunyuan for training that model. For clarity, Outputs by themselves are not deemed Model Derivatives.
|
12 |
+
h. “Output” shall mean the information and/or content output of Tencent Hunyuan or a Model Derivative that results from operating or otherwise using Tencent Hunyuan or a Model Derivative, including via a Hosted Service.
|
13 |
+
i. “Tencent,” “We” or “Us” shall mean THL A29 Limited.
|
14 |
+
j. “Tencent Hunyuan” shall mean the large language models, image/video/audio/3D generation models, and multimodal large language models and their software and algorithms, including trained model weights, parameters (including optimizer states), machine-learning model code, inference-enabling code, training-enabling code, fine-tuning enabling code and other elements of the foregoing made publicly available by Us at https://huggingface.co/Tencent-Hunyuan/HunyuanDiT and https://github.com/Tencent/HunyuanDiT .
|
15 |
+
k. “Tencent Hunyuan Works” shall mean: (i) the Materials; (ii) Model Derivatives; and (iii) all derivative works thereof.
|
16 |
+
l. “Third Party” or “Third Parties” shall mean individuals or legal entities that are not under common control with Us or You.
|
17 |
+
m. “including” shall mean including but not limited to.
|
18 |
+
2. GRANT OF RIGHTS.
|
19 |
+
We grant You a non-exclusive, worldwide, non-transferable and royalty-free limited license under Tencent’s intellectual property or other rights owned by Us embodied in or utilized by the Materials to use, reproduce, distribute, create derivative works of (including Model Derivatives), and make modifications to the Materials, only in accordance with the terms of this Agreement and the Acceptable Use Policy, and You must not violate (or encourage or permit anyone else to violate) any term of this Agreement or the Acceptable Use Policy.
|
20 |
+
3. DISTRIBUTION.
|
21 |
+
You may, subject to Your compliance with this Agreement, distribute or make available to Third Parties the Tencent Hunyuan Works, provided that You meet all of the following conditions:
|
22 |
+
a. You must provide all such Third Party recipients of the Tencent Hunyuan Works or products or services using them a copy of this Agreement;
|
23 |
+
b. You must cause any modified files to carry prominent notices stating that You changed the files;
|
24 |
+
c. You are encouraged to: (i) publish at least one technology introduction blogpost or one public statement expressing Your experience of using the Tencent Hunyuan Works; and (ii) mark the products or services developed by using the Tencent Hunyuan Works to indicate that the product/service is “Powered by Tencent Hunyuan”; and
|
25 |
+
d. All distributions to Third Parties (other than through a Hosted Service) must be accompanied by a “Notice” text file that contains the following notice: “Tencent Hunyuan is licensed under the Tencent Hunyuan Community License Agreement, Copyright © 2024 Tencent. All Rights Reserved. The trademark rights of “Tencent Hunyuan” are owned by Tencent or its affiliate.”
|
26 |
+
You may add Your own copyright statement to Your modifications and, except as set forth in this Section and in Section 5, may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Model Derivatives as a whole, provided Your use, reproduction, modification, distribution, performance and display of the work otherwise complies with the terms and conditions of this Agreement. If You receive Tencent Hunyuan Works from a Licensee as part of an integrated end user product, then this Section 3 of this Agreement will not apply to You.
|
27 |
+
4. ADDITIONAL COMMERCIAL TERMS.
|
28 |
+
If, on the Tencent Hunyuan version release date, the monthly active users of all products or services made available by or for Licensee is greater than 100 million monthly active users in the preceding calendar month, You must request a license from Tencent, which Tencent may grant to You in its sole discretion, and You are not authorized to exercise any of the rights under this Agreement unless or until Tencent otherwise expressly grants You such rights.
|
29 |
+
5. RULES OF USE.
|
30 |
+
a. Your use of the Tencent Hunyuan Works must comply with applicable laws and regulations (including trade compliance laws and regulations) and adhere to the Acceptable Use Policy for the Tencent Hunyuan Works, which is hereby incorporated by reference into this Agreement. You must include the use restrictions referenced in these Sections 5(a) and 5(b) as an enforceable provision in any agreement (e.g., license agreement, terms of use, etc.) governing the use and/or distribution of Tencent Hunyuan Works and You must provide notice to subsequent users to whom You distribute that Tencent Hunyuan Works are subject to the use restrictions in these Sections 5(a) and 5(b).
|
31 |
+
b. You must not use the Tencent Hunyuan Works or any Output or results of the Tencent Hunyuan Works to improve any other large language model (other than Tencent Hunyuan or Model Derivatives thereof).
|
32 |
+
6. INTELLECTUAL PROPERTY.
|
33 |
+
a. Subject to Tencent’s ownership of Tencent Hunyuan Works made by or for Tencent and intellectual property rights therein, conditioned upon Your compliance with the terms and conditions of this Agreement, as between You and Tencent, You will be the owner of any derivative works and modifications of the Materials and any Model Derivatives that are made by or for You.
|
34 |
+
b. No trademark licenses are granted under this Agreement, and in connection with the Tencent Hunyuan Works, Licensee may not use any name or mark owned by or associated with Tencent or any of its affiliates, except as required for reasonable and customary use in describing and distributing the Tencent Hunyuan Works. Tencent hereby grants You a license to use “Tencent Hunyuan” (the “Mark”) solely as required to comply with the provisions of Section 3(c), provided that You comply with any applicable laws related to trademark protection. All goodwill arising out of Your use of the Mark will inure to the benefit of Tencent.
|
35 |
+
c. If You commence a lawsuit or other proceedings (including a cross-claim or counterclaim in a lawsuit) against Us or any person or entity alleging that the Materials or any Output, or any portion of any of the foregoing, infringe any intellectual property or other right owned or licensable by You, then all licenses granted to You under this Agreement shall terminate as of the date such lawsuit or other proceeding is filed. You will defend, indemnify and hold harmless Us from and against any claim by any Third Party arising out of or related to Your or the Third Party’s use or distribution of the Tencent Hunyuan Works.
|
36 |
+
d. Tencent claims no rights in Outputs You generate. You and Your users are solely responsible for Outputs and their subsequent uses.
|
37 |
+
7. DISCLAIMERS OF WARRANTY AND LIMITATIONS OF LIABILITY.
|
38 |
+
a. We are not obligated to support, update, provide training for, or develop any further version of the Tencent Hunyuan Works or to grant any license thereto.
|
39 |
+
b. UNLESS AND ONLY TO THE EXTENT REQUIRED BY APPLICABLE LAW, THE TENCENT HUNYUAN WORKS AND ANY OUTPUT AND RESULTS THEREFROM ARE PROVIDED “AS IS” WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES OF ANY KIND INCLUDING ANY WARRANTIES OF TITLE, MERCHANTABILITY, NONINFRINGEMENT, COURSE OF DEALING, USAGE OF TRADE, OR FITNESS FOR A PARTICULAR PURPOSE. YOU ARE SOLELY RESPONSIBLE FOR DETERMINING THE APPROPRIATENESS OF USING, REPRODUCING, MODIFYING, PERFORMING, DISPLAYING OR DISTRIBUTING ANY OF THE TENCENT HUNYUAN WORKS OR OUTPUTS AND ASSUME ANY AND ALL RISKS ASSOCIATED WITH YOUR OR A THIRD PARTY’S USE OR DISTRIBUTION OF ANY OF THE TENCENT HUNYUAN WORKS OR OUTPUTS AND YOUR EXERCISE OF RIGHTS AND PERMISSIONS UNDER THIS AGREEMENT.
|
40 |
+
c. TO THE FULLEST EXTENT PERMITTED BY APPLICABLE LAW, IN NO EVENT SHALL TENCENT OR ITS AFFILIATES BE LIABLE UNDER ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, TORT, NEGLIGENCE, PRODUCTS LIABILITY, OR OTHERWISE, FOR ANY DAMAGES, INCLUDING ANY DIRECT, INDIRECT, SPECIAL, INCIDENTAL, EXEMPLARY, CONSEQUENTIAL OR PUNITIVE DAMAGES, OR LOST PROFITS OF ANY KIND ARISING FROM THIS AGREEMENT OR RELATED TO ANY OF THE TENCENT HUNYUAN WORKS OR OUTPUTS, EVEN IF TENCENT OR ITS AFFILIATES HAVE BEEN ADVISED OF THE POSSIBILITY OF ANY OF THE FOREGOING.
|
41 |
+
8. SURVIVAL AND TERMINATION.
|
42 |
+
a. The term of this Agreement shall commence upon Your acceptance of this Agreement or access to the Materials and will continue in full force and effect until terminated in accordance with the terms and conditions herein.
|
43 |
+
b. We may terminate this Agreement if You breach any of the terms or conditions of this Agreement. Upon termination of this Agreement, You must promptly delete and cease use of the Tencent Hunyuan Works. Sections 6(a), 6(c), 7 and 9 shall survive the termination of this Agreement.
|
44 |
+
9. GOVERNING LAW AND JURISDICTION.
|
45 |
+
a. This Agreement and any dispute arising out of or relating to it will be governed by the laws of the Hong Kong Special Administrative Region of the People’s Republic of China, without regard to conflict of law principles, and the UN Convention on Contracts for the International Sale of Goods does not apply to this Agreement.
|
46 |
+
b. Exclusive jurisdiction and venue for any dispute arising out of or relating to this Agreement will be a court of competent jurisdiction in the Hong Kong Special Administrative Region of the People’s Republic of China, and Tencent and Licensee consent to the exclusive jurisdiction of such court with respect to any such dispute.
|
47 |
+
|
48 |
+
|
49 |
+
EXHIBIT A
|
50 |
+
ACCEPTABLE USE POLICY
|
51 |
+
|
52 |
+
Tencent reserves the right to update this Acceptable Use Policy from time to time.
|
53 |
+
Last modified: 2024/5/14
|
54 |
+
|
55 |
+
Tencent endeavors to promote safe and fair use of its tools and features, including Tencent Hunyuan. You agree not to use Tencent Hunyuan or Model Derivatives:
|
56 |
+
1. In any way that violates any applicable national, federal, state, local, international or any other law or regulation;
|
57 |
+
2. To harm Yourself or others;
|
58 |
+
3. To repurpose or distribute output from Tencent Hunyuan or any Model Derivatives to harm Yourself or others;
|
59 |
+
4. To override or circumvent the safety guardrails and safeguards We have put in place;
|
60 |
+
5. For the purpose of exploiting, harming or attempting to exploit or harm minors in any way;
|
61 |
+
6. To generate or disseminate verifiably false information and/or content with the purpose of harming others or influencing elections;
|
62 |
+
7. To generate or facilitate false online engagement, including fake reviews and other means of fake online engagement;
|
63 |
+
8. To intentionally defame, disparage or otherwise harass others;
|
64 |
+
9. To generate and/or disseminate malware (including ransomware) or any other content to be used for the purpose of harming electronic systems;
|
65 |
+
10. To generate or disseminate personal identifiable information with the purpose of harming others;
|
66 |
+
11. To generate or disseminate information (including images, code, posts, articles), and place the information in any public context (including –through the use of bot generated tweets), without expressly and conspicuously identifying that the information and/or content is machine generated;
|
67 |
+
12. To impersonate another individual without consent, authorization, or legal right;
|
68 |
+
13. To make high-stakes automated decisions in domains that affect an individual’s safety, rights or wellbeing (e.g., law enforcement, migration, medicine/health, management of critical infrastructure, safety components of products, essential services, credit, employment, housing, education, social scoring, or insurance);
|
69 |
+
14. In a manner that violates or disrespects the social ethics and moral standards of other countries or regions;
|
70 |
+
15. To perform, facilitate, threaten, incite, plan, promote or encourage violent extremism or terrorism;
|
71 |
+
16. For any use intended to discriminate against or harm individuals or groups based on protected characteristics or categories, online or offline social behavior or known or predicted personal or personality characteristics;
|
72 |
+
17. To intentionally exploit any of the vulnerabilities of a specific group of persons based on their age, social, physical or mental characteristics, in order to materially distort the behavior of a person pertaining to that group in a manner that causes or is likely to cause that person or another person physical or psychological harm;
|
73 |
+
18. For military purposes;
|
74 |
+
19. To engage in the unauthorized or unlicensed practice of any profession including, but not limited to, financial, legal, medical/health, or other professional practices.
|
README.md
CHANGED
@@ -1,5 +1,578 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
---
|
2 |
-
|
3 |
-
|
4 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
5 |
---
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<!-- ## **HunyuanDiT** -->
|
2 |
+
|
3 |
+
<p align="center">
|
4 |
+
<img src="https://raw.githubusercontent.com/Tencent/HunyuanDiT/main/asset/logo.png" height=100>
|
5 |
+
</p>
|
6 |
+
|
7 |
+
# Hunyuan-DiT : A Powerful Multi-Resolution Diffusion Transformer with Fine-Grained Chinese Understanding
|
8 |
+
|
9 |
+
<div align="center">
|
10 |
+
<a href="https://github.com/Tencent/HunyuanDiT"><img src="https://img.shields.io/static/v1?label=Hunyuan-DiT Code&message=Github&color=blue&logo=github-pages"></a>  
|
11 |
+
<a href="https://dit.hunyuan.tencent.com"><img src="https://img.shields.io/static/v1?label=Project%20Page&message=Github&color=blue&logo=github-pages"></a>  
|
12 |
+
<a href="https://arxiv.org/abs/2405.08748"><img src="https://img.shields.io/static/v1?label=Tech Report&message=Arxiv:HunYuan-DiT&color=red&logo=arxiv"></a>  
|
13 |
+
<a href="https://arxiv.org/abs/2403.08857"><img src="https://img.shields.io/static/v1?label=Paper&message=Arxiv:DialogGen&color=red&logo=arxiv"></a>  
|
14 |
+
<a href="https://huggingface.co/Tencent-Hunyuan/HunyuanDiT"><img src="https://img.shields.io/static/v1?label=Hunyuan-DiT&message=HuggingFace&color=yellow"></a>  
|
15 |
+
<a href="https://hunyuan.tencent.com/bot/chat"><img src="https://img.shields.io/static/v1?label=Hunyuan Bot&message=Web&color=green"></a>  
|
16 |
+
<a href="https://huggingface.co/spaces/Tencent-Hunyuan/HunyuanDiT"><img src="https://img.shields.io/static/v1?label=Hunyuan-DiT Demo&message=HuggingFace&color=yellow"></a>  
|
17 |
+
</div>
|
18 |
+
|
19 |
+
-----
|
20 |
+
|
21 |
+
This repo contains PyTorch model definitions, pre-trained weights and inference/sampling code for our paper exploring Hunyuan-DiT. You can find more visualizations on our [project page](https://dit.hunyuan.tencent.com/).
|
22 |
+
|
23 |
+
> [**Hunyuan-DiT: A Powerful Multi-Resolution Diffusion Transformer with Fine-Grained Chinese Understanding**](https://arxiv.org/abs/2405.08748) <br>
|
24 |
+
|
25 |
+
> [**DialogGen: Multi-modal Interactive Dialogue System for Multi-turn Text-to-Image Generation**](https://arxiv.org/abs/2403.08857) <br>
|
26 |
+
|
27 |
+
## 🔥🔥🔥 News!!
|
28 |
+
* Jun 13, 2024: :zap: HYDiT-v1.1 version is released, which mitigates the issue of image oversaturation and alleviates the watermark issue. Please check [HunyuanDiT-v1.1 ](https://huggingface.co/Tencent-Hunyuan/HunyuanDiT-v1.1) and
|
29 |
+
[Distillation-v1.1](https://huggingface.co/Tencent-Hunyuan/Distillation-v1.1) for more details.
|
30 |
+
* Jun 13, 2024: :truck: The training code is released, offering [full-parameter training](#full-parameter-training) and [LoRA training](#lora).
|
31 |
+
* Jun 06, 2024: :tada: Hunyuan-DiT is now available in ComfyUI. Please check [ComfyUI](#using-comfyui) for more details.
|
32 |
+
* Jun 06, 2024: 🚀 We introduce Distillation version for Hunyuan-DiT acceleration, which achieves **50%** acceleration on NVIDIA GPUs. Please check [Distillation](https://huggingface.co/Tencent-Hunyuan/Distillation) for more details.
|
33 |
+
* Jun 05, 2024: 🤗 Hunyuan-DiT is now available in 🤗 Diffusers! Please check the [example](#using--diffusers) below.
|
34 |
+
* Jun 04, 2024: :globe_with_meridians: Support Tencent Cloud links to download the pretrained models! Please check the [links](#-download-pretrained-models) below.
|
35 |
+
* May 22, 2024: 🚀 We introduce TensorRT version for Hunyuan-DiT acceleration, which achieves **47%** acceleration on NVIDIA GPUs. Please check [TensorRT-libs](https://huggingface.co/Tencent-Hunyuan/TensorRT-libs) for instructions.
|
36 |
+
* May 22, 2024: 💬 We support demo running multi-turn text2image generation now. Please check the [script](#using-gradio) below.
|
37 |
+
|
38 |
+
## 🤖 Try it on the web
|
39 |
+
|
40 |
+
Welcome to our web-based [**Tencent Hunyuan Bot**](https://hunyuan.tencent.com/bot/chat), where you can explore our innovative products! Just input the suggested prompts below or any other **imaginative prompts containing drawing-related keywords** to activate the Hunyuan text-to-image generation feature. Unleash your creativity and create any picture you desire, **all for free!**
|
41 |
+
|
42 |
+
You can use simple prompts similar to natural language text
|
43 |
+
|
44 |
+
> 画一只穿着西装的猪
|
45 |
+
>
|
46 |
+
> draw a pig in a suit
|
47 |
+
>
|
48 |
+
> 生成一幅画,赛博朋克风,跑车
|
49 |
+
>
|
50 |
+
> generate a painting, cyberpunk style, sports car
|
51 |
+
|
52 |
+
or multi-turn language interactions to create the picture.
|
53 |
+
|
54 |
+
> 画一个木制的鸟
|
55 |
+
>
|
56 |
+
> draw a wooden bird
|
57 |
+
>
|
58 |
+
> 变成玻璃的
|
59 |
+
>
|
60 |
+
> turn into glass
|
61 |
+
|
62 |
+
## 📑 Open-source Plan
|
63 |
+
|
64 |
+
- Hunyuan-DiT (Text-to-Image Model)
|
65 |
+
- [x] Inference
|
66 |
+
- [x] Checkpoints
|
67 |
+
- [x] Distillation Version
|
68 |
+
- [x] TensorRT Version
|
69 |
+
- [x] Training
|
70 |
+
- [x] Lora
|
71 |
+
- [ ] Controlnet (Pose, Canny, Depth, Tile)
|
72 |
+
- [ ] IP-adapter
|
73 |
+
- [ ] Hunyuan-DiT-XL checkpoints (0.7B model)
|
74 |
+
- [ ] Caption model (Re-caption the raw image-text pairs)
|
75 |
+
- [DialogGen](https://github.com/Centaurusalpha/DialogGen) (Prompt Enhancement Model)
|
76 |
+
- [x] Inference
|
77 |
+
- [X] Web Demo (Gradio)
|
78 |
+
- [x] Multi-turn T2I Demo (Gradio)
|
79 |
+
- [X] Cli Demo
|
80 |
+
- [X] ComfyUI
|
81 |
+
- [X] Diffusers
|
82 |
+
- [ ] WebUI
|
83 |
+
|
84 |
+
|
85 |
+
## Contents
|
86 |
+
- [Hunyuan-DiT](#hunyuan-dit--a-powerful-multi-resolution-diffusion-transformer-with-fine-grained-chinese-understanding)
|
87 |
+
- [Abstract](#abstract)
|
88 |
+
- [🎉 Hunyuan-DiT Key Features](#-hunyuan-dit-key-features)
|
89 |
+
- [Chinese-English Bilingual DiT Architecture](#chinese-english-bilingual-dit-architecture)
|
90 |
+
- [Multi-turn Text2Image Generation](#multi-turn-text2image-generation)
|
91 |
+
- [📈 Comparisons](#-comparisons)
|
92 |
+
- [🎥 Visualization](#-visualization)
|
93 |
+
- [📜 Requirements](#-requirements)
|
94 |
+
- [🛠 Dependencies and Installation](#%EF%B8%8F-dependencies-and-installation)
|
95 |
+
- [🧱 Download Pretrained Models](#-download-pretrained-models)
|
96 |
+
- [:truck: Training](#truck-training)
|
97 |
+
- [Data Preparation](#data-preparation)
|
98 |
+
- [Full Parameter Training](#full-parameter-training)
|
99 |
+
- [LoRA](#lora)
|
100 |
+
- [🔑 Inference](#-inference)
|
101 |
+
- [Using Gradio](#using-gradio)
|
102 |
+
- [Using Diffusers](#using--diffusers)
|
103 |
+
- [Using Command Line](#using-command-line)
|
104 |
+
- [More Configurations](#more-configurations)
|
105 |
+
- [Using ComfyUI](#using-comfyui)
|
106 |
+
- [🚀 Acceleration (for Linux)](#-acceleration-for-linux)
|
107 |
+
- [🔗 BibTeX](#-bibtex)
|
108 |
+
|
109 |
+
## **Abstract**
|
110 |
+
|
111 |
+
We present Hunyuan-DiT, a text-to-image diffusion transformer with fine-grained understanding of both English and Chinese. To construct Hunyuan-DiT, we carefully designed the transformer structure, text encoder, and positional encoding. We also build from scratch a whole data pipeline to update and evaluate data for iterative model optimization. For fine-grained language understanding, we train a Multimodal Large Language Model to refine the captions of the images. Finally, Hunyuan-DiT can perform multi-round multi-modal dialogue with users, generating and refining images according to the context.
|
112 |
+
Through our carefully designed holistic human evaluation protocol with more than 50 professional human evaluators, Hunyuan-DiT sets a new state-of-the-art in Chinese-to-image generation compared with other open-source models.
|
113 |
+
|
114 |
+
|
115 |
+
## 🎉 **Hunyuan-DiT Key Features**
|
116 |
+
### **Chinese-English Bilingual DiT Architecture**
|
117 |
+
Hunyuan-DiT is a diffusion model in the latent space, as depicted in figure below. Following the Latent Diffusion Model, we use a pre-trained Variational Autoencoder (VAE) to compress the images into low-dimensional latent spaces and train a diffusion model to learn the data distribution with diffusion models. Our diffusion model is parameterized with a transformer. To encode the text prompts, we leverage a combination of pre-trained bilingual (English and Chinese) CLIP and multilingual T5 encoder.
|
118 |
+
<p align="center">
|
119 |
+
<img src="https://raw.githubusercontent.com/Tencent/HunyuanDiT/main/asset/framework.png" height=450>
|
120 |
+
</p>
|
121 |
+
|
122 |
+
### Multi-turn Text2Image Generation
|
123 |
+
Understanding natural language instructions and performing multi-turn interaction with users are important for a
|
124 |
+
text-to-image system. It can help build a dynamic and iterative creation process that bring the user’s idea into reality
|
125 |
+
step by step. In this section, we will detail how we empower Hunyuan-DiT with the ability to perform multi-round
|
126 |
+
conversations and image generation. We train MLLM to understand the multi-round user dialogue
|
127 |
+
and output the new text prompt for image generation.
|
128 |
+
<p align="center">
|
129 |
+
<img src="https://raw.githubusercontent.com/Tencent/HunyuanDiT/main/asset/mllm.png" height=300>
|
130 |
+
</p>
|
131 |
+
|
132 |
+
## 📈 Comparisons
|
133 |
+
In order to comprehensively compare the generation capabilities of HunyuanDiT and other models, we constructed a 4-dimensional test set, including Text-Image Consistency, Excluding AI Artifacts, Subject Clarity, Aesthetic. More than 50 professional evaluators performs the evaluation.
|
134 |
+
|
135 |
+
<p align="center">
|
136 |
+
<table>
|
137 |
+
<thead>
|
138 |
+
<tr>
|
139 |
+
<th rowspan="2">Model</th> <th rowspan="2">Open Source</th> <th>Text-Image Consistency (%)</th> <th>Excluding AI Artifacts (%)</th> <th>Subject Clarity (%)</th> <th rowspan="2">Aesthetics (%)</th> <th rowspan="2">Overall (%)</th>
|
140 |
+
</tr>
|
141 |
+
</thead>
|
142 |
+
<tbody>
|
143 |
+
<tr>
|
144 |
+
<td>SDXL</td> <td> ✔ </td> <td>64.3</td> <td>60.6</td> <td>91.1</td> <td>76.3</td> <td>42.7</td>
|
145 |
+
</tr>
|
146 |
+
<tr>
|
147 |
+
<td>PixArt-α</td> <td> ✔</td> <td>68.3</td> <td>60.9</td> <td>93.2</td> <td>77.5</td> <td>45.5</td>
|
148 |
+
</tr>
|
149 |
+
<tr>
|
150 |
+
<td>Playground 2.5</td> <td>✔</td> <td>71.9</td> <td>70.8</td> <td>94.9</td> <td>83.3</td> <td>54.3</td>
|
151 |
+
</tr>
|
152 |
+
|
153 |
+
<tr>
|
154 |
+
<td>SD 3</td> <td>✘</td> <td>77.1</td> <td>69.3</td> <td>94.6</td> <td>82.5</td> <td>56.7</td>
|
155 |
+
|
156 |
+
</tr>
|
157 |
+
<tr>
|
158 |
+
<td>MidJourney v6</td><td>✘</td> <td>73.5</td> <td>80.2</td> <td>93.5</td> <td>87.2</td> <td>63.3</td>
|
159 |
+
</tr>
|
160 |
+
<tr>
|
161 |
+
<td>DALL-E 3</td><td>✘</td> <td>83.9</td> <td>80.3</td> <td>96.5</td> <td>89.4</td> <td>71.0</td>
|
162 |
+
</tr>
|
163 |
+
<tr style="font-weight: bold; background-color: #f2f2f2;">
|
164 |
+
<td>Hunyuan-DiT</td><td>✔</td> <td>74.2</td> <td>74.3</td> <td>95.4</td> <td>86.6</td> <td>59.0</td>
|
165 |
+
</tr>
|
166 |
+
</tbody>
|
167 |
+
</table>
|
168 |
+
</p>
|
169 |
+
|
170 |
+
## 🎥 Visualization
|
171 |
+
|
172 |
+
* **Chinese Elements**
|
173 |
+
<p align="center">
|
174 |
+
<img src="https://raw.githubusercontent.com/Tencent/HunyuanDiT/main/asset/chinese elements understanding.png" height=220>
|
175 |
+
</p>
|
176 |
+
|
177 |
+
* **Long Text Input**
|
178 |
+
|
179 |
+
|
180 |
+
<p align="center">
|
181 |
+
<img src="https://raw.githubusercontent.com/Tencent/HunyuanDiT/main/asset/long text understanding.png" height=310>
|
182 |
+
</p>
|
183 |
+
|
184 |
+
* **Multi-turn Text2Image Generation**
|
185 |
+
|
186 |
+
https://github.com/Tencent/tencent.github.io/assets/27557933/94b4dcc3-104d-44e1-8bb2-dc55108763d1
|
187 |
+
|
188 |
+
|
189 |
+
|
190 |
---
|
191 |
+
|
192 |
+
## 📜 Requirements
|
193 |
+
|
194 |
+
This repo consists of DialogGen (a prompt enhancement model) and Hunyuan-DiT (a text-to-image model).
|
195 |
+
|
196 |
+
The following table shows the requirements for running the models (batch size = 1):
|
197 |
+
|
198 |
+
| Model | --load-4bit (DialogGen) | GPU Peak Memory | GPU |
|
199 |
+
|:-----------------------:|:-----------------------:|:---------------:|:---------------:|
|
200 |
+
| DialogGen + Hunyuan-DiT | ✘ | 32G | A100 |
|
201 |
+
| DialogGen + Hunyuan-DiT | ✔ | 22G | A100 |
|
202 |
+
| Hunyuan-DiT | - | 11G | A100 |
|
203 |
+
| Hunyuan-DiT | - | 14G | RTX3090/RTX4090 |
|
204 |
+
|
205 |
+
* An NVIDIA GPU with CUDA support is required.
|
206 |
+
* We have tested V100 and A100 GPUs.
|
207 |
+
* **Minimum**: The minimum GPU memory required is 11GB.
|
208 |
+
* **Recommended**: We recommend using a GPU with 32GB of memory for better generation quality.
|
209 |
+
* Tested operating system: Linux
|
210 |
+
|
211 |
+
## 🛠️ Dependencies and Installation
|
212 |
+
|
213 |
+
Begin by cloning the repository:
|
214 |
+
```shell
|
215 |
+
git clone https://github.com/tencent/HunyuanDiT
|
216 |
+
cd HunyuanDiT
|
217 |
+
```
|
218 |
+
|
219 |
+
### Installation Guide for Linux
|
220 |
+
|
221 |
+
We provide an `environment.yml` file for setting up a Conda environment.
|
222 |
+
Conda's installation instructions are available [here](https://docs.anaconda.com/free/miniconda/index.html).
|
223 |
+
|
224 |
+
```shell
|
225 |
+
# 1. Prepare conda environment
|
226 |
+
conda env create -f environment.yml
|
227 |
+
|
228 |
+
# 2. Activate the environment
|
229 |
+
conda activate HunyuanDiT
|
230 |
+
|
231 |
+
# 3. Install pip dependencies
|
232 |
+
python -m pip install -r requirements.txt
|
233 |
+
|
234 |
+
# 4. (Optional) Install flash attention v2 for acceleration (requires CUDA 11.6 or above)
|
235 |
+
python -m pip install git+https://github.com/Dao-AILab/[email protected]
|
236 |
+
```
|
237 |
+
|
238 |
+
## 🧱 Download Pretrained Models
|
239 |
+
To download the model, first install the huggingface-cli. (Detailed instructions are available [here](https://huggingface.co/docs/huggingface_hub/guides/cli).)
|
240 |
+
|
241 |
+
```shell
|
242 |
+
python -m pip install "huggingface_hub[cli]"
|
243 |
+
```
|
244 |
+
|
245 |
+
Then download the model using the following commands:
|
246 |
+
|
247 |
+
```shell
|
248 |
+
# Create a directory named 'ckpts' where the model will be saved, fulfilling the prerequisites for running the demo.
|
249 |
+
mkdir ckpts
|
250 |
+
# Use the huggingface-cli tool to download the model.
|
251 |
+
# The download time may vary from 10 minutes to 1 hour depending on network conditions.
|
252 |
+
huggingface-cli download Tencent-Hunyuan/HunyuanDiT --local-dir ./ckpts
|
253 |
+
```
|
254 |
+
|
255 |
+
<details>
|
256 |
+
<summary>💡Tips for using huggingface-cli (network problem)</summary>
|
257 |
+
|
258 |
+
##### 1. Using HF-Mirror
|
259 |
+
|
260 |
+
If you encounter slow download speeds in China, you can try a mirror to speed up the download process. For example,
|
261 |
+
|
262 |
+
```shell
|
263 |
+
HF_ENDPOINT=https://hf-mirror.com huggingface-cli download Tencent-Hunyuan/HunyuanDiT --local-dir ./ckpts
|
264 |
+
```
|
265 |
+
|
266 |
+
##### 2. Resume Download
|
267 |
+
|
268 |
+
`huggingface-cli` supports resuming downloads. If the download is interrupted, you can just rerun the download
|
269 |
+
command to resume the download process.
|
270 |
+
|
271 |
+
Note: If an `No such file or directory: 'ckpts/.huggingface/.gitignore.lock'` like error occurs during the download
|
272 |
+
process, you can ignore the error and rerun the download command.
|
273 |
+
|
274 |
+
</details>
|
275 |
+
|
276 |
---
|
277 |
+
|
278 |
+
All models will be automatically downloaded. For more information about the model, visit the Hugging Face repository [here](https://huggingface.co/Tencent-Hunyuan/HunyuanDiT).
|
279 |
+
|
280 |
+
| Model | #Params | Huggingface Download URL | Tencent Cloud Download URL |
|
281 |
+
|:------------------:|:-------:|:-------------------------------------------------------------------------------------------------------:|:-----------------------------------------------------------------------------------------------:|
|
282 |
+
| mT5 | 1.6B | [mT5](https://huggingface.co/Tencent-Hunyuan/HunyuanDiT/tree/main/t2i/mt5) | [mT5](https://dit.hunyuan.tencent.com/download/HunyuanDiT/mt5.zip) |
|
283 |
+
| CLIP | 350M | [CLIP](https://huggingface.co/Tencent-Hunyuan/HunyuanDiT/tree/main/t2i/clip_text_encoder) | [CLIP](https://dit.hunyuan.tencent.com/download/HunyuanDiT/clip_text_encoder.zip) |
|
284 |
+
| Tokenizer | - | [Tokenizer](https://huggingface.co/Tencent-Hunyuan/HunyuanDiT/tree/main/t2i/tokenizer) | [Tokenizer](https://dit.hunyuan.tencent.com/download/HunyuanDiT/tokenizer.zip) |
|
285 |
+
| DialogGen | 7.0B | [DialogGen](https://huggingface.co/Tencent-Hunyuan/HunyuanDiT/tree/main/dialoggen) | [DialogGen](https://dit.hunyuan.tencent.com/download/HunyuanDiT/dialoggen.zip) |
|
286 |
+
| sdxl-vae-fp16-fix | 83M | [sdxl-vae-fp16-fix](https://huggingface.co/Tencent-Hunyuan/HunyuanDiT/tree/main/t2i/sdxl-vae-fp16-fix) | [sdxl-vae-fp16-fix](https://dit.hunyuan.tencent.com/download/HunyuanDiT/sdxl-vae-fp16-fix.zip) |
|
287 |
+
| Hunyuan-DiT | 1.5B | [Hunyuan-DiT](https://huggingface.co/Tencent-Hunyuan/HunyuanDiT/tree/main/t2i/model) | [Hunyuan-DiT](https://dit.hunyuan.tencent.com/download/HunyuanDiT/model.zip) |
|
288 |
+
| Data demo | - | - | [Data demo](https://dit.hunyuan.tencent.com/download/HunyuanDiT/data_demo.zip) |
|
289 |
+
|
290 |
+
## :truck: Training
|
291 |
+
|
292 |
+
### Data Preparation
|
293 |
+
|
294 |
+
Refer to the commands below to prepare the training data.
|
295 |
+
|
296 |
+
1. Install dependencies
|
297 |
+
|
298 |
+
We offer an efficient data management library, named IndexKits, supporting the management of reading hundreds of millions of data during training, see more in [docs](./IndexKits/README.md).
|
299 |
+
```shell
|
300 |
+
# 1 Install dependencies
|
301 |
+
cd HunyuanDiT
|
302 |
+
pip install -e ./IndexKits
|
303 |
+
```
|
304 |
+
2. Data download
|
305 |
+
|
306 |
+
Feel free to download the [data demo](https://dit.hunyuan.tencent.com/download/HunyuanDiT/data_demo.zip).
|
307 |
+
```shell
|
308 |
+
# 2 Data download
|
309 |
+
wget -O ./dataset/data_demo.zip https://dit.hunyuan.tencent.com/download/HunyuanDiT/data_demo.zip
|
310 |
+
unzip ./dataset/data_demo.zip -d ./dataset
|
311 |
+
mkdir ./dataset/porcelain/arrows ./dataset/porcelain/jsons
|
312 |
+
```
|
313 |
+
3. Data conversion
|
314 |
+
|
315 |
+
Create a CSV file for training data with the fields listed in the table below.
|
316 |
+
|
317 |
+
| Fields | Required | Description | Example |
|
318 |
+
|:---------------:| :------: |:----------------:|:-----------:|
|
319 |
+
| `image_path` | Required | image path | `./dataset/porcelain/images/0.png` |
|
320 |
+
| `text_zh` | Required | text | 青花瓷风格,一只蓝色的鸟儿站在蓝色的花瓶上,周围点缀着白色花朵,背景是白色 |
|
321 |
+
| `md5` | Optional | image md5 (Message Digest Algorithm 5) | `d41d8cd98f00b204e9800998ecf8427e` |
|
322 |
+
| `width` | Optional | image width | `1024 ` |
|
323 |
+
| `height` | Optional | image height | ` 1024 ` |
|
324 |
+
|
325 |
+
> ⚠️ Optional fields like MD5, width, and height can be omitted. If omitted, the script below will automatically calculate them. This process can be time-consuming when dealing with large-scale training data.
|
326 |
+
|
327 |
+
We utilize [Arrow](https://github.com/apache/arrow) for training data format, offering a standard and efficient in-memory data representation. A conversion script is provided to transform CSV files into Arrow format.
|
328 |
+
```shell
|
329 |
+
# 3 Data conversion
|
330 |
+
python ./hydit/data_loader/csv2arrow.py ./dataset/porcelain/csvfile/image_text.csv ./dataset/porcelain/arrows
|
331 |
+
```
|
332 |
+
|
333 |
+
4. Data Selection and Configuration File Creation
|
334 |
+
|
335 |
+
We configure the training data through YAML files. In these files, you can set up standard data processing strategies for filtering, copying, deduplicating, and more regarding the training data. For more details, see [docs](IndexKits/docs/MakeDataset.md).
|
336 |
+
|
337 |
+
For a sample file, please refer to [file](./dataset/yamls/porcelain.yaml). For a full parameter configuration file, see [file](./IndexKits/docs/MakeDataset.md).
|
338 |
+
|
339 |
+
|
340 |
+
5. Create training data index file using YAML file.
|
341 |
+
|
342 |
+
```shell
|
343 |
+
# Single Resolution Data Preparation
|
344 |
+
cd /HunyuanDiT
|
345 |
+
idk base -c dataset/yamls/porcelain.yaml -t dataset/porcelain/jsons/porcelain.json
|
346 |
+
|
347 |
+
# Multi Resolution Data Preparation
|
348 |
+
idk multireso -c dataset/yamls/porcelain_mt.yaml -t dataset/porcelain/jsons/porcelain_mt.json
|
349 |
+
```
|
350 |
+
|
351 |
+
The directory structure for `porcelain` dataset is:
|
352 |
+
|
353 |
+
```shell
|
354 |
+
cd ./dataset
|
355 |
+
|
356 |
+
porcelain
|
357 |
+
├──images/ (image files)
|
358 |
+
│ ├──0.png
|
359 |
+
│ ├──1.png
|
360 |
+
│ ├──......
|
361 |
+
├──csvfile/ (csv files containing text-image pairs)
|
362 |
+
│ ├──image_text.csv
|
363 |
+
├──arrows/ (arrow files containing all necessary training data)
|
364 |
+
│ ├──00000.arrow
|
365 |
+
│ ├──00001.arrow
|
366 |
+
│ ├──......
|
367 |
+
├──jsons/ (final training data index files which read data from arrow files during training)
|
368 |
+
│ ├──porcelain.json
|
369 |
+
│ ├──porcelain_mt.json
|
370 |
+
```
|
371 |
+
|
372 |
+
### Full-parameter Training
|
373 |
+
|
374 |
+
To leverage DeepSpeed in training, you have the flexibility to control **single-node** / **multi-node** training by adjusting parameters such as `--hostfile` and `--master_addr`. For more details, see [link](https://www.deepspeed.ai/getting-started/#resource-configuration-multi-node).
|
375 |
+
|
376 |
+
```shell
|
377 |
+
# Single Resolution Data Preparation
|
378 |
+
PYTHONPATH=./ sh hydit/train.sh --index-file dataset/porcelain/jsons/porcelain.json
|
379 |
+
|
380 |
+
# Multi Resolution Data Preparation
|
381 |
+
PYTHONPATH=./ sh hydit/train.sh --index-file dataset/porcelain/jsons/porcelain.json --multireso --reso-step 64
|
382 |
+
```
|
383 |
+
|
384 |
+
### LoRA
|
385 |
+
|
386 |
+
We provide training and inference scripts for LoRA, detailed in the [guidances](./lora/README.md).
|
387 |
+
|
388 |
+
|
389 |
+
## 🔑 Inference
|
390 |
+
|
391 |
+
### Using Gradio
|
392 |
+
|
393 |
+
Make sure the conda environment is activated before running the following command.
|
394 |
+
|
395 |
+
```shell
|
396 |
+
# By default, we start a Chinese UI.
|
397 |
+
python app/hydit_app.py
|
398 |
+
|
399 |
+
# Using Flash Attention for acceleration.
|
400 |
+
python app/hydit_app.py --infer-mode fa
|
401 |
+
|
402 |
+
# You can disable the enhancement model if the GPU memory is insufficient.
|
403 |
+
# The enhancement will be unavailable until you restart the app without the `--no-enhance` flag.
|
404 |
+
python app/hydit_app.py --no-enhance
|
405 |
+
|
406 |
+
# Start with English UI
|
407 |
+
python app/hydit_app.py --lang en
|
408 |
+
|
409 |
+
# Start a multi-turn T2I generation UI.
|
410 |
+
# If your GPU memory is less than 32GB, use '--load-4bit' to enable 4-bit quantization, which requires at least 22GB of memory.
|
411 |
+
python app/multiTurnT2I_app.py
|
412 |
+
```
|
413 |
+
Then the demo can be accessed through http://0.0.0.0:443. It should be noted that the 0.0.0.0 here needs to be X.X.X.X with your server IP.
|
414 |
+
|
415 |
+
### Using 🤗 Diffusers
|
416 |
+
|
417 |
+
Please install PyTorch version 2.0 or higher in advance to satisfy the requirements of the specified version of the diffusers library.
|
418 |
+
|
419 |
+
Install 🤗 diffusers, ensuring that the version is at least 0.28.1:
|
420 |
+
|
421 |
+
```shell
|
422 |
+
pip install git+https://github.com/huggingface/diffusers.git
|
423 |
+
```
|
424 |
+
or
|
425 |
+
```shell
|
426 |
+
pip install diffusers
|
427 |
+
```
|
428 |
+
|
429 |
+
You can generate images with both Chinese and English prompts using the following Python script:
|
430 |
+
```py
|
431 |
+
import torch
|
432 |
+
from diffusers import HunyuanDiTPipeline
|
433 |
+
|
434 |
+
pipe = HunyuanDiTPipeline.from_pretrained("Tencent-Hunyuan/HunyuanDiT-Diffusers", torch_dtype=torch.float16)
|
435 |
+
pipe.to("cuda")
|
436 |
+
|
437 |
+
# You may also use English prompt as HunyuanDiT supports both English and Chinese
|
438 |
+
# prompt = "An astronaut riding a horse"
|
439 |
+
prompt = "一个宇航员在骑马"
|
440 |
+
image = pipe(prompt).images[0]
|
441 |
+
```
|
442 |
+
You can use our distilled model to generate images even faster:
|
443 |
+
|
444 |
+
```py
|
445 |
+
import torch
|
446 |
+
from diffusers import HunyuanDiTPipeline
|
447 |
+
|
448 |
+
pipe = HunyuanDiTPipeline.from_pretrained("Tencent-Hunyuan/HunyuanDiT-Diffusers-Distilled", torch_dtype=torch.float16)
|
449 |
+
pipe.to("cuda")
|
450 |
+
|
451 |
+
# You may also use English prompt as HunyuanDiT supports both English and Chinese
|
452 |
+
# prompt = "An astronaut riding a horse"
|
453 |
+
prompt = "一个宇航员在骑马"
|
454 |
+
image = pipe(prompt, num_inference_steps=25).images[0]
|
455 |
+
```
|
456 |
+
More details can be found in [HunyuanDiT-Diffusers-Distilled](https://huggingface.co/Tencent-Hunyuan/HunyuanDiT-Diffusers-Distilled)
|
457 |
+
|
458 |
+
### Using Command Line
|
459 |
+
|
460 |
+
We provide several commands to quick start:
|
461 |
+
|
462 |
+
```shell
|
463 |
+
# Prompt Enhancement + Text-to-Image. Torch mode
|
464 |
+
python sample_t2i.py --prompt "渔舟唱晚"
|
465 |
+
|
466 |
+
# Only Text-to-Image. Torch mode
|
467 |
+
python sample_t2i.py --prompt "渔舟唱晚" --no-enhance
|
468 |
+
|
469 |
+
# Only Text-to-Image. Flash Attention mode
|
470 |
+
python sample_t2i.py --infer-mode fa --prompt "渔舟唱晚"
|
471 |
+
|
472 |
+
# Generate an image with other image sizes.
|
473 |
+
python sample_t2i.py --prompt "渔舟唱晚" --image-size 1280 768
|
474 |
+
|
475 |
+
# Prompt Enhancement + Text-to-Image. DialogGen loads with 4-bit quantization, but it may loss performance.
|
476 |
+
python sample_t2i.py --prompt "渔舟唱晚" --load-4bit
|
477 |
+
|
478 |
+
```
|
479 |
+
|
480 |
+
More example prompts can be found in [example_prompts.txt](example_prompts.txt)
|
481 |
+
|
482 |
+
### More Configurations
|
483 |
+
|
484 |
+
We list some more useful configurations for easy usage:
|
485 |
+
|
486 |
+
| Argument | Default | Description |
|
487 |
+
|:---------------:|:---------:|:---------------------------------------------------:|
|
488 |
+
| `--prompt` | None | The text prompt for image generation |
|
489 |
+
| `--image-size` | 1024 1024 | The size of the generated image |
|
490 |
+
| `--seed` | 42 | The random seed for generating images |
|
491 |
+
| `--infer-steps` | 100 | The number of steps for sampling |
|
492 |
+
| `--negative` | - | The negative prompt for image generation |
|
493 |
+
| `--infer-mode` | torch | The inference mode (torch, fa, or trt) |
|
494 |
+
| `--sampler` | ddpm | The diffusion sampler (ddpm, ddim, or dpmms) |
|
495 |
+
| `--no-enhance` | False | Disable the prompt enhancement model |
|
496 |
+
| `--model-root` | ckpts | The root directory of the model checkpoints |
|
497 |
+
| `--load-key` | ema | Load the student model or EMA model (ema or module) |
|
498 |
+
| `--load-4bit` | Fasle | Load DialogGen model with 4bit quantization |
|
499 |
+
|
500 |
+
### Using ComfyUI
|
501 |
+
|
502 |
+
We provide several commands to quick start:
|
503 |
+
|
504 |
+
```shell
|
505 |
+
# Download comfyui code
|
506 |
+
git clone https://github.com/comfyanonymous/ComfyUI.git
|
507 |
+
|
508 |
+
# Install torch, torchvision, torchaudio
|
509 |
+
pip install torch==2.0.1 torchvision==0.15.2 torchaudio==2.0.2 --index-url https://download.pytorch.org/whl/cu117
|
510 |
+
|
511 |
+
# Install Comfyui essential python package
|
512 |
+
cd ComfyUI
|
513 |
+
pip install -r requirements.txt
|
514 |
+
|
515 |
+
# ComfyUI has been successfully installed!
|
516 |
+
|
517 |
+
# Download model weight as before or link the existing model folder to ComfyUI.
|
518 |
+
python -m pip install "huggingface_hub[cli]"
|
519 |
+
mkdir models/hunyuan
|
520 |
+
huggingface-cli download Tencent-Hunyuan/HunyuanDiT --local-dir ./models/hunyuan/ckpts
|
521 |
+
|
522 |
+
# Move to the ComfyUI custom_nodes folder and copy comfyui-hydit folder from HunyuanDiT Repo.
|
523 |
+
cd custom_nodes
|
524 |
+
cp -r ${HunyuanDiT}/comfyui-hydit ./
|
525 |
+
cd comfyui-hydit
|
526 |
+
|
527 |
+
# Install some essential python Package.
|
528 |
+
pip install -r requirements.txt
|
529 |
+
|
530 |
+
# Our tool has been successfully installed!
|
531 |
+
|
532 |
+
# Go to ComfyUI main folder
|
533 |
+
cd ../..
|
534 |
+
# Run the ComfyUI Lauch command
|
535 |
+
python main.py --listen --port 80
|
536 |
+
|
537 |
+
# Running ComfyUI successfully!
|
538 |
+
```
|
539 |
+
More details can be found in [ComfyUI README](comfyui-hydit/README.md)
|
540 |
+
|
541 |
+
## 🚀 Acceleration (for Linux)
|
542 |
+
|
543 |
+
- We provide TensorRT version of HunyuanDiT for inference acceleration (faster than flash attention).
|
544 |
+
See [Tencent-Hunyuan/TensorRT-libs](https://huggingface.co/Tencent-Hunyuan/TensorRT-libs) for more details.
|
545 |
+
|
546 |
+
- We provide Distillation version of HunyuanDiT for inference acceleration.
|
547 |
+
See [Tencent-Hunyuan/Distillation](https://huggingface.co/Tencent-Hunyuan/Distillation) for more details.
|
548 |
+
|
549 |
+
## 🔗 BibTeX
|
550 |
+
If you find [Hunyuan-DiT](https://arxiv.org/abs/2405.08748) or [DialogGen](https://arxiv.org/abs/2403.08857) useful for your research and applications, please cite using this BibTeX:
|
551 |
+
|
552 |
+
```BibTeX
|
553 |
+
@misc{li2024hunyuandit,
|
554 |
+
title={Hunyuan-DiT: A Powerful Multi-Resolution Diffusion Transformer with Fine-Grained Chinese Understanding},
|
555 |
+
author={Zhimin Li and Jianwei Zhang and Qin Lin and Jiangfeng Xiong and Yanxin Long and Xinchi Deng and Yingfang Zhang and Xingchao Liu and Minbin Huang and Zedong Xiao and Dayou Chen and Jiajun He and Jiahao Li and Wenyue Li and Chen Zhang and Rongwei Quan and Jianxiang Lu and Jiabin Huang and Xiaoyan Yuan and Xiaoxiao Zheng and Yixuan Li and Jihong Zhang and Chao Zhang and Meng Chen and Jie Liu and Zheng Fang and Weiyan Wang and Jinbao Xue and Yangyu Tao and Jianchen Zhu and Kai Liu and Sihuan Lin and Yifu Sun and Yun Li and Dongdong Wang and Mingtao Chen and Zhichao Hu and Xiao Xiao and Yan Chen and Yuhong Liu and Wei Liu and Di Wang and Yong Yang and Jie Jiang and Qinglin Lu},
|
556 |
+
year={2024},
|
557 |
+
eprint={2405.08748},
|
558 |
+
archivePrefix={arXiv},
|
559 |
+
primaryClass={cs.CV}
|
560 |
+
}
|
561 |
+
|
562 |
+
@article{huang2024dialoggen,
|
563 |
+
title={DialogGen: Multi-modal Interactive Dialogue System for Multi-turn Text-to-Image Generation},
|
564 |
+
author={Huang, Minbin and Long, Yanxin and Deng, Xinchi and Chu, Ruihang and Xiong, Jiangfeng and Liang, Xiaodan and Cheng, Hong and Lu, Qinglin and Liu, Wei},
|
565 |
+
journal={arXiv preprint arXiv:2403.08857},
|
566 |
+
year={2024}
|
567 |
+
}
|
568 |
+
```
|
569 |
+
|
570 |
+
## Start History
|
571 |
+
|
572 |
+
<a href="https://star-history.com/#Tencent/HunyuanDiT&Date">
|
573 |
+
<picture>
|
574 |
+
<source media="(prefers-color-scheme: dark)" srcset="https://api.star-history.com/svg?repos=Tencent/HunyuanDiT&type=Date&theme=dark" />
|
575 |
+
<source media="(prefers-color-scheme: light)" srcset="https://api.star-history.com/svg?repos=Tencent/HunyuanDiT&type=Date" />
|
576 |
+
<img alt="Star History Chart" src="https://api.star-history.com/svg?repos=Tencent/HunyuanDiT&type=Date" />
|
577 |
+
</picture>
|
578 |
+
</a>
|
t2i/model/pytorch_model_ema.pt
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:ab23c3ae8d81ab2ea9f0b13494e08f88574143d58603da588fb671ff189740fd
|
3 |
+
size 6066602623
|
t2i/model/pytorch_model_module.pt
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:60fe6c4e5ee4171e532e3805c5f9078b3ce637e46550c3a38767ee07af0383aa
|
3 |
+
size 3033268125
|