🚀 simpletuner-sdxl-lora-test
這是一個基於 stabilityai/stable-diffusion-xl-base-1.0 的 LyCORIS 適配器。該適配器可用於文本到圖像的生成任務,通過特定的訓練和設置,能生成高質量的圖像。
🚀 快速開始
本項目是一個基於 stabilityai/stable-diffusion-xl-base-1.0 的 LyCORIS 適配器。下面為你介紹其基本信息和使用方法。
✨ 主要特性
- 基於穩定擴散模型
stabilityai/stable-diffusion-xl-base-1.0
構建。
- 可用於文本到圖像、圖像到圖像的轉換任務。
- 提供了詳細的訓練和驗證設置。
📚 詳細文檔
驗證設置
- CFG:
4.2
- CFG 重縮放:
0.0
- 步數:
20
- 採樣器:
ddim
- 種子:
42
- 分辨率:
1024x1024
注意:驗證設置不一定與訓練設置相同。
你可以在以下圖庫中找到一些示例圖像:
文本編碼器未進行訓練。你可以在推理時複用基礎模型的文本編碼器。
訓練設置
- 訓練輪數:1
- 訓練步數:390
- 學習率:3e - 07
- 最大梯度值:2.0
- 有效批量大小:3
- 微批量大小:1
- 梯度累積步數:1
- GPU 數量:3
- 梯度檢查點:啟用
- 預測類型:epsilon(額外參數=['training_scheduler_timestep_spacing=trailing', 'inference_scheduler_timestep_spacing=trailing'])
- 優化器:bnb - lion8bit
- 可訓練參數精度:純 BF16
- 基礎模型精度:
no_change
- 字幕丟棄概率: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 = "A photo-realistic image of a cat"
negative_prompt = 'blurry, cropped, ugly'
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")
📄 許可證
本項目採用 creativeml-openrail-m
許可證。
屬性 |
詳情 |
模型類型 |
基於 LyCORIS 的 SDXL LoRA 適配器 |
基礎模型 |
stabilityai/stable-diffusion-xl-base-1.0 |
訓練數據 |
signs-discovery 和 signs-discovery-512 數據集 |