"test/training_service/config/multi_thread/search_space.json" did not exist on "d6e49c5f422652bbe345f33941f6be4e3f88951d"
README.md 5.43 KB
Newer Older
mashun1's avatar
kolors  
mashun1 committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
# Kolors

## 论文

**Kolors: Effective Training of Diffusion Model for Photorealistic Text-to-Image Synthesis**

* https://github.com/Kwai-Kolors/Kolors/blob/master/imgs/Kolors_paper.pdf 

## 模型结构

模型基于`SDXL`,并使用`ChatGLM-6B-Base`作为`text-encoder`

![alt text](readme_imgs/arch.png)

## 算法原理

算法通过使用双语模型作为`text-encoder`,通过对训练`图像-文本`数据精心标注,并采用两阶段训练策略,遵循DDMP训练目标。

![alt text](readme_imgs/alg.png)

## 环境配置

### Docker(方法一)
    
    docker pull image.sourcefind.cn:5000/dcu/admin/base/pytorch:2.1.0-ubuntu20.04-dtk24.04.1-py3.10

    docker run --shm-size 50g --network=host --name=kolors --privileged --device=/dev/kfd --device=/dev/dri --group-add video --cap-add=SYS_PTRACE --security-opt seccomp=unconfined -v 项目地址(绝对路径):/home/ -v /opt/hyhal:/opt/hyhal:ro -it <your IMAGE ID> bash

    pip install -r requirements.txt

    python setup.py install


### Dockerfile(方法二)

    docker build -t <IMAGE_NAME>:<TAG> .

    docker run --shm-size 50g --network=host --name=kolors --privileged --device=/dev/kfd --device=/dev/dri --group-add video --cap-add=SYS_PTRACE --security-opt seccomp=unconfined -v 项目地址(绝对路径):/home/ -v /opt/hyhal:/opt/hyhal:ro -it <your IMAGE ID> bash

    pip install -r requirements.txt

    python setup.py install


### Anaconda (方法三)

1、关于本项目DCU显卡所需的特殊深度学习库可从光合开发者社区下载安装:
https://developer.hpccube.com/tool/

    DTK驱动:dtk24.04.1
    python:python3.10
    torch: 2.1.0
    torchvision: 0.16.0
    deepspeed: 0.12.3
    xformers: 0.0.25
    trition: 2.1.0

Tips:以上dtk驱动、python、torch等DCU相关工具版本需要严格一一对应

2、其它非特殊库参照requirements.txt安装

    pip install -r requirements.txt

    pip install accelerate==0.31.0

    python setup.py install

## 数据集



## 训练



## 推理

    python scripts/sample.py <prompt>

    # webui
    python scripts/sampleui.py

## result

|||||
|:---:|:---|:---:|:---:|
|prompt|一只熊猫坐在湖边看夕阳,湖边有一片竹林|Oriental Pearl Tower, Cyberpunk style.|一张瓢虫的照片,微距,变焦,高质量,电影,拿着一个牌子,写着“可图”|
|output|![alt text](readme_imgs/r1.png)|![alt text](readme_imgs/r2.png)|![alt text](readme_imgs/r3.png)|

### 精度



## 应用场景

### 算法类别

`AIGC`

### 热点应用行业

`零售,广媒,教育`

## 预训练权重

[huggingface](https://huggingface.co/Kwai-Kolors/Kolors/tree/main) | [Modelscope](https://modelscope.cn/models/Kwai-Kolors/Kolors/files) | [SCNet](http://113.200.138.88:18080/aimodels/Kolors) 高速通道

建议使用SCNet,使用以下命令下载

    mkdir weights && cd weights

    git clone http://113.200.138.88:18080/aimodels/Kolors

    git lfs install

    git lfs pull

权重文件结构
    
    weights
    └── Kolors
        ├── imgs
        │   └── head_final3.png
        ├── model_index.json
        ├── MODEL_LICENSE
        ├── README.md
        ├── scheduler
        │   └── scheduler_config.json
        ├── text_encoder
        │   ├── config.json
        │   ├── configuration_chatglm.py
        │   ├── modeling_chatglm.py
        │   ├── __pycache__
        │   │   ├── configuration_chatglm.cpython-311.pyc
        │   │   ├── configuration_chatglm.cpython-37.pyc
        │   │   ├── configuration_chatglm.cpython-38.pyc
        │   │   ├── configuration_chatglm.cpython-39.pyc
        │   │   ├── modeling_chatglm.cpython-38.pyc
        │   │   ├── modeling_chatglm.cpython-39.pyc
        │   │   ├── tokenization_chatglm.cpython-38.pyc
        │   │   └── tokenization_chatglm.cpython-39.pyc
        │   ├── pytorch_model-00001-of-00007.bin
        │   ├── pytorch_model-00002-of-00007.bin
        │   ├── pytorch_model-00003-of-00007.bin
        │   ├── pytorch_model-00004-of-00007.bin
        │   ├── pytorch_model-00005-of-00007.bin
        │   ├── pytorch_model-00006-of-00007.bin
        │   ├── pytorch_model-00007-of-00007.bin
        │   ├── pytorch_model.bin.index.json
        │   ├── quantization.py
        │   ├── tokenization_chatglm.py
        │   ├── tokenizer_config.json
        │   ├── tokenizer.model
        │   └── vocab.txt
        ├── tokenizer
        │   ├── tokenization_chatglm.py
        │   ├── tokenizer_config.json
        │   ├── tokenizer.model
        │   └── vocab.txt
        ├── unet
        │   ├── config.json
        │   ├── diffusion_pytorch_model.fp16.safetensors
        │   └── diffusion_pytorch_model.safetensors
        └── vae
            ├── config.json
            ├── diffusion_pytorch_model.bin
            ├── diffusion_pytorch_model.fp16.bin
            ├── diffusion_pytorch_model.fp16.safetensors
            └── diffusion_pytorch_model.safetensors

## 源码仓库及问题反馈

* https://developer.hpccube.com/codes/modelzoo/kolors_pytorch

## 参考资料

* https://github.com/Kwai-Kolors/Kolorss