🚀 stylloha
stylloha是一個基於black-forest-labs/FLUX.1-dev的LyCORIS適配器。它可用於文本到圖像、圖像到圖像的轉換,為圖像生成任務提供了新的解決方案。
🚀 快速開始
本項目是一個基於特定基礎模型的LyCORIS適配器,可用於圖像生成。以下是使用該適配器進行推理的基本步驟。
✨ 主要特性
📚 詳細文檔
驗證設置
- CFG:
3.0
- CFG Rescale:
0.0
- 步數:
20
- 採樣器:
FlowMatchEulerDiscreteScheduler
- 種子:
42
- 分辨率:
1024x1024
- 跳過層引導:
注意:驗證設置不一定與訓練設置相同。
你可以在以下圖庫中找到一些示例圖像:
文本編碼器未進行訓練。你可以重用基礎模型的文本編碼器進行推理。
訓練設置
- 訓練輪數:3
- 訓練步數:6000
- 學習率:0.0001
- 最大梯度值:2.0
- 有效批量大小:3
- 梯度檢查點:True
- 預測類型:flow_matching (額外參數=['shift=3', 'flux_guidance_mode=constant', 'flux_guidance_value=1.0'])
- 優化器:adamw_bf16
- 可訓練參數精度:Pure BF16
- 基礎模型精度:
no_change
- 字幕丟棄概率:0.05%
LyCORIS配置
{
"algo": "loha",
"multiplier": 1.0,
"linear_dim": 32,
"linear_alpha": 16,
"apply_preset": {
"target_module": [
"Attention",
"FeedForward"
],
"module_algo_map": {
"Attention": {
"factor": 16
},
"FeedForward": {
"factor": 8
}
}
}
}
數據集
數據集名稱 |
重複次數 |
圖像總數 |
縱橫比桶總數 |
分辨率 |
裁剪 |
裁剪樣式 |
裁剪縱橫比 |
是否用於正則化數據 |
styl-256 |
10 |
43 |
2 |
0.065536 兆像素 |
否 |
無 |
無 |
否 |
styl-crop-256 |
10 |
43 |
1 |
0.065536 兆像素 |
是 |
居中 |
方形 |
否 |
styl-512 |
10 |
43 |
2 |
0.262144 兆像素 |
否 |
無 |
無 |
否 |
styl-crop-512 |
10 |
43 |
1 |
0.262144 兆像素 |
是 |
居中 |
方形 |
否 |
styl-768 |
10 |
43 |
2 |
0.589824 兆像素 |
否 |
無 |
無 |
否 |
styl-crop-768 |
10 |
43 |
1 |
0.589824 兆像素 |
是 |
居中 |
方形 |
否 |
styl-1024 |
10 |
16 |
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 = 'black-forest-labs/FLUX.1-dev'
adapter_repo_id = 'quzo/stylloha'
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 = "A photo-realistic image of a cat"
pipeline.to('cuda' if torch.cuda.is_available() else 'mps' if torch.backends.mps.is_available() else 'cpu')
model_output = pipeline(
prompt=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=3.0,
).images[0]
model_output.save("output.png", format="PNG")
高級用法
📄 許可證
許可證類型:other