🚀 mani - flux - dress
このプロジェクトは、[black - forest - labs/FLUX.1 - dev](https://huggingface.co/black - forest - labs/FLUX.1 - dev) から派生したLyCORISアダプターです。主にテキストから画像を生成するタスクに特化しており、高品質な画像生成を実現します。
🚀 クイックスタート
この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 = 'black-forest-labs/FLUX.1-dev'
adapter_repo_id = 'PixelWormhole/mani-flux-dress'
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 film still of a high fashion photoshoot featuring the _8FSL39XP1_ Dress, an elegant off-the-shoulder design in delicate white lace with floral motifs. The dress is form-fitting, mini-length, with long sleeves that flare slightly at the cuffs. The scene is set in a luxurious, modern Mediterranean architectural space with a sea view. A beautiful, young, natural-looking European woman with long hair is captured in a dynamic mid-motion pose, either mid-step or gently turning. She stands against a backdrop of clean white stone and curated designer furniture in neutral tones, with the calm, open sea visible in the distance. Her expression is serene and self-assured, her posture poised and refined. Natural daylight enhances the soft textures and casts gentle shadows across the scene. The color palette blends creamy whites, stone beiges, and hints of ocean blue."
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=28,
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")
高度な使用法
from optimum.quanto import quantize, freeze, qint8
quantize(pipeline.transformer, weights=qint8)
freeze(pipeline.transformer)
model_output = pipeline(
prompt=prompt,
num_inference_steps=28,
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_quantized.png", format="PNG")
📚 詳細ドキュメント
検証設定
- CFG:
3.0
- CFG Rescale:
0.0
- ステップ数:
28
- サンプラー:
FlowMatchEulerDiscreteScheduler
- シード値:
42
- 解像度:
1024x1024
- スキップレイヤーガイダンス:
注意: 検証設定はトレーニング設定と必ずしも同じではありません。
トレーニング設定
- トレーニングエポック数: 99
- トレーニングステップ数: 4000
- 学習率: 1e - 05
- 学習率スケジュール: 多項式
- ウォームアップステップ数: 100
- 最大勾配値: 2.0
- 有効バッチサイズ: 1
- マイクロバッチサイズ: 1
- 勾配累積ステップ数: 1
- GPU数: 1
- 勾配チェックポイント: True
- 予測タイプ: flow_matching (追加パラメータ=['shift=3', 'flux_guidance_mode=constant', 'flux_guidance_value=1.0'])
- オプティマイザー: adamw_bf16
- 学習可能パラメータの精度: Pure BF16
- ベースモデルの精度:
no_change
- キャプションドロップアウト確率: 5.0%
LyCORIS設定:
{
"algo": "lora",
"multiplier": 1.0,
"linear_dim": 64,
"linear_alpha": 32,
"apply_preset": {
"target_module": [
"Attention",
"FeedForward"
],
"module_algo_map": {
"Attention": {
"factor": 16
},
"FeedForward": {
"factor": 8
}
}
}
}
データセット
hidream - test - dataset - 256
- 繰り返し数: 0
- 画像総数: 5
- アスペクトバケット総数: 2
- 解像度: 0.065536メガピクセル
- クロップ: False
- クロップスタイル: None
- クロップアスペクト: None
- 正則化データとして使用: No
hidream - test - dataset - crop - 256
- 繰り返し数: 0
- 画像総数: 5
- アスペクトバケット総数: 1
- 解像度: 0.065536メガピクセル
- クロップ: True
- クロップスタイル: center
- クロップアスペクト: square
- 正則化データとして使用: No
hidream - test - dataset - 512
- 繰り返し数: 0
- 画像総数: 5
- アスペクトバケット総数: 3
- 解像度: 0.262144メガピクセル
- クロップ: False
- クロップスタイル: None
- クロップアスペクト: None
- 正則化データとして使用: No
hidream - test - dataset - crop - 512
- 繰り返し数: 0
- 画像総数: 5
- アスペクトバケット総数: 1
- 解像度: 0.262144メガピクセル
- クロップ: True
- クロップスタイル: center
- クロップアスペクト: square
- 正則化データとして使用: No
hidream - test - dataset - 768
- 繰り返し数: 0
- 画像総数: 5
- アスペクトバケット総数: 1
- 解像度: 0.589824メガピクセル
- クロップ: False
- クロップスタイル: None
- クロップアスペクト: None
- 正則化データとして使用: No
hidream - test - dataset - crop - 768
- 繰り返し数: 0
- 画像総数: 5
- アスペクトバケット総数: 1
- 解像度: 0.589824メガピクセル
- クロップ: True
- クロップスタイル: center
- クロップアスペクト: square
- 正則化データとして使用: No
hidream - test - dataset - 1024
- 繰り返し数: 0
- 画像総数: 5
- アスペクトバケット総数: 3
- 解像度: 1.048576メガピクセル
- クロップ: False
- クロップスタイル: None
- クロップアスペクト: None
- 正則化データとして使用: No
hidream - test - dataset - crop - 1024
- 繰り返し数: 0
- 画像総数: 5
- アスペクトバケット総数: 1
- 解像度: 1.048576メガピクセル
- クロップ: True
- クロップスタイル: center
- クロップアスペクト: square
- 正則化データとして使用: No
🔧 技術詳細
このアダプターはLyCORISアルゴリズムを使用しており、特定のモジュールに対して適用されます。トレーニングには多様な設定が用いられており、これにより高品質な画像生成が可能になっています。
📄 ライセンス
このプロジェクトは、otherライセンスの下で公開されています。