license: creativeml-openrail-m
base_model: "stabilityai/stable-diffusion-xl-base-1.0"
tags:
- sdxl
- sdxl-diffusers
- 文生图
- 图生图
- diffusers
- simpletuner
- 非全年龄向
- lora
- template:sd-lora
- lycoris
pipeline_tag: text-to-image
inference: true
widget:
- text: '无条件(空白提示)'
parameters:
negative_prompt: '模糊,裁剪,丑陋'
output:
url: ./assets/image_0_0.png
- text: '一张逼真的猫照片'
parameters:
negative_prompt: '模糊,裁剪,丑陋'
output:
url: ./assets/image_1_0.png
simpletuner-sdxl-lora-test
这是基于stabilityai/stable-diffusion-xl-base-1.0衍生的LyCORIS适配器。
训练期间使用的主要验证提示词为:
一张逼真的猫照片
验证设置
- CFG:
4.2
- CFG重缩放:
0.0
- 步数:
20
- 采样器:
ddim
- 种子:
42
- 分辨率:
1024x1024
注:验证设置不一定与训练设置相同。
您可以在以下画廊查看示例图片:
文本编码器未参与训练。
推理时可复用基础模型的文本编码器。
训练设置
- 训练轮次:1
- 训练步数:390
- 学习率:3e-07
- 最大梯度值:2.0
- 有效批次大小:3
- 梯度检查点:启用
- 预测类型:epsilon(额外参数=['training_scheduler_timestep_spacing=trailing', 'inference_scheduler_timestep_spacing=trailing'])
- 优化器:bnb-lion8bit
- 可训练参数精度:纯BF16
- 基础模型精度:
保持原样
- 标题丢弃概率:0.1%
LyCORIS配置:
{
"bypass_mode": true,
"algo": "lokr",
"multiplier": 1.0,
"linear_dim": 10000,
"linear_alpha": 1,
"factor": 12,
"apply_preset": {
"target_module": [
"Attention",
"FeedForward"
],
"module_algo_map": {
"Attention": {
"factor": 12
},
"FeedForward": {
"factor": 6
}
}
}
}
数据集
signs-discovery
- 重复次数:0
- 总图像数:约423
- 宽高比分桶数:5
- 分辨率:1.048576百万像素
- 是否裁剪:否
- 裁剪风格:无
- 裁剪比例:无
- 是否用于正则化数据:否
signs-discovery-512
- 重复次数:0
- 总图像数:约420
- 宽高比分桶数:4
- 分辨率:0.262144百万像素
- 是否裁剪:否
- 裁剪风格:无
- 裁剪比例:无
- 是否用于正则化数据:否
推理
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-xl-base-1.0'
adapter_repo_id = 'bghira/simpletuner-sdxl-lora-test'
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.unet)
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.2,
guidance_rescale=0.0,
).images[0]
model_output.save("output.png", format="PNG")