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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
license: other
|
| 3 |
+
base_model: "black-forest-labs/FLUX.1-dev"
|
| 4 |
+
tags:
|
| 5 |
+
- flux
|
| 6 |
+
- flux-diffusers
|
| 7 |
+
- text-to-image
|
| 8 |
+
- diffusers
|
| 9 |
+
- simpletuner
|
| 10 |
+
- safe-for-work
|
| 11 |
+
- lora
|
| 12 |
+
- template:sd-lora
|
| 13 |
+
- lycoris
|
| 14 |
+
inference: true
|
| 15 |
+
widget:
|
| 16 |
+
- text: 'unconditional (blank prompt)'
|
| 17 |
+
parameters:
|
| 18 |
+
negative_prompt: 'blurry, cropped, ugly'
|
| 19 |
+
output:
|
| 20 |
+
url: ./assets/image_0_0.png
|
| 21 |
+
- text: 'In the style of a Raphael oil painting, Three figures in red and white religious attire, with one seated at a table holding a magnifying glass, and two standing figures behind. The table is covered with a red cloth and holds an open book and a silver bell. Dark background and muted color palette.'
|
| 22 |
+
parameters:
|
| 23 |
+
negative_prompt: 'blurry, cropped, ugly'
|
| 24 |
+
output:
|
| 25 |
+
url: ./assets/image_1_0.png
|
| 26 |
+
- text: 'In the style of a Raphael oil painting, A knight on a white horse is spearing a dragon lying on the ground. The knight wears armor and a blue cape, while a woman in a red dress stands in the background beside a rock formation. The setting includes tall trees and a distant cityscape.'
|
| 27 |
+
parameters:
|
| 28 |
+
negative_prompt: 'blurry, cropped, ugly'
|
| 29 |
+
output:
|
| 30 |
+
url: ./assets/image_2_0.png
|
| 31 |
+
- text: 'In the style of a Raphael oil painting, A bearded man wearing a black robe and cap sits at a table holding papers in one hand. An apple rests on the table alongside a book with a ring visible on his finger. The background is plain and neutral.'
|
| 32 |
+
parameters:
|
| 33 |
+
negative_prompt: 'blurry, cropped, ugly'
|
| 34 |
+
output:
|
| 35 |
+
url: ./assets/image_3_0.png
|
| 36 |
+
- text: 'In the style of a Raphael oil painting, A seated figure in a blue robe and red dress holds a book, surrounded by two young, unclothed children in a natural setting with trees and mountains in the background. One child holds a bird while the other reaches out towards it. The setting includes a rock and a grassy landscape.'
|
| 37 |
+
parameters:
|
| 38 |
+
negative_prompt: 'blurry, cropped, ugly'
|
| 39 |
+
output:
|
| 40 |
+
url: ./assets/image_4_0.png
|
| 41 |
+
- text: 'In the style of a Raphael oil painting, A scholar-alchemist in flowing robes stands amid glass vessels and astronomical instruments, while light streams through a Gothic window. A mechanical armillary sphere sits prominently on a wooden table, while an assistant in the background tends to a burning crucible.'
|
| 42 |
+
parameters:
|
| 43 |
+
negative_prompt: 'blurry, cropped, ugly'
|
| 44 |
+
output:
|
| 45 |
+
url: ./assets/image_5_0.png
|
| 46 |
+
- text: 'In the style of a Raphael oil painting, Neptune rises from turbulent waters on the steps of Venice''s St. Mark''s Basilica, offering a golden ring to a figure representing the Maritime Republic. Merchants in Renaissance dress observe from gondolas, while angels hold scrolls of maritime law above.'
|
| 47 |
+
parameters:
|
| 48 |
+
negative_prompt: 'blurry, cropped, ugly'
|
| 49 |
+
output:
|
| 50 |
+
url: ./assets/image_6_0.png
|
| 51 |
+
- text: 'In the style of a Raphael oil painting, Aristotle and Plato walk through a Renaissance medicinal garden, discussing a dissected flower. Young apprentices sketch botanical specimens nearby, while in the background, monks tend to rows of healing herbs beneath a pergola covered in grape vines.'
|
| 52 |
+
parameters:
|
| 53 |
+
negative_prompt: 'blurry, cropped, ugly'
|
| 54 |
+
output:
|
| 55 |
+
url: ./assets/image_7_0.png
|
| 56 |
+
- text: 'In the style of a Raphael oil painting, Angels and scholars share a vast library with soaring Renaissance architecture, where celestial maps float in mid-air. Some angels point to globes showing undiscovered continents, while others transcribe from books bound in supernatural light. A telescope made of gold and ivory points through an open dome to the stars.'
|
| 57 |
+
parameters:
|
| 58 |
+
negative_prompt: 'blurry, cropped, ugly'
|
| 59 |
+
output:
|
| 60 |
+
url: ./assets/image_8_0.png
|
| 61 |
+
---
|
| 62 |
+
|
| 63 |
+
# Flux-Raphael-LoRA-NoCrops-EMA-Fast
|
| 64 |
+
|
| 65 |
+
This is a LyCORIS adapter derived from [black-forest-labs/FLUX.1-dev](https://huggingface.co/black-forest-labs/FLUX.1-dev).
|
| 66 |
+
|
| 67 |
+
|
| 68 |
+
No validation prompt was used during training.
|
| 69 |
+
|
| 70 |
+
None
|
| 71 |
+
|
| 72 |
+
|
| 73 |
+
|
| 74 |
+
## Validation settings
|
| 75 |
+
- CFG: `3.0`
|
| 76 |
+
- CFG Rescale: `0.0`
|
| 77 |
+
- Steps: `20`
|
| 78 |
+
- Sampler: `FlowMatchEulerDiscreteScheduler`
|
| 79 |
+
- Seed: `42`
|
| 80 |
+
- Resolution: `1024x1280`
|
| 81 |
+
- Skip-layer guidance:
|
| 82 |
+
|
| 83 |
+
Note: The validation settings are not necessarily the same as the [training settings](#training-settings).
|
| 84 |
+
|
| 85 |
+
You can find some example images in the following gallery:
|
| 86 |
+
|
| 87 |
+
|
| 88 |
+
<Gallery />
|
| 89 |
+
|
| 90 |
+
The text encoder **was not** trained.
|
| 91 |
+
You may reuse the base model text encoder for inference.
|
| 92 |
+
|
| 93 |
+
|
| 94 |
+
## Training settings
|
| 95 |
+
|
| 96 |
+
- Training epochs: 1
|
| 97 |
+
- Training steps: 450
|
| 98 |
+
- Learning rate: 0.001
|
| 99 |
+
- Learning rate schedule: polynomial
|
| 100 |
+
- Warmup steps: 100
|
| 101 |
+
- Max grad norm: 2.0
|
| 102 |
+
- Effective batch size: 4
|
| 103 |
+
- Micro-batch size: 2
|
| 104 |
+
- Gradient accumulation steps: 2
|
| 105 |
+
- Number of GPUs: 1
|
| 106 |
+
- Gradient checkpointing: True
|
| 107 |
+
- Prediction type: flow-matching (extra parameters=['shift=3', 'flux_guidance_mode=constant', 'flux_guidance_value=1.0', 'flow_matching_loss=compatible'])
|
| 108 |
+
- Optimizer: adamw_bf16
|
| 109 |
+
- Trainable parameter precision: Pure BF16
|
| 110 |
+
- Caption dropout probability: 10.0%
|
| 111 |
+
|
| 112 |
+
|
| 113 |
+
### LyCORIS Config:
|
| 114 |
+
```json
|
| 115 |
+
{
|
| 116 |
+
"algo": "lokr",
|
| 117 |
+
"multiplier": 1.0,
|
| 118 |
+
"linear_dim": 10000,
|
| 119 |
+
"linear_alpha": 1,
|
| 120 |
+
"factor": 16,
|
| 121 |
+
"apply_preset": {
|
| 122 |
+
"target_module": [
|
| 123 |
+
"Attention",
|
| 124 |
+
"FeedForward"
|
| 125 |
+
],
|
| 126 |
+
"module_algo_map": {
|
| 127 |
+
"Attention": {
|
| 128 |
+
"factor": 16
|
| 129 |
+
},
|
| 130 |
+
"FeedForward": {
|
| 131 |
+
"factor": 8
|
| 132 |
+
}
|
| 133 |
+
}
|
| 134 |
+
}
|
| 135 |
+
}
|
| 136 |
+
```
|
| 137 |
+
|
| 138 |
+
## Datasets
|
| 139 |
+
|
| 140 |
+
### raphael-512
|
| 141 |
+
- Repeats: 11
|
| 142 |
+
- Total number of images: 28
|
| 143 |
+
- Total number of aspect buckets: 6
|
| 144 |
+
- Resolution: 0.262144 megapixels
|
| 145 |
+
- Cropped: False
|
| 146 |
+
- Crop style: None
|
| 147 |
+
- Crop aspect: None
|
| 148 |
+
- Used for regularisation data: No
|
| 149 |
+
### raphael-768
|
| 150 |
+
- Repeats: 11
|
| 151 |
+
- Total number of images: 28
|
| 152 |
+
- Total number of aspect buckets: 9
|
| 153 |
+
- Resolution: 0.589824 megapixels
|
| 154 |
+
- Cropped: False
|
| 155 |
+
- Crop style: None
|
| 156 |
+
- Crop aspect: None
|
| 157 |
+
- Used for regularisation data: No
|
| 158 |
+
### raphael-1024
|
| 159 |
+
- Repeats: 5
|
| 160 |
+
- Total number of images: 28
|
| 161 |
+
- Total number of aspect buckets: 11
|
| 162 |
+
- Resolution: 1.048576 megapixels
|
| 163 |
+
- Cropped: False
|
| 164 |
+
- Crop style: None
|
| 165 |
+
- Crop aspect: None
|
| 166 |
+
- Used for regularisation data: No
|
| 167 |
+
|
| 168 |
+
|
| 169 |
+
## Inference
|
| 170 |
+
|
| 171 |
+
|
| 172 |
+
```python
|
| 173 |
+
import torch
|
| 174 |
+
from diffusers import DiffusionPipeline
|
| 175 |
+
from lycoris import create_lycoris_from_weights
|
| 176 |
+
|
| 177 |
+
|
| 178 |
+
def download_adapter(repo_id: str):
|
| 179 |
+
import os
|
| 180 |
+
from huggingface_hub import hf_hub_download
|
| 181 |
+
adapter_filename = "pytorch_lora_weights.safetensors"
|
| 182 |
+
cache_dir = os.environ.get('HF_PATH', os.path.expanduser('~/.cache/huggingface/hub/models'))
|
| 183 |
+
cleaned_adapter_path = repo_id.replace("/", "_").replace("\\", "_").replace(":", "_")
|
| 184 |
+
path_to_adapter = os.path.join(cache_dir, cleaned_adapter_path)
|
| 185 |
+
path_to_adapter_file = os.path.join(path_to_adapter, adapter_filename)
|
| 186 |
+
os.makedirs(path_to_adapter, exist_ok=True)
|
| 187 |
+
hf_hub_download(
|
| 188 |
+
repo_id=repo_id, filename=adapter_filename, local_dir=path_to_adapter
|
| 189 |
+
)
|
| 190 |
+
|
| 191 |
+
return path_to_adapter_file
|
| 192 |
+
|
| 193 |
+
model_id = 'black-forest-labs/FLUX.1-dev'
|
| 194 |
+
adapter_repo_id = 'davidrd123/Flux-Raphael-LoRA-NoCrops-EMA-Fast'
|
| 195 |
+
adapter_filename = 'pytorch_lora_weights.safetensors'
|
| 196 |
+
adapter_file_path = download_adapter(repo_id=adapter_repo_id)
|
| 197 |
+
pipeline = DiffusionPipeline.from_pretrained(model_id, torch_dtype=torch.bfloat16) # loading directly in bf16
|
| 198 |
+
lora_scale = 1.0
|
| 199 |
+
wrapper, _ = create_lycoris_from_weights(lora_scale, adapter_file_path, pipeline.transformer)
|
| 200 |
+
wrapper.merge_to()
|
| 201 |
+
|
| 202 |
+
prompt = "An astronaut is riding a horse through the jungles of Thailand."
|
| 203 |
+
|
| 204 |
+
|
| 205 |
+
## Optional: quantise the model to save on vram.
|
| 206 |
+
## Note: The model was quantised during training, and so it is recommended to do the same during inference time.
|
| 207 |
+
from optimum.quanto import quantize, freeze, qint8
|
| 208 |
+
quantize(pipeline.transformer, weights=qint8)
|
| 209 |
+
freeze(pipeline.transformer)
|
| 210 |
+
|
| 211 |
+
pipeline.to('cuda' if torch.cuda.is_available() else 'mps' if torch.backends.mps.is_available() else 'cpu') # the pipeline is already in its target precision level
|
| 212 |
+
image = pipeline(
|
| 213 |
+
prompt=prompt,
|
| 214 |
+
num_inference_steps=20,
|
| 215 |
+
generator=torch.Generator(device='cuda' if torch.cuda.is_available() else 'mps' if torch.backends.mps.is_available() else 'cpu').manual_seed(42),
|
| 216 |
+
width=1024,
|
| 217 |
+
height=1280,
|
| 218 |
+
guidance_scale=3.0,
|
| 219 |
+
).images[0]
|
| 220 |
+
image.save("output.png", format="PNG")
|
| 221 |
+
```
|
| 222 |
+
|
| 223 |
+
|
| 224 |
+
|
| 225 |
+
## Exponential Moving Average (EMA)
|
| 226 |
+
|
| 227 |
+
SimpleTuner generates a safetensors variant of the EMA weights and a pt file.
|
| 228 |
+
|
| 229 |
+
The safetensors file is intended to be used for inference, and the pt file is for continuing finetuning.
|
| 230 |
+
|
| 231 |
+
The EMA model may provide a more well-rounded result, but typically will feel undertrained compared to the full model as it is a running decayed average of the model weights.
|
| 232 |
+
|