项目简介
可图大模型是由快手可图团队开发的基于潜在扩散的大规模文本到图像生成模型。Kolors 在数十亿图文对下进行训练,在视觉质量、复杂语义理解、文字生成(中英文字符)等方面,相比于开源/闭源模型,都展示出了巨大的优势。同时,Kolors 支持中英双语,在中文特色内容理解方面更具竞争力。更多的实验结果和细节请查看我们的技术报告。
📊 评测表现
为了全面比较 Kolors 与其他模型的生成能力,我们构建了包含人工评估、机器评估的全面评测内容。在相关基准评测中,Kolors 具有非常有竞争力的表现,达到业界领先水平。我们构建了一个包含14种垂类,12个挑战项,总数量为一千多个 prompt 的文生图评估集 KolorsPrompts。在 KolorsPrompts 上,我们收集了 Kolors 与市面上常见的 SOTA 级别的开源/闭源系统的文生图结果,并进行了人工评测和机器评测。
人工评测
我们邀请了50个具有图像领域知识的专业评估人员对不同模型的生成结果进行对比评估,为生成图像打分,衡量维度为:画面质量、图文相关性、整体满意度三个方面。Kolors 在整体满意度方面处于最优水平,其中画面质量显著领先其他模型。
模型 | 整体满意度平均分 | 画面质量平均分 | 图文相关性平均分 |
---|---|---|---|
Adobe-Firefly | 3.03 | 3.46 | 3.84 |
Stable Diffusion 3 | 3.26 | 3.50 | 4.20 |
DALL-E 3 | 3.32 | 3.54 | 4.22 |
Midjourney-v5 | 3.32 | 3.68 | 4.02 |
Playground-v2.5 | 3.37 | 3.73 | 4.04 |
Midjourney-v6 | 3.58 | 3.92 | 4.18 |
Kolors | 3.59 | 3.99 | 4.17 |
所有模型结果取自 2024.04 的产品版本
机器评测
我们采用 MPS (Multi-dimensional Human preference Score) 来评估上述模型。我们以 KolorsPrompts 作为基础评估数据集,计算多个模型的 MPS 指标。Kolors 实现了最高的MPS 指标,这与人工评估的指标一致。
模型 | MPS综合得分 |
---|---|
Adobe-Firefly | 8.5 |
Stable Diffusion 3 | 8.9 |
DALL-E 3 | 9.0 |
Midjourney-v5 | 9.4 |
Playground-v2.5 | 9.8 |
Midjourney-v6 | 10.2 |
Kolors | 10.3 |
更多的实验结果和细节请查看我们的技术报告。点击技术报告。
🎥 可视化
-
高质量人像
-
中国元素
-
文字绘制
上述可视化 case,可以点击可视化prompts 获取
🛠️ 快速使用
要求
-
python 3.8及以上版本
-
pytorch 1.13.1及以上版本
-
transformers 4.26.1及以上版本
-
建议使用CUDA 11.7及以上
1、仓库克隆及依赖安装
apt-get install git-lfsgit clone https://github.com/Kwai-Kolors/Kolorscd Kolorsconda create --name kolors python=3.8conda activate kolorspip install -r requirements.txtpython3 setup.py install
2、模型权重下载
huggingface-cli download --resume-download Kwai-Kolors/Kolors --local-dir weights/Kolors
或者
git lfs clone https://huggingface.co/Kwai-Kolors/Kolors weights/Kolors
3、模型推理:
python3 scripts/sample.py "一张瓢虫的照片,微距,变焦,高质量,电影,拿着一个牌子,写着“可图”"# The image will be saved to "scripts/outputs/sample_text.jpg"
4、 Web demo:
python3 scripts/sampleui.py
在 Diffusers 中使用
确保您安装了最新版本的 diffusers
(0.30.0.dev0):
git clone https://github.com/huggingface/diffuserscd diffuserspython3 setup.py install
注意:
-
KolorsPipeline 默认使用
EulerDiscreteScheduler
作为噪声调度器。我们推荐使用该调度器时搭配guidance scale=5.0
及num_inference_steps=50
。 -
KolorsPipeline 同时支持
EDMDPMSolverMultistepScheduler
。在使用该噪声调度器时,推荐使用参数guidance scale=5.0
及num_inference_steps=25
。 -
除了文生图能力,
KolorsImg2ImgPipeline
同时也支持图文生图功能。
运行以下指令进行图像生成:
import torchfrom diffusers import KolorsPipelinepipe = KolorsPipeline.from_pretrained( torch_dtype=torch.float16, variant="fp16").to("cuda")prompt = '一张瓢虫的照片,微距,变焦,高质量,电影,拿着一个牌子,写着"可图"'image = pipe( prompt=prompt, negative_prompt="", guidance_scale=5.0, num_inference_steps=50, generator=torch.Generator(pipe.device).manual_seed(66),).images[0]image.show()
IP-Adapter-Plus
我们提供了 IP-Adapter-Plus 的参数和代码, 详细信息见 ipadapter.
# Weights downloadhuggingface-cli download --resume-download Kwai-Kolors/Kolors-IP-Adapter-Plus --local-dir weights/Kolors-IP-Adapter-Plus
# Inference:python3 ipadapter/sample_ipadapter_plus.py ./ipadapter/asset/test_ip.jpg "穿着黑色T恤衫,上面中文绿色大字写着“可图”"
python3 ipadapter/sample_ipadapter_plus.py ./ipadapter/asset/test_ip2.png "一只可爱的小狗在奔跑"
# The image will be saved to "scripts/outputs/"
ControlNet
我们提供了三个类型的ControlNet参数和代码,详细信息见controlnet。
# Weights download
# Canny - ControlNethuggingface-cli download --resume-download Kwai-Kolors/Kolors-ControlNet-Canny --local-dir weights/Kolors-ControlNet-Canny
# Depth - ControlNethuggingface-cli download --resume-download Kwai-Kolors/Kolors-ControlNet-Depth --local-dir weights/Kolors-ControlNet-Depth
# Pose - ControlNethuggingface-cli download --resume-download Kwai-Kolors/Kolors-ControlNet-Pose --local-dir weights/Kolors-ControlNet-Pose
Inpainting
我们提供了 Inpainting 的参数和代码, 详细信息见 inpainting.
# Weights downloadhuggingface-cli download --resume-download Kwai-Kolors/Kolors-Inpainting --local-dir weights/Kolors-Inpainting
# Inference:python3 inpainting/sample_inpainting.py ./inpainting/asset/3.png ./inpainting/asset/3_mask.png 穿着美少女战士的衣服,一件类似于水手服风格的衣服,包括一个白色紧身上衣,前胸搭配一个大大的红色蝴蝶结。衣服的领子部分呈蓝色,并且有白色条纹。她还穿着一条蓝色百褶裙,超高清,辛烷渲染,高级质感,32k,高分辨率,最好的质量,超级细节,景深
python3 inpainting/sample_inpainting.py ./inpainting/asset/4.png ./inpainting/asset/4_mask.png 穿着钢铁侠的衣服,高科技盔甲,主要颜色为红色和金色,并且有一些银色装饰。胸前有一个亮起的圆形反应堆装置,充满了未来科技感。超清晰,高质量,超逼真,高分辨率,最好的质量,超级细节,景深
# The image will be saved to "scripts/outputs/"
IP-Adapter-FaceID-Plus
我们提供了 IP-Adapter-FaceID-Plus 的参数和代码, 详细信息见 ipadapter_FaceID.
# Weights downloadhuggingface-cli download --resume-download Kwai-Kolors/Kolors-IP-Adapter-FaceID-Plus --local-dir weights/Kolors-IP-Adapter-FaceID-Plus
# Inference:python ipadapter_FaceID/sample_ipadapter_faceid_plus.py ./ipadapter_FaceID/assets/image1.png "穿着晚礼服,在星光下的晚宴场景中,烛光闪闪,整个场景洋溢着浪漫而奢华的氛围"
python ipadapter_FaceID/sample_ipadapter_faceid_plus.py ./ipadapter_FaceID/assets/image2.png "西部牛仔,牛仔帽,荒野大镖客,背景是西部小镇,仙人掌,,日落余晖, 暖色调, 使用XT4胶片拍摄, 噪点, 晕影, 柯达胶卷,复古"
# The image will be saved to "scripts/outputs/"
Dreambooth-LoRA
我们提供了Dreambooth-LoRA 的训练和推理代码,详细信息见 Dreambooth-LoRA.
# Training:sh train.sh
# Inference:python infer_dreambooth.py "ktxl狗在草地上跑"
项目链接
https://github.com/Kwai-Kolors/Kolors/blob/master/README_CN.md