🚀 simpletuner-lora
このモデルは、stabilityai/stable-diffusion-3.5-large をベースにしたLyCORISアダプターです。
学習中に使用された主な検証プロンプトは以下の通りです。
A photo-realistic image of a cat
✨ 主な機能
このアダプターは、テキストから画像を生成するタスクに特化しており、特定の設定で高品質な画像生成が可能です。また、学習設定や検証設定が明確に記載されており、再現性が高いです。
📦 インストール
インストールに関する具体的な手順は記載されていません。
💻 使用例
基本的な使用法
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-large'
adapter_repo_id = 'ShanZard/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 = "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=3.0,
).images[0]
model_output.save("output.png", format="PNG")
高度な使用法
高度な使用法に関する具体的なコードは記載されていません。
📚 ドキュメント
検証設定
- CFG:
3.0
- CFG Rescale:
0.0
- Steps:
20
- Sampler:
FlowMatchEulerDiscreteScheduler
- Seed:
42
- Resolution:
1024x1024
- Skip-layer guidance:
注意: 検証設定は 学習設定 と必ずしも同じではありません。
以下のギャラリーにいくつかのサンプル画像を見ることができます。
テキストエンコーダーは学習されていません。推論にはベースモデルのテキストエンコーダーを再利用できます。
学習設定
- 学習エポック数: 1
- 学習ステップ数: 10000
- 学習率: 0.0001
- 学習率スケジュール: polynomial
- ウォームアップステップ数: 100
- 最大勾配値: 2.0
- 有効バッチサイズ: 2
- マイクロバッチサイズ: 1
- 勾配累積ステップ数: 1
- GPU数: 2
- 勾配チェックポイント: True
- 予測タイプ: flow-matching (追加パラメータ=['shift=3'])
- オプティマイザー: adamw_bf16
- 学習可能パラメータ精度: Pure BF16
- ベースモデル精度:
no_change
- キャプションドロップアウト確率: 10.0%
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 megapixels
- クロップ: True
- クロップスタイル: center
- クロップアスペクト: square
- 正則化データとして使用: No
🔧 技術詳細
このアダプターは、LyCORIS技術を用いてベースモデルから派生しています。学習設定や検証設定が明確に記載されており、特定の設定での画像生成が可能です。また、テキストエンコーダーは学習されておらず、ベースモデルのテキストエンコーダーを再利用できます。
📄 ライセンス
ライセンスは other です。