đ mani-flux-dress
This is a LyCORIS adapter derived from black-forest-labs/FLUX.1-dev. It is mainly used for text - to - image and image - to - image tasks, offering high - quality image generation capabilities.
đ Quick Start
Prerequisites
- Python environment
- Necessary libraries such as
torch
, diffusers
, lycoris
, huggingface_hub
, etc.
Installation
You need to install relevant libraries according to the requirements of the code. For example:
pip install torch diffusers lycoris huggingface_hub
Inference
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")
⨠Features
- Based on LyCORIS Adapter: Derived from black-forest-labs/FLUX.1-dev, it can generate high - quality images.
- Multiple Image Generation Modes: Support text - to - image and image - to - image generation.
- Customizable Parameters: You can adjust parameters such as
CFG
, Steps
, Sampler
, etc. to get different image generation results.
đĻ Installation
You need to install relevant libraries according to the requirements of the code. For example:
pip install torch diffusers lycoris huggingface_hub
đģ Usage Examples
Basic Usage
Advanced Usage
You can adjust parameters such as lora_scale
, prompt
, num_inference_steps
, etc. to generate different images. For example:
lora_scale = 0.5
wrapper, _ = create_lycoris_from_weights(lora_scale, adapter_file_path, pipeline.transformer)
wrapper.merge_to()
prompt = "A cute kitten in a colorful garden"
model_output = pipeline(
prompt=prompt,
num_inference_steps=30,
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("new_output.png", format="PNG")
đ Documentation
Validation Settings
Property |
Details |
CFG |
3.0 |
CFG Rescale |
0.0 |
Steps |
28 |
Sampler |
FlowMatchEulerDiscreteScheduler |
Seed |
42 |
Resolution |
1024x1024 |
Skip - layer guidance |
None |
Note: The validation settings are not necessarily the same as the training settings.
Training Settings
Property |
Details |
Training epochs |
99 |
Training steps |
4000 |
Learning rate |
1e - 05 |
Learning rate schedule |
polynomial |
Warmup steps |
100 |
Max grad value |
2.0 |
Effective batch size |
1 |
Micro - batch size |
1 |
Gradient accumulation steps |
1 |
Number of GPUs |
1 |
Gradient checkpointing |
True |
Prediction type |
flow_matching (extra parameters=['shift=3', 'flux_guidance_mode=constant', 'flux_guidance_value=1.0']) |
Optimizer |
adamw_bf16 |
Trainable parameter precision |
Pure BF16 |
Base model precision |
no_change |
Caption dropout probability |
5.0% |
LyCORIS Config
{
"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
}
}
}
}
Datasets
Dataset Name |
Repeats |
Total number of images |
Total number of aspect buckets |
Resolution |
Cropped |
Crop style |
Crop aspect |
Used for regularisation data |
hidream - test - dataset - 256 |
0 |
5 |
2 |
0.065536 megapixels |
False |
None |
None |
No |
hidream - test - dataset - crop - 256 |
0 |
5 |
1 |
0.065536 megapixels |
True |
center |
square |
No |
hidream - test - dataset - 512 |
0 |
5 |
3 |
0.262144 megapixels |
False |
None |
None |
No |
hidream - test - dataset - crop - 512 |
0 |
5 |
1 |
0.262144 megapixels |
True |
center |
square |
No |
hidream - test - dataset - 768 |
0 |
5 |
1 |
0.589824 megapixels |
False |
None |
None |
No |
hidream - test - dataset - crop - 768 |
0 |
5 |
1 |
0.589824 megapixels |
True |
center |
square |
No |
hidream - test - dataset - 1024 |
0 |
5 |
3 |
1.048576 megapixels |
False |
None |
None |
No |
hidream - test - dataset - crop - 1024 |
0 |
5 |
1 |
1.048576 megapixels |
True |
center |
square |
No |
đ§ Technical Details
This project is a LyCORIS adapter based on black-forest-labs/FLUX.1-dev. It uses the LoRA algorithm for parameter adjustment and training, and can generate high - quality images through the diffusion model. During the training process, parameters such as learning rate, batch size, and gradient checkpointing are set to ensure the stability and efficiency of training.
đ License
The license is other.