许可协议: 其他
基础模型: "stabilityai/stable-diffusion-3.5-medium"
标签:
- sd3
- sd3-diffusers
- 文本生成图像
- 图像生成图像
- diffusers
- simpletuner
- 非全年龄段适用
- lora
- 模板:sd-lora
- lycoris
管道标签: 文本生成图像
推理: 是
小部件示例:
- 文本: '无条件(空白提示)'
参数:
负面提示: '模糊、裁剪、丑陋'
输出:
链接: ./assets/image_0_0.png
- 文本: '盘子上的狗'
参数:
负面提示: '模糊、裁剪、丑陋'
输出:
链接: ./assets/image_1_0.png
- 文本: '沙发上的猫'
参数:
负面提示: '模糊、裁剪、丑陋'
输出:
链接: ./assets/image_2_0.png
- 文本: '一张猫的照片级真实感图像'
参数:
负面提示: '模糊、裁剪、丑陋'
输出:
链接: ./assets/image_3_0.png
simpletuner-lora
这是一个基于stabilityai/stable-diffusion-3.5-medium的LyCORIS适配器。
训练期间使用的主要验证提示为:
一张猫的照片级真实感图像
验证设置
- CFG:
4.0
- CFG重缩放:
0.0
- 步数:
20
- 采样器:
FlowMatchEulerDiscreteScheduler
- 种子:
42
- 分辨率:
1024x1024
- 跳过层引导:
skip_guidance_layers=[7, 8, 9],
注意:验证设置不一定与训练设置相同。
您可以在以下图库中找到一些示例图像:
文本编码器未训练。
您可以复用基础模型的文本编码器进行推理。
训练设置
- 训练周期: 6
- 训练步数: 3000
- 学习率: 0.0001
- 最大梯度值: 2.0
- 有效批次大小: 32
- 微批次大小: 32
- 梯度累积步数: 1
- GPU数量: 1
- 梯度检查点: 是
- 预测类型: flow_matching (额外参数=['flow_schedule_auto_shift', 'shift=0.0', 'flow_use_uniform_schedule'])
- 优化器: adamw_bf16
- 可训练参数精度: 纯BF16
- 基础模型精度:
不变
- 标题丢弃概率: 0.1%
LyCORIS配置:
{
"algo": "lokr",
"multiplier": 1.0,
"full_matrix": true,
"linear_alpha": 1,
"factor": 16,
"apply_preset": {
"target_module": [
"Attention",
"FeedForward"
],
"module_algo_map": {
"Attention": {
"factor": 16
},
"FeedForward": {
"factor": 8
}
}
}
}
数据集
pseudo-camera-10k-sd3
- 重复次数: 0
- 总图像数: 14102
- 总比例桶数: 1
- 分辨率: 1.048576百万像素
- 裁剪: 是
- 裁剪风格: 居中
- 裁剪比例: 正方形
- 用于正则化数据: 否
推理
import torch
from diffusers import DiffusionPipeline
from lycoris import create_lycoris_from_weights
def download_adapter(repo_id: str):
import os
from huggingface_hub import hf_hub_download
adapter_filename = "pytorch_lora_weights.safetensors"
cache_dir = os.environ.get('HF_PATH', os.path.expanduser('~/.cache/huggingface/hub/models'))
cleaned_adapter_path = repo_id.replace("/", "_").replace("\\", "_").replace(":", "_")
path_to_adapter = os.path.join(cache_dir, cleaned_adapter_path)
path_to_adapter_file = os.path.join(path_to_adapter, adapter_filename)
os.makedirs(path_to_adapter, exist_ok=True)
hf_hub_download(
repo_id=repo_id, filename=adapter_filename, local_dir=path_to_adapter
)
return path_to_adapter_file
model_id = 'stabilityai/stable-diffusion-3.5-medium'
adapter_repo_id = 'hmwhwm/simpletuner-lora'
adapter_filename = 'pytorch_lora_weights.safetensors'
adapter_file_path = download_adapter(repo_id=adapter_repo_id)
pipeline = DiffusionPipeline.from_pretrained(model_id, torch_dtype=torch.bfloat16)
lora_scale = 1.0
wrapper, _ = create_lycoris_from_weights(lora_scale, adapter_file_path, pipeline.transformer)
wrapper.merge_to()
prompt = "一张猫的照片级真实感图像"
negative_prompt = '模糊、裁剪、丑陋'
pipeline.to('cuda' if torch.cuda.is_available() else 'mps' if torch.backends.mps.is_available() else 'cpu')
model_output = pipeline(
prompt=prompt,
negative_prompt=negative_prompt,
num_inference_steps=20,
generator=torch.Generator(device='cuda' if torch.cuda.is_available() else 'mps' if torch.backends.mps.is_available() else 'cpu').manual_seed(42),
width=1024,
height=1024,
guidance_scale=4.0,
skip_guidance_layers=[7, 8, 9],
).images[0]
model_output.save("output.png", format="PNG")