🚀 stable-diffusion-v3-5-large-GGUF
stable-diffusion-v3-5-large-GGUF 是一个文本到图像的生成模型,基于 Stable Diffusion 3.5 large 进行 GGUF 量化,可将文本描述转化为图像,在图像质量、排版、复杂提示理解和资源效率方面表现出色。
🚀 快速开始
此模型实验性地由 gpustack/llama-box v0.0.75+ 支持。
✨ 主要特性
- 多模态扩散变压器架构:采用 MMDiT 架构,使用三个固定的预训练文本编码器,结合 QK 归一化技术,提升训练稳定性。
- 多种量化选项:提供 FP16、Q8_0、Q4_1、Q4_0 等多种量化方式,满足不同场景需求。
- 广泛的应用场景:可用于艺术创作、教育、创意工具以及生成模型研究等领域。
📦 安装指南
升级到最新版本的 diffusers 库
pip install -U diffusers
安装 bitsandbytes 以进行模型量化
pip install bitsandbytes
💻 使用示例
基础用法
import torch
from diffusers import StableDiffusion3Pipeline
pipe = StableDiffusion3Pipeline.from_pretrained("stabilityai/stable-diffusion-3.5-large", torch_dtype=torch.bfloat16)
pipe = pipe.to("cuda")
image = pipe(
"A capybara holding a sign that reads Hello World",
num_inference_steps=28,
guidance_scale=3.5,
).images[0]
image.save("capybara.png")
高级用法
from diffusers import BitsAndBytesConfig, SD3Transformer2DModel
from diffusers import StableDiffusion3Pipeline
import torch
model_id = "stabilityai/stable-diffusion-3.5-large"
nf4_config = BitsAndBytesConfig(
load_in_4bit=True,
bnb_4bit_quant_type="nf4",
bnb_4bit_compute_dtype=torch.bfloat16
)
model_nf4 = SD3Transformer2DModel.from_pretrained(
model_id,
subfolder="transformer",
quantization_config=nf4_config,
torch_dtype=torch.bfloat16
)
pipeline = StableDiffusion3Pipeline.from_pretrained(
model_id,
transformer=model_nf4,
torch_dtype=torch.bfloat16
)
pipeline.enable_model_cpu_offload()
prompt = "A whimsical and creative image depicting a hybrid creature that is a mix of a waffle and a hippopotamus, basking in a river of melted butter amidst a breakfast-themed landscape. It features the distinctive, bulky body shape of a hippo. However, instead of the usual grey skin, the creature's body resembles a golden-brown, crispy waffle fresh off the griddle. The skin is textured with the familiar grid pattern of a waffle, each square filled with a glistening sheen of syrup. The environment combines the natural habitat of a hippo with elements of a breakfast table setting, a river of warm, melted butter, with oversized utensils or plates peeking out from the lush, pancake-like foliage in the background, a towering pepper mill standing in for a tree. As the sun rises in this fantastical world, it casts a warm, buttery glow over the scene. The creature, content in its butter river, lets out a yawn. Nearby, a flock of birds take flight"
image = pipeline(
prompt=prompt,
num_inference_steps=28,
guidance_scale=4.5,
max_sequence_length=512,
).images[0]
image.save("whimsical.png")
📚 详细文档
模型描述
属性 |
详情 |
模型开发者 |
Stability AI |
模型类型 |
MMDiT 文本到图像生成模型 |
模型说明 |
该模型基于文本提示生成图像,是一个 多模态扩散变压器,使用三个固定的预训练文本编码器,并采用 QK 归一化来提高训练稳定性。 |
许可证
- 社区许可证:适用于研究、非商业用途,以及年总收入低于 100 万美元的组织或个人。更多详情请参阅 社区许可协议。请访问 https://stability.ai/license 了解更多信息。
- 企业许可证:年总收入超过 100 万美元的个人或组织,请 联系我们 获取企业许可证。
模型来源
文件结构
点击此处访问 文件和版本标签
│
├── text_encoders/
│ ├── README.md
│ ├── clip_g.safetensors
│ ├── clip_l.safetensors
│ ├── t5xxl_fp16.safetensors
│ └── t5xxl_fp8_e4m3fn.safetensors
│
├── README.md
├── LICENSE
├── sd3_large.safetensors
├── SD3.5L_example_workflow.json
└── sd3_large_demo.png
** 以下文件结构用于 diffusers 集成 **
├── scheduler/
├── text_encoder/
├── text_encoder_2/
├── text_encoder_3/
├── tokenizer/
├── tokenizer_2/
├── tokenizer_3/
├── transformer/
├── vae/
└── model_index.json
微调
请参阅 微调指南。
预期用途
- 生成艺术作品,并用于设计和其他艺术创作过程。
- 应用于教育或创意工具。
- 进行生成模型研究,包括了解生成模型的局限性。
所有对模型的使用都必须符合我们的 可接受使用政策。
非预期用途
该模型并非用于生成事实性或真实反映人物或事件的内容。因此,使用该模型生成此类内容超出了其能力范围。
安全
我们采取了一系列措施来确保模型的安全性和可靠性。在模型开发的各个阶段都实施了安全措施,以降低潜在风险。然而,我们建议开发者根据具体用例进行自己的测试,并采取额外的缓解措施。
完整性评估
我们的完整性评估方法包括结构化评估和针对特定危害的红队测试。测试主要以英语进行,可能无法涵盖所有可能的危害。
已识别的风险和缓解措施
- 有害内容:我们在训练模型时使用了过滤后的数据集,并实施了保障措施,试图在实用性和防止危害之间取得平衡。但这并不能保证所有可能的有害内容都已被去除。所有开发者和部署者应谨慎行事,并根据其特定的产品政策和应用用例实施内容安全护栏。
- 滥用:技术限制以及对开发者和最终用户的教育可以帮助减轻模型的恶意应用。所有用户都必须遵守我们的 可接受使用政策,包括在应用微调提示工程机制时。请参考 Stability AI 可接受使用政策,了解我们产品的违规使用信息。
- 隐私侵犯:鼓励开发者和部署者采用尊重数据隐私的技术,遵守隐私法规。
联系我们
请报告模型的任何问题或联系我们:
- 安全问题:safety@stability.ai
- 安全漏洞:security@stability.ai
- 隐私问题:privacy@stability.ai
- 许可证和一般问题:https://stability.ai/license
- 企业许可证:https://stability.ai/enterprise
🔧 技术细节
实现细节
- QK 归一化:实现了 QK 归一化技术,以提高训练稳定性。
- 文本编码器:
- 训练数据和策略:该模型在多种数据上进行训练,包括合成数据和经过筛选的公开可用数据。
有关原始 MMDiT 架构的更多技术细节,请参阅 研究论文。
模型性能
请参阅 博客,了解我们关于该模型在提示遵循度和美学质量方面的比较性能研究。
📄 许可证
本模型采用 Stability Community License 许可协议。请访问 Stability AI 了解更多信息,或 联系我们 获取商业许可详情。