🚀 cute-doodles-lokr-hidream
このプロジェクトは、HiDream-ai/HiDream-I1-Full をベースとしたLyCORISアダプターです。このアダプターを使用することで、特定のスタイルの画像生成が可能になります。
🚀 クイックスタート
このアダプターを使用するには、以下の手順に従ってください。
モデルのダウンロード
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 = 'HiDream-ai/HiDream-I1-Full'
adapter_repo_id = 'markury/cute-doodles-lokr-hidream'
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 cute doodle of an orange tabby cat, with a grey mouse in its mouth."
negative_prompt = 'blurry, cropped, ugly'
from optimum.quanto import quantize, freeze, qint8
quantize(pipeline.transformer, weights=qint8)
freeze(pipeline.transformer)
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=50,
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=5.0,
).images[0]
model_output.save("output.png", format="PNG")
✨ 主な機能
- 特定スタイルの画像生成:このアダプターを使用することで、可愛いドゥードルスタイルの画像を生成できます。
- ベースモデルの再利用:テキストエンコーダーはベースモデルを再利用することができ、推論時の負荷を軽減します。
📚 ドキュメント
検証設定
- CFG:
5.0
- CFG Rescale:
0.0
- Steps:
50
- Sampler:
FlowMatchEulerDiscreteScheduler
- Seed:
42
- Resolutions:
1024,1024
注意: 検証設定は学習設定と必ずしも同じではありません。
学習設定
- 学習エポック数: 0
- 学習ステップ数: 600
- 学習率: 0.0001
- 学習率スケジュール: 一定
- ウォームアップステップ: 100
- 最大勾配値: 0.01
- 有効バッチサイズ: 2
- マイクロバッチサイズ: 2
- 勾配累積ステップ: 1
- GPU数: 1
- 勾配チェックポイント: True
- 予測タイプ: flow_matching (追加パラメータ=['shift=3'])
- オプティマイザー: optimi-lion
- 学習可能パラメータ精度: Pure BF16
- ベースモデル精度:
int8-quanto
- キャプションドロップアウト確率: 0.0%
LyCORIS設定
{
"algo": "lokr",
"multiplier": 1.0,
"linear_dim": 10000,
"linear_alpha": 1,
"factor": 16,
"apply_preset": {
"target_module": [
"Attention",
"FeedForward"
],
"module_algo_map": {
"Attention": {
"factor": 16
},
"FeedForward": {
"factor": 16
}
}
}
}
データセット
ドゥードル
- 繰り返し数: 7
- 画像総数: 183
- アスペクトバケット総数: 1
- 解像度: 1.048576メガピクセル
- クロップ: True
- クロップスタイル: ランダム
- クロップアスペクト: 正方形
- 正則化データとして使用: No
📄 ライセンス
このプロジェクトは、Otherライセンスの下で提供されています。