Skip to content

Commit 41627ee

Browse files
docs: add README_ja.md (#26) (#28)
I cerated Japanese translated README. Co-authored-by: Ikko Eltociear Ashimine <[email protected]>
1 parent 8f01c5d commit 41627ee

File tree

3 files changed

+184
-0
lines changed

3 files changed

+184
-0
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# CogView4 & CogView3 & CogView-3Plus
22

33
[阅读中文版](./README_zh.md)
4+
[日本語で読む](./README_ja.md)
45

56
<div align="center">
67
<img src=resources/logo.svg width="50%"/>

README_ja.md

Lines changed: 182 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,182 @@
1+
# CogView4 & CogView3 & CogView-3Plus
2+
3+
[Read this in English](./README.md)
4+
[阅读中文版](./README_zh.md)
5+
6+
<div align="center">
7+
<img src=resources/logo.svg width="50%"/>
8+
</div>
9+
<p align="center">
10+
<a href="https://huggingface.co/spaces/THUDM-HF-SPACE/CogView3-Plus-3B-Space" target="_blank"> 🤗 HuggingFace Space</a> <a href="https://modelscope.cn/studios/ZhipuAI/CogView4" target="_blank"> 🤖ModelScope Space</a> <a href="resources/WECHAT.md" target="_blank"> 👋 WeChat Community</a> <a href="https://arxiv.org/abs/2403.05121" target="_blank">📚 CogView3 Paper</a>
11+
</p>
12+
13+
14+
![showcase.png](resources/showcase.png)
15+
16+
## プロジェクトの更新
17+
18+
- 🔥🔥 ```2025/03/04```: [diffusers](https://github.com/huggingface/diffusers) バージョンの **CogView-4** モデルを適応し、オープンソース化しました。このモデルは6Bのパラメータを持ち、ネイティブの中国語入力と中国語のテキストから画像生成をサポートしています。オンラインで試すことができます [こちら](https://huggingface.co/spaces/THUDM-HF-SPACE/CogView4)
19+
- ```2024/10/13```: [diffusers](https://github.com/huggingface/diffusers) バージョンの **CogView-3Plus-3B** モデルを適応し、オープンソース化しました。オンラインで試すことができます [こちら](https://huggingface.co/spaces/THUDM-HF-SPACE/CogView3-Plus-3B-Space)
20+
- ```2024/9/29```: **CogView3****CogView-3Plus-3B** をオープンソース化しました。**CogView3** はカスケード拡散に基づくテキストから画像生成システムで、リレーディフュージョンフレームワークを使用しています。**CogView-3Plus** は新たに開発されたDiffusion Transformerに基づくテキストから画像生成モデルのシリーズです。
21+
22+
## プロジェクト計画
23+
24+
- [X] diffusers ワークフローの適応
25+
- [ ] ComfyUI diffusers ノード
26+
- [ ] 微調整スクリプトとエコシステムキット
27+
- [ ] ControlNet モデルのリリース
28+
- [ ] Cogシリーズの微調整キット
29+
30+
## モデル紹介
31+
32+
### モデル比較
33+
34+
<table style="border-collapse: collapse; width: 100%;">
35+
<tr>
36+
<th style="text-align: center;">モデル名</th>
37+
<th style="text-align: center;">CogView4</th>
38+
<th style="text-align: center;">CogView3-Plus-3B</th>
39+
</tr>
40+
<td style="text-align: center;">解像度</td>
41+
<td colspan="2" style="text-align: center;">
42+
512 <= H, W <= 2048 <br>
43+
H * W <= 2^{21} <br>
44+
H, W \mod 32 = 0
45+
</td>
46+
<tr>
47+
<td style="text-align: center;">推論精度</td>
48+
<td colspan="2" style="text-align: center;">BF16, FP32 のみサポート</td>
49+
<tr>
50+
<td style="text-align: center;">エンコーダ</td>
51+
<td style="text-align: center;"><a href="https://huggingface.co/THUDM/glm-4-9b-hf" target="_blank">GLM-4-9B</a></td>
52+
<td style="text-align: center;"><a href="https://huggingface.co/google/t5-v1_1-xxl" target="_blank">T5-XXL</a></td>
53+
</tr>
54+
<tr>
55+
<td style="text-align: center;">プロンプト言語</td>
56+
<td style="text-align: center;">中国語、英語</td>
57+
<td style="text-align: center;">英語</td>
58+
</tr>
59+
<tr>
60+
<td style="text-align: center;">プロンプト長さの制限</td>
61+
<td style="text-align: center;">1024 トークン</td>
62+
<td style="text-align: center;">224 トークン</td>
63+
</tr>
64+
<tr>
65+
<td style="text-align: center;">ダウンロードリンク</td>
66+
<td style="text-align: center;"><a href="https://huggingface.co/THUDM/CogView4-6B">🤗 HuggingFace</a><br><a href="https://modelscope.cn/models/ZhipuAI/CogView4-6B">🤖 ModelScope</a><br><a href="https://wisemodel.cn/models/ZhipuAI/CogView4-6B">🟣 WiseModel</a></td>
67+
<td style="text-align: center;"><a href="https://huggingface.co/THUDM/CogView3-Plus-3B">🤗 HuggingFace</a><br><a href="https://modelscope.cn/models/ZhipuAI/CogView3-Plus-3B">🤖 ModelScope</a><br><a href="https://wisemodel.cn/models/ZhipuAI/CogView3-Plus-3B">🟣 WiseModel</a></td>
68+
</tr>
69+
</table>
70+
71+
### メモリ使用量
72+
73+
DITモデルは `BF16` 精度と `batchsize=4` でテストされ、結果は以下の表に示されています:
74+
75+
| 解像度 | enable_model_cpu_offload OFF | enable_model_cpu_offload ON | enable_model_cpu_offload ON </br> Text Encoder 4bit |
76+
|-------------|------------------------------|-----------------------------|-----------------------------------------------------|
77+
| 512 * 512 | 33GB | 20GB | 13G |
78+
| 1280 * 720 | 35GB | 20GB | 13G |
79+
| 1024 * 1024 | 35GB | 20GB | 13G |
80+
| 1920 * 1280 | 39GB | 20GB | 14G |
81+
| 2048 * 2048 | 43GB | 21GB | 14G |
82+
83+
さらに、プロセスが強制終了されないようにするために、少なくとも`32GB`のRAMを持つデバイスを推奨します。
84+
85+
### モデル指標
86+
87+
複数のベンチマークでテストを行い、以下のスコアを達成しました:
88+
89+
#### DPG-Bench
90+
91+
| モデル | 全体 | グローバル | エンティティ | 属性 | 関係 | その他 |
92+
|--------------|-----------|-----------|-----------|-----------|-----------|-----------|
93+
| SDXL | 74.65 | 83.27 | 82.43 | 80.91 | 86.76 | 80.41 |
94+
| PixArt-alpha | 71.11 | 74.97 | 79.32 | 78.60 | 82.57 | 76.96 |
95+
| SD3-Medium | 84.08 | 87.90 | **91.01** | 88.83 | 80.70 | 88.68 |
96+
| DALL-E 3 | 83.50 | **90.97** | 89.61 | 88.39 | 90.58 | 89.83 |
97+
| Flux.1-dev | 83.79 | 85.80 | 86.79 | 89.98 | 90.04 | **89.90** |
98+
| Janus-Pro-7B | 84.19 | 86.90 | 88.90 | 89.40 | 89.32 | 89.48 |
99+
| **CogView4-6B** | **85.13** | 83.85 | 90.35 | **91.17** | **91.14** | 87.29 |
100+
101+
#### GenEval
102+
103+
| モデル | 全体 | 単一オブジェクト | 二つのオブジェクト | カウント || 位置 | 色の属性 |
104+
|-----------------|----------|-------------|----------|----------|----------|----------|-------------------|
105+
| SDXL | 0.55 | 0.98 | 0.74 | 0.39 | 0.85 | 0.15 | 0.23 |
106+
| PixArt-alpha | 0.48 | 0.98 | 0.50 | 0.44 | 0.80 | 0.08 | 0.07 |
107+
| SD3-Medium | 0.74 | **0.99** | **0.94** | 0.72 | 0.89 | 0.33 | 0.60 |
108+
| DALL-E 3 | 0.67 | 0.96 | 0.87 | 0.47 | 0.83 | 0.43 | 0.45 |
109+
| Flux.1-dev | 0.66 | 0.98 | 0.79 | **0.73** | 0.77 | 0.22 | 0.45 |
110+
| Janus-Pro-7B | **0.80** | **0.99** | 0.89 | 0.59 | **0.90** | **0.79** | **0.66** |
111+
| **CogView4-6B** | 0.73 | **0.99** | 0.86 | 0.66 | 0.79 | 0.48 | 0.58 |
112+
113+
#### T2I-CompBench
114+
115+
| モデル ||| テクスチャ | 2D-空間 | 3D-空間 | 数量 | 非空間 Clip | 複雑な3-in-1 |
116+
|-----------------|------------|------------|------------|------------|------------|------------|------------------|----------------|
117+
| SDXL | 0.5879 | 0.4687 | 0.5299 | 0.2133 | 0.3566 | 0.4988 | 0.3119 | 0.3237 |
118+
| PixArt-alpha | 0.6690 | 0.4927 | 0.6477 | 0.2064 | 0.3901 | 0.5058 | **0.3197** | 0.3433 |
119+
| SD3-Medium | **0.8132** | 0.5885 | **0.7334** | **0.3200** | **0.4084** | 0.6174 | 0.3140 | 0.3771 |
120+
| DALL-E 3 | 0.7785 | **0.6205** | 0.7036 | 0.2865 | 0.3744 | 0.5880 | 0.3003 | 0.3773 |
121+
| Flux.1-dev | 0.7572 | 0.5066 | 0.6300 | 0.2700 | 0.3992 | 0.6165 | 0.3065 | 0.3628 |
122+
| Janus-Pro-7B | 0.5145 | 0.3323 | 0.4069 | 0.1566 | 0.2753 | 0.4406 | 0.3137 | 0.3806 |
123+
| **CogView4-6B** | 0.7786 | 0.5880 | 0.6983 | 0.3075 | 0.3708 | **0.6626** | 0.3056 | **0.3869** |
124+
125+
## 中国語テキストの正確性評価
126+
127+
| モデル | 精度 | リコール | F1スコア | pick@4 |
128+
|-----------------|------------|------------|------------|------------|
129+
| Kolors | 0.6094 | 0.1886 | 0.2880 | 0.1633 |
130+
| **CogView4-6B** | **0.6969** | **0.5532** | **0.6168** | **0.3265** |
131+
132+
## 推論モデル
133+
134+
### プロンプトの最適化
135+
136+
CogView4シリーズのモデルは長文の合成画像説明でトレーニングされていますが、テキストから画像生成を行う前に大規模言語モデルを使用してプロンプトをリライトすることを強くお勧めします。これにより生成品質が大幅に向上します。
137+
138+
[例のスクリプト](inference/prompt_optimize.py)を提供しています。このスクリプトを実行してプロンプトをリファインすることをお勧めします。`CogView4``CogView3` モデルのプロンプト最適化には異なるfew-shotが使用されていることに注意してください。区別が必要です。
139+
140+
```shell
141+
cd inference
142+
python prompt_optimize.py --api_key "Zhipu AI API Key" --prompt {your prompt} --base_url "https://open.bigmodel.cn/api/paas/v4" --model "glm-4-plus" --cogview_version "cogview4"
143+
```
144+
145+
### 推論モデル
146+
147+
`BF16` 精度でモデルを実行します:
148+
149+
```python
150+
from diffusers import CogView4Pipeline
151+
import torch
152+
153+
pipe = CogView4Pipeline.from_pretrained("THUDM/CogView4-6B", torch_dtype=torch.bfloat16).to("cuda")
154+
155+
# GPUメモリ使用量を減らすために開く
156+
pipe.enable_model_cpu_offload()
157+
pipe.vae.enable_slicing()
158+
pipe.vae.enable_tiling()
159+
160+
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."
161+
image = pipe(
162+
prompt=prompt,
163+
guidance_scale=3.5,
164+
num_images_per_prompt=1,
165+
num_inference_steps=50,
166+
width=1024,
167+
height=1024,
168+
).images[0]
169+
170+
image.save("cogview4.png")
171+
```
172+
173+
その他の推論コードについては、以下を確認してください:
174+
175+
1. `int4` を使用して `text encoder` をロードし、完全な注釈付き推論コードを確認するには [こちら](inference/cli_demo_cogview4.py)
176+
2. `gradio` GUI DEMO をセットアップするには [こちら](inference/gradio_web_demo.py)
177+
178+
## ライセンス
179+
180+
このリポジトリのコードとCogView3モデルは [Apache 2.0](./LICENSE) のライセンスの下で提供されています。
181+
182+
コードの貢献を歓迎し、感謝します。貢献ガイドラインは [こちら](resources/contribute.md) で確認できます。

README_zh.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# CogView4 & CogView3 & CogView-3Plus
22

33
[Read this in English](./README.md)
4+
[日本語で読む](./README_ja.md)
45

56
<div align="center">
67
<img src=resources/logo.svg width="50%"/>

0 commit comments

Comments
 (0)