zR
commited on
Commit
•
0defbe5
1
Parent(s):
4ed09bf
release
Browse files- README.md +99 -0
- README_zh.md +84 -0
README.md
ADDED
@@ -0,0 +1,99 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
---
|
2 |
+
license: apache-2.0
|
3 |
+
license_link: LICENSE.md
|
4 |
+
|
5 |
+
language:
|
6 |
+
- en
|
7 |
+
|
8 |
+
tags:
|
9 |
+
- text-to-image
|
10 |
+
- image-generation
|
11 |
+
- cogview
|
12 |
+
|
13 |
+
inference: false
|
14 |
+
---
|
15 |
+
|
16 |
+
# CogView3-Plus-3B
|
17 |
+
|
18 |
+
<p style="text-align: center;">
|
19 |
+
<div align="center">
|
20 |
+
<img src=https://github.com/THUDM/CogView3/raw/main/resources/logo.svg width="50%"/>
|
21 |
+
</div>
|
22 |
+
<p align="center">
|
23 |
+
<a href="README_zh.md">📄 中文阅读 </a> |
|
24 |
+
<a href="https://huggingface.co/spaces/THUDM-HF-SPACE/CogView-3-Plus">🤗 Hugging Face Space | </a>
|
25 |
+
<a href="https://github.com/THUDM/CogView3">🌐 Github </a> |
|
26 |
+
<a href="https://arxiv.org/pdf/2403.05121">📜 arxiv </a>
|
27 |
+
</p>
|
28 |
+
<p align="center">
|
29 |
+
📍 Visit <a href="https://chatglm.cn/main/gdetail/65a232c082ff90a2ad2f15e2?fr=osm_cogvideox&lang=zh"> Qingyan </a> and <a href="https://open.bigmodel.cn/?utm_campaign=open&_channel_track_key=OWTVNma9"> API Platform</a> to experience larger-scale commercial video generation models.
|
30 |
+
</p>
|
31 |
+
|
32 |
+
## Inference Requirements and Model Overview
|
33 |
+
|
34 |
+
This model is the DiT version of CogView3, a text-to-image generation model, supporting image generation from 512 to 2048px.
|
35 |
+
|
36 |
+
+ Resolution: Width and height must meet the range from 512px to 2048px and must be divisible by 32.
|
37 |
+
+ Inference Speed: 1s / step (tested on A100)
|
38 |
+
+ Precision: BF16 / FP32 (FP16 is not supported, as it leads to overflow causing black images)
|
39 |
+
|
40 |
+
## Memory Consumption
|
41 |
+
|
42 |
+
We tested memory consumption at several common resolutions on A100 devices, `batchsize=1, BF16`, as shown in the table below:
|
43 |
+
|
44 |
+
| 分辨率 | enable_model_cpu_offload OFF | enable_model_cpu_offload ON |
|
45 |
+
|-------------|------------------------------|-----------------------------|
|
46 |
+
| 512 * 512 | 19GB | 11GB |
|
47 |
+
| 720 * 480 | 20GB | 11GB |
|
48 |
+
| 1024 * 1024 | 23GB | 11GB |
|
49 |
+
| 1280 * 720 | 24GB | 11GB |
|
50 |
+
| 2048 * 2048 | 25GB | 11GB |
|
51 |
+
|
52 |
+
## Quick Start
|
53 |
+
|
54 |
+
First, ensure the `diffusers` library is installed from source. Then, run the following code:
|
55 |
+
|
56 |
+
```python
|
57 |
+
from diffusers import CogView3PlusPipeline
|
58 |
+
import torch
|
59 |
+
|
60 |
+
pipe = CogView3PlusPipeline.from_pretrained("THUDM/CogView3-Plus-3B", torch_dtype=torch.float16).to("cuda")
|
61 |
+
|
62 |
+
# Enable it to reduce GPU memory usage
|
63 |
+
pipe.enable_model_cpu_offload()
|
64 |
+
pipe.vae.enable_slicing()
|
65 |
+
pipe.vae.enable_tiling()
|
66 |
+
|
67 |
+
prompt = "A vibrant cherry red sports car sits proudly under the gleaming sun, its polished exterior smooth and flawless, casting a mirror-like reflection. The car features a low, aerodynamic body, angular headlights that gaze forward like predatory eyes, and a set of black, high-gloss racing rims that contrast starkly with the red. A subtle hint of chrome embellishes the grille and exhaust, while the tinted windows suggest a luxurious and private interior. The scene conveys a sense of speed and elegance, the car appearing as if it's about to burst into a sprint along a coastal road, with the ocean's azure waves crashing in the background."
|
68 |
+
image = pipe(
|
69 |
+
prompt=prompt,
|
70 |
+
guidance_scale=7.0,
|
71 |
+
num_images_per_prompt=1,
|
72 |
+
num_inference_steps=50,
|
73 |
+
width=1024,
|
74 |
+
height=1024,
|
75 |
+
).images[0]
|
76 |
+
|
77 |
+
image.save("cogview3.png")
|
78 |
+
```
|
79 |
+
|
80 |
+
For more content and to download the original SAT weights, please visit our [GitHub](https://github.com/THUDM/CogView3).
|
81 |
+
|
82 |
+
## Citation
|
83 |
+
|
84 |
+
🌟 If you find our work helpful, feel free to cite our paper and leave a star:
|
85 |
+
|
86 |
+
```
|
87 |
+
@article{zheng2024cogview3,
|
88 |
+
title={Cogview3: Finer and faster text-to-image generation via relay diffusion},
|
89 |
+
author={Zheng, Wendi and Teng, Jiayan and Yang, Zhuoyi and Wang, Weihan and Chen, Jidong and Gu, Xiaotao and Dong, Yuxiao and Ding, Ming and Tang, Jie},
|
90 |
+
journal={arXiv preprint arXiv:2403.05121},
|
91 |
+
year={2024}
|
92 |
+
}
|
93 |
+
```
|
94 |
+
|
95 |
+
We welcome your contributions, and you can click [here](resources/contribute_zh.md) for more information.
|
96 |
+
|
97 |
+
## Model License
|
98 |
+
|
99 |
+
This Model is released under the [Apache 2.0 License](LICENSE).
|
README_zh.md
ADDED
@@ -0,0 +1,84 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# CogView3-Plus-3B
|
2 |
+
|
3 |
+
<p style="text-align: center;">
|
4 |
+
<div align="center">
|
5 |
+
<img src=https://github.com/THUDM/CogView3/raw/main/resources/logo.svg width="50%"/>
|
6 |
+
</div>
|
7 |
+
<p align="center">
|
8 |
+
<a href="README.md">📄 Read in English</a> |
|
9 |
+
<a href="https://huggingface.co/spaces/THUDM-HF-SPACE/CogView-3-Plus">🤗 Hugging Face Space | </a>
|
10 |
+
<a href="https://github.com/THUDM/CogView3">🌐 Github </a> |
|
11 |
+
<a href="https://arxiv.org/pdf/2403.05121">📜 arxiv </a>
|
12 |
+
</p>
|
13 |
+
<p align="center">
|
14 |
+
📍 前往<a href="https://chatglm.cn/main/gdetail/65a232c082ff90a2ad2f15e2?fr=osm_cogvideox&lang=zh"> 清言 </a> 和 <a href="https://open.bigmodel.cn/?utm_campaign=open&_channel_track_key=OWTVNma9"> API平台</a> 体验更大规模的商业版视频生成模型。
|
15 |
+
</p>
|
16 |
+
|
17 |
+
## 推理要求和模型介绍
|
18 |
+
|
19 |
+
该模型是 CogView3 的 DiT 版本图像生成模型,支持从 512 到 2048 范围内的图像生成。
|
20 |
+
|
21 |
+
+ 分辨率: 长宽均需满足 512px - 2048px 之间,均需被32整除。
|
22 |
+
+ 推理速度: 1s / step (在 A100 进行测试)
|
23 |
+
+ 精度: BF16 / FP32 (不支持FP16,会出现溢出导致纯黑图片)
|
24 |
+
|
25 |
+
## 显存消耗
|
26 |
+
|
27 |
+
我们在A100设备上对几个常见分辨率的显存消耗进行了测试,`batchsize=1, BF16`, 如下表所示:
|
28 |
+
|
29 |
+
| 分辨率 | enable_model_cpu_offload OFF | enable_model_cpu_offload ON |
|
30 |
+
|-------------|------------------------------|-----------------------------|
|
31 |
+
| 512 * 512 | 19GB | 11GB |
|
32 |
+
| 720 * 480 | 20GB | 11GB |
|
33 |
+
| 1024 * 1024 | 23GB | 11GB |
|
34 |
+
| 1280 * 720 | 24GB | 11GB |
|
35 |
+
| 2048 * 2048 | 25GB | 11GB |
|
36 |
+
|
37 |
+
## 快速开始
|
38 |
+
|
39 |
+
首先,确保从源代码安装`diffusers`库。接着,运行以下代码:
|
40 |
+
|
41 |
+
```python
|
42 |
+
from diffusers import CogView3PlusPipeline
|
43 |
+
import torch
|
44 |
+
|
45 |
+
pipe = CogView3PlusPipeline.from_pretrained("THUDM/CogView3-Plus-3B", torch_dtype=torch.float16).to("cuda")
|
46 |
+
|
47 |
+
# Open it for reduce GPU memory usage
|
48 |
+
pipe.enable_model_cpu_offload()
|
49 |
+
pipe.vae.enable_slicing()
|
50 |
+
pipe.vae.enable_tiling()
|
51 |
+
|
52 |
+
prompt = "A vibrant cherry red sports car sits proudly under the gleaming sun, its polished exterior smooth and flawless, casting a mirror-like reflection. The car features a low, aerodynamic body, angular headlights that gaze forward like predatory eyes, and a set of black, high-gloss racing rims that contrast starkly with the red. A subtle hint of chrome embellishes the grille and exhaust, while the tinted windows suggest a luxurious and private interior. The scene conveys a sense of speed and elegance, the car appearing as if it's about to burst into a sprint along a coastal road, with the ocean's azure waves crashing in the background."
|
53 |
+
image = pipe(
|
54 |
+
prompt=prompt,
|
55 |
+
guidance_scale=7.0,
|
56 |
+
num_images_per_prompt=1,
|
57 |
+
num_inference_steps=50,
|
58 |
+
width=1024,
|
59 |
+
height=1024,
|
60 |
+
).images[0]
|
61 |
+
|
62 |
+
image.save("cogview3.png")
|
63 |
+
```
|
64 |
+
|
65 |
+
更多内容以及下载 SAT 原始权重,请前往我们的 [github](https://github.com/THUDM/CogView3)。
|
66 |
+
|
67 |
+
## 引用
|
68 |
+
|
69 |
+
🌟 如果您发现我们的工作有所帮助,欢迎引用我们的文章,留下宝贵的stars
|
70 |
+
|
71 |
+
```
|
72 |
+
@article{zheng2024cogview3,
|
73 |
+
title={Cogview3: Finer and faster text-to-image generation via relay diffusion},
|
74 |
+
author={Zheng, Wendi and Teng, Jiayan and Yang, Zhuoyi and Wang, Weihan and Chen, Jidong and Gu, Xiaotao and Dong, Yuxiao and Ding, Ming and Tang, Jie},
|
75 |
+
journal={arXiv preprint arXiv:2403.05121},
|
76 |
+
year={2024}
|
77 |
+
}
|
78 |
+
```
|
79 |
+
|
80 |
+
我们欢迎您的贡献,您可以点击[这里](resources/contribute_zh.md)查看更多信息。
|
81 |
+
|
82 |
+
## 模型协议
|
83 |
+
|
84 |
+
该模型基于 [Apache 2.0 License](LICENSE) 协议发布。
|