🚀 Anything V3.1
Anything V3.1是一个基于潜在扩散模型的第三方延续版本,它在Anything V3.0的基础上进行了优化。该模型通过修复VAE模型和CLIP位置ID键,被认为是Anything V3.0的改进版本。它能够根据文本提示生成和修改动漫主题的图像。
🚀 快速开始
你可以选择使用Automatic1111's Stable Diffusion Webui
或者🧨 diffusers
来使用这个模型。具体使用方法如下:
✨ 主要特性
- 优化升级:基于Anything V3.0,修复了VAE模型和CLIP位置ID键,CLIP参考自Stable Diffusion V1.5。
- 多源数据训练:在从多个来源收集的数据集上进行微调,其中1/4为合成数据集。
- 支持Danbooru标签:和其他动漫风格的Stable Diffusion模型一样,支持使用Danbooru标签来生成图像。
📦 安装指南
使用🧨 diffusers
运行模型
你需要安装以下依赖才能运行模型:
pip install diffusers transformers accelerate scipy safetensors
💻 使用示例
基础用法
运行以下代码来生成图像(如果不更换调度器,将使用默认的DDIM,此示例中我们将其更换为DPMSolverMultistepScheduler):
import torch
from torch import autocast
from diffusers import StableDiffusionPipeline, DPMSolverMultistepScheduler
model_id = "cag/anything-v3-1"
pipe = StableDiffusionPipeline.from_pretrained(model_id, torch_dtype=torch.float16)
pipe.scheduler = DPMSolverMultistepScheduler.from_config(pipe.scheduler.config)
pipe = pipe.to("cuda")
prompt = "masterpiece, best quality, high quality, 1girl, solo, sitting, confident expression, long blonde hair, blue eyes, formal dress"
negative_prompt = "lowres, bad anatomy, bad hands, text, error, missing fingers, extra digit, fewer digits, cropped, worst quality, low quality, normal quality, jpeg artifacts, signature, watermark, username, blurry"
with autocast("cuda"):
image = pipe(prompt,
negative_prompt=negative_prompt,
width=512,
height=728,
guidance_scale=12,
num_inference_steps=50).images[0]
image.save("anime_girl.png")
📚 详细文档
#how-to-use
- 下载
Anything V3.1
点击此处,或者下载Anything V3.2
点击此处,所有模型均为.safetensors
格式。
- 你需要使用美学标签调整提示词以获得更好的结果,你可以使用任何通用的负面提示词,或者使用以下建议的负面提示词来引导模型生成高美学的图像:
lowres, bad anatomy, bad hands, text, error, missing fingers, extra digit, fewer digits, cropped, worst quality, low quality, normal quality, jpeg artifacts, signature, watermark, username, blurry
- 并且,为了获得高美学的结果,以下内容也应添加到提示词前:
masterpiece, best quality, illustration, beautiful detailed, finely detailed, dramatic light, intricate details
🧨Diffusers
此模型的使用方法与其他Stable Diffusion模型相同。更多信息请参考Stable Diffusion。你还可以将模型导出为ONNX、MPS和/或FLAX/JAX。预训练模型目前基于Anything V3.1。
🔧 技术细节
- CLIP和VAE处理:CLIP参考自Stable Diffusion V1.5,VAE使用Kohya的merge - vae脚本进行替换,CLIP使用Arena的stable - diffusion - model - toolkit webui扩展进行修复。
- 微调参数:当前模型在从多个来源收集的数据集上进行微调,学习率为2.0e - 6,训练50个周期,批量大小为4。
- 数据集预处理:使用Aspect Ratio Bucketing Tool对数据集进行预处理,以便可以将其转换为潜在变量并在非正方形分辨率下进行训练。
📄 许可证
该模型采用CreativeML OpenRAIL - M许可证,此许可证规定:
- 你不能使用该模型故意生成或分享非法或有害的输出或内容。
- 作者对您生成的输出不主张任何权利,你可以自由使用它们,但需对其使用负责,且使用不得违反许可证中的规定。
- 你可以重新分发模型权重,并将模型用于商业用途或作为服务使用。如果你这样做,请确保包含与许可证中相同的使用限制,并向所有用户分享一份CreativeML OpenRAIL - M许可证副本。
请在此处阅读完整许可证
局限性
- 过拟合问题:即使修复了文本编码器,该模型仍然存在过拟合问题,不能很好地遵循提示词,导致在输入提示词时比较受限,只有输入“1girl”时才能获得较好的结果。
- 性别偏向:该模型基于动漫风格,偏向于生成动漫女性角色,在不提供特定提示词的情况下,很难生成具有阳刚之气的男性角色。
- 改进有限:与Anything V3.0基础模型相比,变化不大,仅涉及更换VAE和CLIP模型,然后在小规模数据集上微调50个周期。
示例
以下是一些精心挑选的样本以及可用模型之间的比较:

鸣谢
此项目属于公共领域。
模型信息表格