绘梦有形,快手开源「可图 Kolors」,等你来玩
01 引言
最近,快手开源了一个叫Kolors(可图)的文本到图像生成模型,这玩意儿有点意思——它对英语和汉语的理解能力很强,生成的图像质量也高,逼真度在线。技术报告里提了几个关键点,咱们掰开揉碎说说:

首先,Kolors用的不是常见的T5大语言模型(像Imagen和Stable Diffusion 3那样),而是基于通用语言模型ChatGLM——这招挺妙,直接让它在中英文理解上更拿手。同时,团队用多模态大模型CogVLM重新给训练数据里的图像生成了更详细的描述,相当于把数据质量再提了一档。
其次,训练分两个阶段:概念学习和质量改进。每个阶段都用专门的数据集来优化,核心目标就是让画面更好看。通过引入高质量数据和高分辨率训练技术,图像质量的提升是肉眼可见的。
最后,Kolors团队还搞了个平衡类别的基准数据集KolorsPrompts,专门用来指导和评估模型训练。
从最终的评测数据来看,即便用的是U-Net backbone,Kolors的表现也相当亮眼,在人类评价中直接超越了现有的开源模型,性能看齐了Midjourney v6。关键是,代码和权重已经开源,可以直接上手玩。
代码开源链接:https://github.com/Kwai-Kolors/Kolors
模型开源链接:https://modelscope.cn/models/Kwai-Kolors/Kolors
技术报告链接:https://github.com/Kwai-Kolors/Kolors/blob/master/imgs/Kolors_paper.pdf
02 下载和体验可图
模型卡片直达:
下载方式:
sdk下载:
# 模型下载
from modelscope import snapshot_download
model_dir = snapshot_download('Kwai-Kolors/Kolors')
git下载:
git clone https://www.modelscope.cn/Kwai-Kolors/Kolors.git
CLI下载:
modelscope download --model=Kwai-Kolors/Kolors --local_dir ./Kolors/
03 最佳实践
参考开源项目:https://github.com/kijai/ComfyUI-KwaiKolorsWrapper,我们在魔搭社区免费GPU算力上完成了Kolors的ComfyUI环境搭建和体验实践,下面是具体流程。
体验环境
使用魔搭社区的Notebook运行Kolors可图模型。
搭建 ComfyUI
从最新的ComfyUI代码安装:
# #@title Environment Setup
from pathlib import Path
OPTIONS = {}
UPDATE_COMFY_UI = True #@param {type:"boolean"}
INSTALL_COMFYUI_MANAGER = True #@param {type:"boolean"}
INSTALL_KOLORS = True #@param {type:"boolean"}
INSTALL_CUSTOM_NODES_DEPENDENCIES = True #@param {type:"boolean"}
OPTIONS['UPDATE_COMFY_UI'] = UPDATE_COMFY_UI
OPTIONS['INSTALL_COMFYUI_MANAGER'] = INSTALL_COMFYUI_MANAGER
OPTIONS['INSTALL_KOLORS'] = INSTALL_KOLORS
OPTIONS['INSTALL_CUSTOM_NODES_DEPENDENCIES'] = INSTALL_CUSTOM_NODES_DEPENDENCIES
current_dir = !pwd
WORKSPACE = f"{current_dir[0]}/ComfyUI"
%cd /mnt/workspace/
![ ! -d $WORKSPACE ] && echo -= Initial setup ComfyUI =- && git clone https://github.com/comfyanonymous/ComfyUI
%cd $WORKSPACE
if OPTIONS['UPDATE_COMFY_UI']:
!echo "-= Updating ComfyUI =-"
!git pull
if OPTIONS['INSTALL_COMFYUI_MANAGER']:
%cd custom_nodes
![ ! -d ComfyUI-Manager ] && echo -= Initial setup ComfyUI-Manager =- && git clone https://github.com/ltdrdata/ComfyUI-Manager
%cd ComfyUI-Manager
!git pull
if OPTIONS['INSTALL_KOLORS']:
%cd ../
![ ! -d ComfyUI-KwaiKolorsWrapper ] && echo -= Initial setup KOLORS =- && git clone https://github.com/kijai/ComfyUI-KwaiKolorsWrapper.git
%cd ComfyUI-KwaiKolorsWrapper
!git pull
%cd $WORKSPACE
if OPTIONS['INSTALL_CUSTOM_NODES_DEPENDENCIES']:
!pwd
!echo "-= Install custom nodes dependencies =-"
![ -f "custom_nodes/ComfyUI-Manager/scripts/colab-dependencies.py" ] && python "custom_nodes/ComfyUI-Manager/scripts/colab-dependencies.py"
下载模型权重:
#@markdown ###Download standard resources
OPTIONS = {}
#@markdown **unet**
!wget -c "https://modelscope.cn/models/Kwai-Kolors/Kolors/resolve/master/unet/diffusion_pytorch_model.fp16.safetensors" -P ./models/diffusers/Kolors/unet/
!wget -c "https://modelscope.cn/models/Kwai-Kolors/Kolors/resolve/master/unet/config.json" -P ./models/diffusers/Kolors/unet/
#@markdown **encoder**
!modelscope download --model=ZhipuAI/chatglm3-6b-base --local_dir ./models/diffusers/Kolors/text_encoder/
#@markdown **vae**
!wget -c "https://modelscope.cn/models/AI-ModelScope/sdxl-vae-fp16-fix/resolve/master/sdxl.vae.safetensors" -P ./models/vae/
#@markdown **scheduler**
!wget -c "https://modelscope.cn/models/Kwai-Kolors/Kolors/resolve/master/scheduler/scheduler_config.json" -P ./models/diffusers/Kolors/scheduler/
#@markdown **modelindex**
!wget -c "https://modelscope.cn/models/Kwai-Kolors/Kolors/resolve/master/model_index.json" -P ./models/diffusers/Kolors/
通过cloudflare启动ComfyUI:
!wget "https://modelscope.oss-cn-beijing.aliyuncs.com/resource/cloudflared-linux-amd64.deb"
!dpkg -i cloudflared-linux-amd64.deb
%cd /mnt/workspace/ComfyUI
import subprocess
import threading
import time
import socket
import urllib.request
def iframe_thread(port):
while True:
time.sleep(0.5)
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
result = sock.connect_ex(('127.0.0.1', port))
if result == 0:
break
sock.close()
print("nComfyUI finished loading, trying to launch cloudflared (if it gets stuck here cloudflared is ha ving issues)n")
p = subprocess.Popen(["cloudflared", "tunnel", "--url", "http://127.0.0.1:{}".format(port)], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
for line in p.stderr:
l = line.decode()
if "trycloudflare.com " in l:
print("This is the URL to access ComfyUI:", l[l.find("http"):], end='')
threading.Thread(target=iframe_thread, daemon=True, args=(8188,)).start()
!python main.py --dont-print-server
点击右侧load,加载ComfyUI-KwaiKolorsWrapper项目提供的workflow。
文生图体验:
图生图体验(一辆白色小汽车):
显存占用:
效果测试
简单 Prompt
一个苹果 |
一辆汽车 |
一只小狗 |
复杂 Prompt
a bear standing on a car, sunset, winter |
a boy and a girl, the boy stands at the left side, the boy wears a red t-shirt and blue pants, the girl wears a green t-shirt and pink pants. |
the apple is in the box, the box is on the chair, the chair is in the room. |
多实体生成能力很能打,颜色能做到分别控制,空间关系也比较完美。
多风格
中国水墨画,女孩,长长的头发,闪亮的大眼睛 |
oil painting, a girl, long hair, colorful hair, shining eyes |
anime, a girl, long hair, colorful hair, shining eyes |
多风格,强!
文本
一只小狗的照片,微距,变焦,高质量,电影,小狗拿着一个牌子,写着“可图魔搭” |
一张瓢虫的照片,微距,变焦,高质量,电影,拿着一个牌子,写着“可图” |
天空,上面写着"可图"的文字 |
可以处理简单的文本。
多样性
一个可爱的女孩 |
一个可爱的女孩 |
一个可爱的女孩 |
多样性还不错。
性能测试
1024分辨率,A10显卡,生成一张图片(25步)耗时7秒。
-
- 关于宇宙的好的网名有哪些
- 角色扮演 | 1
- 网名