Files changed (1) hide show
  1. README.md +139 -138
README.md CHANGED
@@ -1,138 +1,139 @@
1
- ---
2
- license: apache-2.0
3
- language:
4
- - zh
5
- - en
6
- base_model:
7
- - THUDM/glm-4-9b
8
- pipeline_tag: text-to-image
9
- library_name: diffusers
10
- ---
11
-
12
- # CogView4-6B
13
-
14
- <p style="text-align: center;">
15
- <div align="center">
16
- <img src=https://github.com/THUDM/CogView4/raw/main/resources/logo.svg width="50%"/>
17
- </div>
18
- <p align="center">
19
- <a href="https://huggingface.co/spaces/THUDM-HF-SPACE/CogView4">πŸ€— Space | </a>
20
- <a href="https://github.com/THUDM/CogView4">🌐 Github </a> |
21
- <a href="https://arxiv.org/pdf/2403.05121">πŸ“œ CogView3 Paper </a>
22
- </p>
23
-
24
- ![img](https://raw.githubusercontent.com/THUDM/CogView4/refs/heads/main/resources/showcase.png)
25
-
26
- ## Inference Requirements and Model Introduction
27
-
28
- + Resolution: Width and height must be between `512px` and `2048px`, divisible by `32`, and ensure the maximum number of
29
- pixels does not exceed `2^21` px.
30
- + Precision: BF16 / FP32 (FP16 is not supported as it will cause overflow resulting in completely black images)
31
-
32
- Using `BF16` precision with `batchsize=4` for testing, the memory usage is shown in the table below:
33
-
34
- | Resolution | enable_model_cpu_offload OFF | enable_model_cpu_offload ON | enable_model_cpu_offload ON </br> Text Encoder 4bit |
35
- |-------------|------------------------------|-----------------------------|-----------------------------------------------------|
36
- | 512 * 512 | 33GB | 20GB | 13G |
37
- | 1280 * 720 | 35GB | 20GB | 13G |
38
- | 1024 * 1024 | 35GB | 20GB | 13G |
39
- | 1920 * 1280 | 39GB | 20GB | 14G |
40
-
41
- ## Quick Start
42
-
43
- First, ensure you install the `diffusers` library from source.
44
-
45
- ```shell
46
- pip install git+https://github.com/huggingface/diffusers.git
47
- cd diffusers
48
- pip install -e .
49
- ```
50
-
51
- Then, run the following code:
52
-
53
- ```python
54
- from diffusers import CogView4Pipeline
55
-
56
- pipe = CogView4Pipeline.from_pretrained("THUDM/CogView4-6B", torch_dtype=torch.bfloat16)
57
-
58
- # Open it for reduce GPU memory usage
59
- pipe.enable_model_cpu_offload()
60
- pipe.vae.enable_slicing()
61
- pipe.vae.enable_tiling()
62
-
63
- 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."
64
- image = pipe(
65
- prompt=prompt,
66
- guidance_scale=3.5,
67
- num_images_per_prompt=1,
68
- num_inference_steps=50,
69
- width=1024,
70
- height=1024,
71
- ).images[0]
72
-
73
- image.save("cogview4.png")
74
- ```
75
-
76
- ### Model Metrics
77
-
78
- We've tested on multiple benchmarks and achieved the following scores:
79
-
80
- #### DPG-Bench
81
-
82
- | Model | Overall | Global | Entity | Attribute | Relation | Other |
83
- |-----------------|-----------|-----------|-----------|-----------|-----------|-----------|
84
- | SDXL | 74.65 | 83.27 | 82.43 | 80.91 | 86.76 | 80.41 |
85
- | PixArt-alpha | 71.11 | 74.97 | 79.32 | 78.60 | 82.57 | 76.96 |
86
- | SD3-Medium | 84.08 | 87.90 | **91.01** | 88.83 | 80.70 | 88.68 |
87
- | DALL-E 3 | 83.50 | **90.97** | 89.61 | 88.39 | 90.58 | 89.83 |
88
- | Flux.1-dev | 83.79 | 85.80 | 86.79 | 89.98 | 90.04 | **89.90** |
89
- | Janus-Pro-7B | 84.19 | 86.90 | 88.90 | 89.40 | 89.32 | 89.48 |
90
- | **CogView4-6B** | **85.13** | 83.85 | 90.35 | **91.17** | **91.14** | 87.29 |
91
-
92
- #### GenEval
93
-
94
- | Model | Overall | Single Obj. | Two Obj. | Counting | Colors | Position | Color attribution |
95
- |-----------------|----------|-------------|----------|----------|----------|----------|-------------------|
96
- | SDXL | 0.55 | 0.98 | 0.74 | 0.39 | 0.85 | 0.15 | 0.23 |
97
- | PixArt-alpha | 0.48 | 0.98 | 0.50 | 0.44 | 0.80 | 0.08 | 0.07 |
98
- | SD3-Medium | 0.74 | **0.99** | **0.94** | 0.72 | 0.89 | 0.33 | 0.60 |
99
- | DALL-E 3 | 0.67 | 0.96 | 0.87 | 0.47 | 0.83 | 0.43 | 0.45 |
100
- | Flux.1-dev | 0.66 | 0.98 | 0.79 | **0.73** | 0.77 | 0.22 | 0.45 |
101
- | Janus-Pro-7B | **0.80** | **0.99** | 0.89 | 0.59 | **0.90** | **0.79** | **0.66** |
102
- | **CogView4-6B** | 0.73 | **0.99** | 0.86 | 0.66 | 0.79 | 0.48 | 0.58 |
103
-
104
- #### T2I-CompBench
105
-
106
- | Model | Color | Shape | Texture | 2D-Spatial | 3D-Spatial | Numeracy | Non-spatial Clip | Complex 3-in-1 |
107
- |-----------------|------------|------------|------------|------------|------------|------------|------------------|----------------|
108
- | SDXL | 0.5879 | 0.4687 | 0.5299 | 0.2133 | 0.3566 | 0.4988 | 0.3119 | 0.3237 |
109
- | PixArt-alpha | 0.6690 | 0.4927 | 0.6477 | 0.2064 | 0.3901 | 0.5058 | **0.3197** | 0.3433 |
110
- | SD3-Medium | **0.8132** | 0.5885 | **0.7334** | **0.3200** | **0.4084** | 0.6174 | 0.3140 | 0.3771 |
111
- | DALL-E 3 | 0.7785 | **0.6205** | 0.7036 | 0.2865 | 0.3744 | 0.5880 | 0.3003 | 0.3773 |
112
- | Flux.1-dev | 0.7572 | 0.5066 | 0.6300 | 0.2700 | 0.3992 | 0.6165 | 0.3065 | 0.3628 |
113
- | Janus-Pro-7B | 0.5145 | 0.3323 | 0.4069 | 0.1566 | 0.2753 | 0.4406 | 0.3137 | 0.3806 |
114
- | **CogView4-6B** | 0.7786 | 0.5880 | 0.6983 | 0.3075 | 0.3708 | **0.6626** | 0.3056 | **0.3869** |
115
-
116
- ## Chinese Text Accuracy Evaluation
117
-
118
- | Model | Precision | Recall | F1 Score | Pick@4 |
119
- |-----------------|------------|------------|------------|------------|
120
- | Kolors | 0.6094 | 0.1886 | 0.2880 | 0.1633 |
121
- | **CogView4-6B** | **0.6969** | **0.5532** | **0.6168** | **0.3265** |
122
-
123
- ## Citation
124
-
125
- 🌟 If you find our work helpful, please consider citing our paper and leaving valuable stars
126
-
127
- ```
128
- @article{zheng2024cogview3,
129
- title={Cogview3: Finer and faster text-to-image generation via relay diffusion},
130
- 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},
131
- journal={arXiv preprint arXiv:2403.05121},
132
- year={2024}
133
- }
134
- ```
135
-
136
- ## License
137
-
138
- This model is released under the [Apache 2.0 License](LICENSE).
 
 
1
+ ---
2
+ license: apache-2.0
3
+ language:
4
+ - zh
5
+ - en
6
+ base_model:
7
+ - THUDM/glm-4-9b
8
+ pipeline_tag: text-to-image
9
+ library_name: diffusers
10
+ ---
11
+
12
+ # CogView4-6B
13
+
14
+ <p style="text-align: center;">
15
+ <div align="center">
16
+ <img src=https://github.com/THUDM/CogView4/raw/main/resources/logo.svg width="50%"/>
17
+ </div>
18
+ <p align="center">
19
+ <a href="https://huggingface.co/spaces/THUDM-HF-SPACE/CogView4">πŸ€— Space | </a>
20
+ <a href="https://github.com/THUDM/CogView4">🌐 Github </a> |
21
+ <a href="https://arxiv.org/pdf/2403.05121">πŸ“œ CogView3 Paper </a>
22
+ </p>
23
+
24
+ ![img](https://raw.githubusercontent.com/THUDM/CogView4/refs/heads/main/resources/showcase.png)
25
+
26
+ ## Inference Requirements and Model Introduction
27
+
28
+ + Resolution: Width and height must be between `512px` and `2048px`, divisible by `32`, and ensure the maximum number of
29
+ pixels does not exceed `2^21` px.
30
+ + Precision: BF16 / FP32 (FP16 is not supported as it will cause overflow resulting in completely black images)
31
+
32
+ Using `BF16` precision with `batchsize=4` for testing, the memory usage is shown in the table below:
33
+
34
+ | Resolution | enable_model_cpu_offload OFF | enable_model_cpu_offload ON | enable_model_cpu_offload ON </br> Text Encoder 4bit |
35
+ |-------------|------------------------------|-----------------------------|-----------------------------------------------------|
36
+ | 512 * 512 | 33GB | 20GB | 13G |
37
+ | 1280 * 720 | 35GB | 20GB | 13G |
38
+ | 1024 * 1024 | 35GB | 20GB | 13G |
39
+ | 1920 * 1280 | 39GB | 20GB | 14G |
40
+
41
+ ## Quick Start
42
+
43
+ First, ensure you install the `diffusers` library from source.
44
+
45
+ ```shell
46
+ pip install git+https://github.com/huggingface/diffusers.git
47
+ cd diffusers
48
+ pip install -e .
49
+ ```
50
+
51
+ Then, run the following code:
52
+
53
+ ```python
54
+ from diffusers import CogView4Pipeline
55
+ import torch
56
+
57
+ pipe = CogView4Pipeline.from_pretrained("THUDM/CogView4-6B", torch_dtype=torch.bfloat16)
58
+
59
+ # Open it for reduce GPU memory usage
60
+ pipe.enable_model_cpu_offload()
61
+ pipe.vae.enable_slicing()
62
+ pipe.vae.enable_tiling()
63
+
64
+ 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."
65
+ image = pipe(
66
+ prompt=prompt,
67
+ guidance_scale=3.5,
68
+ num_images_per_prompt=1,
69
+ num_inference_steps=50,
70
+ width=1024,
71
+ height=1024,
72
+ ).images[0]
73
+
74
+ image.save("cogview4.png")
75
+ ```
76
+
77
+ ### Model Metrics
78
+
79
+ We've tested on multiple benchmarks and achieved the following scores:
80
+
81
+ #### DPG-Bench
82
+
83
+ | Model | Overall | Global | Entity | Attribute | Relation | Other |
84
+ |-----------------|-----------|-----------|-----------|-----------|-----------|-----------|
85
+ | SDXL | 74.65 | 83.27 | 82.43 | 80.91 | 86.76 | 80.41 |
86
+ | PixArt-alpha | 71.11 | 74.97 | 79.32 | 78.60 | 82.57 | 76.96 |
87
+ | SD3-Medium | 84.08 | 87.90 | **91.01** | 88.83 | 80.70 | 88.68 |
88
+ | DALL-E 3 | 83.50 | **90.97** | 89.61 | 88.39 | 90.58 | 89.83 |
89
+ | Flux.1-dev | 83.79 | 85.80 | 86.79 | 89.98 | 90.04 | **89.90** |
90
+ | Janus-Pro-7B | 84.19 | 86.90 | 88.90 | 89.40 | 89.32 | 89.48 |
91
+ | **CogView4-6B** | **85.13** | 83.85 | 90.35 | **91.17** | **91.14** | 87.29 |
92
+
93
+ #### GenEval
94
+
95
+ | Model | Overall | Single Obj. | Two Obj. | Counting | Colors | Position | Color attribution |
96
+ |-----------------|----------|-------------|----------|----------|----------|----------|-------------------|
97
+ | SDXL | 0.55 | 0.98 | 0.74 | 0.39 | 0.85 | 0.15 | 0.23 |
98
+ | PixArt-alpha | 0.48 | 0.98 | 0.50 | 0.44 | 0.80 | 0.08 | 0.07 |
99
+ | SD3-Medium | 0.74 | **0.99** | **0.94** | 0.72 | 0.89 | 0.33 | 0.60 |
100
+ | DALL-E 3 | 0.67 | 0.96 | 0.87 | 0.47 | 0.83 | 0.43 | 0.45 |
101
+ | Flux.1-dev | 0.66 | 0.98 | 0.79 | **0.73** | 0.77 | 0.22 | 0.45 |
102
+ | Janus-Pro-7B | **0.80** | **0.99** | 0.89 | 0.59 | **0.90** | **0.79** | **0.66** |
103
+ | **CogView4-6B** | 0.73 | **0.99** | 0.86 | 0.66 | 0.79 | 0.48 | 0.58 |
104
+
105
+ #### T2I-CompBench
106
+
107
+ | Model | Color | Shape | Texture | 2D-Spatial | 3D-Spatial | Numeracy | Non-spatial Clip | Complex 3-in-1 |
108
+ |-----------------|------------|------------|------------|------------|------------|------------|------------------|----------------|
109
+ | SDXL | 0.5879 | 0.4687 | 0.5299 | 0.2133 | 0.3566 | 0.4988 | 0.3119 | 0.3237 |
110
+ | PixArt-alpha | 0.6690 | 0.4927 | 0.6477 | 0.2064 | 0.3901 | 0.5058 | **0.3197** | 0.3433 |
111
+ | SD3-Medium | **0.8132** | 0.5885 | **0.7334** | **0.3200** | **0.4084** | 0.6174 | 0.3140 | 0.3771 |
112
+ | DALL-E 3 | 0.7785 | **0.6205** | 0.7036 | 0.2865 | 0.3744 | 0.5880 | 0.3003 | 0.3773 |
113
+ | Flux.1-dev | 0.7572 | 0.5066 | 0.6300 | 0.2700 | 0.3992 | 0.6165 | 0.3065 | 0.3628 |
114
+ | Janus-Pro-7B | 0.5145 | 0.3323 | 0.4069 | 0.1566 | 0.2753 | 0.4406 | 0.3137 | 0.3806 |
115
+ | **CogView4-6B** | 0.7786 | 0.5880 | 0.6983 | 0.3075 | 0.3708 | **0.6626** | 0.3056 | **0.3869** |
116
+
117
+ ## Chinese Text Accuracy Evaluation
118
+
119
+ | Model | Precision | Recall | F1 Score | Pick@4 |
120
+ |-----------------|------------|------------|------------|------------|
121
+ | Kolors | 0.6094 | 0.1886 | 0.2880 | 0.1633 |
122
+ | **CogView4-6B** | **0.6969** | **0.5532** | **0.6168** | **0.3265** |
123
+
124
+ ## Citation
125
+
126
+ 🌟 If you find our work helpful, please consider citing our paper and leaving valuable stars
127
+
128
+ ```
129
+ @article{zheng2024cogview3,
130
+ title={Cogview3: Finer and faster text-to-image generation via relay diffusion},
131
+ 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},
132
+ journal={arXiv preprint arXiv:2403.05121},
133
+ year={2024}
134
+ }
135
+ ```
136
+
137
+ ## License
138
+
139
+ This model is released under the [Apache 2.0 License](LICENSE).