🚀 太乙稳定扩散模型 1B 中文 v0.1
太乙稳定扩散模型 1B 中文 v0.1 是首个开源的中英双语 Stable Diffusion 模型,基于 0.2 亿筛选过的中文图文对训练,能够根据文本描述生成高质量的图像,为多模态应用提供了强大支持。
🚀 快速开始
全精度
from diffusers import StableDiffusionPipeline
pipe = StableDiffusionPipeline.from_pretrained("IDEA-CCNL/Taiyi-Stable-Diffusion-1B-Chinese-v0.1").to("cuda")
prompt = '飞流直下三千尺,油画'
image = pipe(prompt, guidance_scale=7.5).images[0]
image.save("飞流.png")
半精度 Half precision FP16 (CUDA)
添加 torch_dtype=torch.float16
和 device_map="auto"
可以快速加载 FP16 的权重,以加快推理速度。更多信息见 the optimization docs。
import torch
from diffusers import StableDiffusionPipeline
torch.backends.cudnn.benchmark = True
pipe = StableDiffusionPipeline.from_pretrained("IDEA-CCNL/Taiyi-Stable-Diffusion-1B-Chinese-v0.1", torch_dtype=torch.float16)
pipe.to('cuda')
prompt = '飞流直下三千尺,油画'
image = pipe(prompt, guidance_scale=7.5).images[0]
image.save("飞流.png")
✨ 主要特性
- 首个开源的中英双语 Stable Diffusion 模型,支持中文文本输入生成图像。
- 基于筛选过的 0.2 亿中文图文对训练,对中文概念有更好的理解和生成能力。
- 提供全精度和半精度两种推理方式,可根据需求选择以平衡速度和精度。
📦 安装指南
文档中未提及具体安装步骤,可参考使用示例中的代码,确保安装所需依赖库,如 diffusers
、torch
等。
💻 使用示例
基础用法
from diffusers import StableDiffusionPipeline
pipe = StableDiffusionPipeline.from_pretrained("IDEA-CCNL/Taiyi-Stable-Diffusion-1B-Chinese-v0.1").to("cuda")
prompt = '飞流直下三千尺,油画'
image = pipe(prompt, guidance_scale=7.5).images[0]
image.save("飞流.png")
高级用法
在半精度推理时,可添加 torch_dtype=torch.float16
和 device_map="auto"
加快推理速度。
import torch
from diffusers import StableDiffusionPipeline
torch.backends.cudnn.benchmark = True
pipe = StableDiffusionPipeline.from_pretrained("IDEA-CCNL/Taiyi-Stable-Diffusion-1B-Chinese-v0.1", torch_dtype=torch.float16)
pipe.to('cuda')
prompt = '飞流直下三千尺,油画'
image = pipe(prompt, guidance_scale=7.5).images[0]
image.save("飞流.png")
📚 详细文档
🔧 技术细节
我们将Noah-Wukong数据集(100M)和Zero数据集(23M)用作预训练的数据集,先用IDEA-CCNL/Taiyi-CLIP-RoBERTa-102M-ViT-L-Chinese对这两个数据集的图文对相似性进行打分,取 CLIP Score 大于 0.2 的图文对作为我们的训练集。 我们使用IDEA-CCNL/Taiyi-CLIP-RoBERTa-102M-ViT-L-Chinese作为初始化的 text encoder,冻住stable-diffusion-v1-4(论文)模型的其他部分,只训练 text encoder,以便保留原始模型的生成能力且实现中文概念的对齐。该模型目前在 0.2 亿图文对上训练了一个 epoch。 我们在 32 x A100 训练了大约 100 小时。该版本只是一个初步的版本,我们将持续优化并开源后续模型,欢迎交流。
📄 许可证
本模型采用 CreativeML OpenRAIL-M 许可证。在获取此模型前,需了解以下信息:
- 不能使用该模型故意生成或分享非法或有害的输出或内容。
- IDEA-CCNL 对生成的输出不主张任何权利,用户可自由使用,但需对其使用负责,且不得违反许可证中的规定。
- 可以重新分发模型权重,并将模型用于商业用途或作为服务。若这样做,需包含与许可证相同的使用限制,并向所有用户分享 CreativeML OpenRAIL-M 许可证副本。
请阅读完整许可证:https://huggingface.co/spaces/CompVis/stable-diffusion-license
点击“访问仓库”,即表示同意您的联系信息(电子邮件地址和用户名)可与模型作者共享。
📋 模型分类
属性 |
详情 |
需求 |
特殊 |
任务 |
多模态 |
系列 |
太乙 |
模型 |
Stable Diffusion |
参数 |
1B |
额外 |
Chinese |
📷 模型生成结果示例
基础提示
提示文本 |
生成图像 |
铁马冰河入梦来,3D 绘画。 |
 |
飞流直下三千尺,油画。 |
 |
女孩背影,日落,唯美插画。 |
 |
高级提示
提示文本 |
生成图像 |
铁马冰河入梦来,概念画,科幻,玄幻,3D |
 |
中国海边城市,科幻,未来感,唯美,插画。 |
 |
那人却在灯火阑珊处,色彩艳丽,古风,资深插画师作品,桌面高清壁纸。 |
 |
🔗 相关链接
📖 引用
如果您在工作中使用了我们的模型,可以引用我们的总论文:
@article{fengshenbang,
author = {Jiaxing Zhang and Ruyi Gan and Junjie Wang and Yuxiang Zhang and Lin Zhang and Ping Yang and Xinyu Gao and Ziwei Wu and Xiaoqun Dong and Junqing He and Jianheng Zhuo and Qi Yang and Yongfeng Huang and Xiayu Li and Yanghan Wu and Junyu Lu and Xinyu Zhu and Weifeng Chen and Ting Han and Kunhao Pan and Rui Wang and Hao Wang and Xiaojun Wu and Zhongshen Zeng and Chongpei Chen},
title = {Fengshenbang 1.0: Being the Foundation of Chinese Cognitive Intelligence},
journal = {CoRR},
volume = {abs/2209.02970},
year = {2022}
}
也可以引用我们的网站:
@misc{Fengshenbang-LM,
title={Fengshenbang-LM},
author={IDEA-CCNL},
year={2021},
howpublished={\url{https://github.com/IDEA-CCNL/Fengshenbang-LM}},
}