Model card auto-generated by SimpleTuner
Browse files
README.md
CHANGED
|
@@ -18,7 +18,7 @@ widget:
|
|
| 18 |
negative_prompt: 'blurry, cropped, ugly'
|
| 19 |
output:
|
| 20 |
url: ./assets/image_0_0.png
|
| 21 |
-
- text: '
|
| 22 |
parameters:
|
| 23 |
negative_prompt: 'blurry, cropped, ugly'
|
| 24 |
output:
|
|
@@ -31,20 +31,19 @@ This is a LyCORIS adapter derived from [black-forest-labs/FLUX.1-dev](https://hu
|
|
| 31 |
|
| 32 |
|
| 33 |
The main validation prompt used during training was:
|
| 34 |
-
|
| 35 |
-
|
| 36 |
-
|
| 37 |
```
|
| 38 |
-
|
| 39 |
```
|
| 40 |
|
|
|
|
| 41 |
## Validation settings
|
| 42 |
- CFG: `3.0`
|
| 43 |
- CFG Rescale: `0.0`
|
| 44 |
- Steps: `20`
|
| 45 |
-
- Sampler: `
|
| 46 |
- Seed: `42`
|
| 47 |
- Resolution: `1024x1024`
|
|
|
|
| 48 |
|
| 49 |
Note: The validation settings are not necessarily the same as the [training settings](#training-settings).
|
| 50 |
|
|
@@ -59,20 +58,24 @@ You may reuse the base model text encoder for inference.
|
|
| 59 |
|
| 60 |
## Training settings
|
| 61 |
|
| 62 |
-
- Training epochs:
|
| 63 |
-
- Training steps:
|
| 64 |
- Learning rate: 0.0001
|
|
|
|
|
|
|
|
|
|
| 65 |
- Effective batch size: 1
|
| 66 |
- Micro-batch size: 1
|
| 67 |
- Gradient accumulation steps: 1
|
| 68 |
- Number of GPUs: 1
|
| 69 |
-
-
|
| 70 |
-
-
|
| 71 |
- Optimizer: adamw_bf16
|
| 72 |
-
-
|
| 73 |
-
-
|
| 74 |
-
|
| 75 |
-
|
|
|
|
| 76 |
```json
|
| 77 |
{
|
| 78 |
"algo": "lokr",
|
|
@@ -99,14 +102,96 @@ You may reuse the base model text encoder for inference.
|
|
| 99 |
|
| 100 |
## Datasets
|
| 101 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 102 |
### my-dataset-1024
|
| 103 |
-
- Repeats:
|
| 104 |
-
- Total number of images:
|
| 105 |
-
- Total number of aspect buckets:
|
| 106 |
- Resolution: 1.048576 megapixels
|
| 107 |
- Cropped: False
|
| 108 |
- Crop style: None
|
| 109 |
- Crop aspect: None
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 110 |
|
| 111 |
|
| 112 |
## Inference
|
|
@@ -117,19 +202,45 @@ import torch
|
|
| 117 |
from diffusers import DiffusionPipeline
|
| 118 |
from lycoris import create_lycoris_from_weights
|
| 119 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 120 |
model_id = 'black-forest-labs/FLUX.1-dev'
|
| 121 |
-
|
|
|
|
|
|
|
|
|
|
| 122 |
lora_scale = 1.0
|
| 123 |
-
wrapper, _ = create_lycoris_from_weights(lora_scale,
|
| 124 |
wrapper.merge_to()
|
| 125 |
|
| 126 |
-
prompt = "
|
|
|
|
| 127 |
|
| 128 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 129 |
image = pipeline(
|
| 130 |
prompt=prompt,
|
| 131 |
num_inference_steps=20,
|
| 132 |
-
generator=torch.Generator(device='cuda' if torch.cuda.is_available() else 'mps' if torch.backends.mps.is_available() else 'cpu').manual_seed(
|
| 133 |
width=1024,
|
| 134 |
height=1024,
|
| 135 |
guidance_scale=3.0,
|
|
@@ -137,3 +248,5 @@ image = pipeline(
|
|
| 137 |
image.save("output.png", format="PNG")
|
| 138 |
```
|
| 139 |
|
|
|
|
|
|
|
|
|
| 18 |
negative_prompt: 'blurry, cropped, ugly'
|
| 19 |
output:
|
| 20 |
url: ./assets/image_0_0.png
|
| 21 |
+
- text: 'modern architecture, canopy structures, white material, urban design, outdoor space, trees, landscaping, seating areas, people, daylight, clear sky, recreational area, paving pattern, public area, contemporary design, pergola-like elements, radial pattern, greenery, mixed-use space'
|
| 22 |
parameters:
|
| 23 |
negative_prompt: 'blurry, cropped, ugly'
|
| 24 |
output:
|
|
|
|
| 31 |
|
| 32 |
|
| 33 |
The main validation prompt used during training was:
|
|
|
|
|
|
|
|
|
|
| 34 |
```
|
| 35 |
+
modern architecture, canopy structures, white material, urban design, outdoor space, trees, landscaping, seating areas, people, daylight, clear sky, recreational area, paving pattern, public area, contemporary design, pergola-like elements, radial pattern, greenery, mixed-use space
|
| 36 |
```
|
| 37 |
|
| 38 |
+
|
| 39 |
## Validation settings
|
| 40 |
- CFG: `3.0`
|
| 41 |
- CFG Rescale: `0.0`
|
| 42 |
- Steps: `20`
|
| 43 |
+
- Sampler: `FlowMatchEulerDiscreteScheduler`
|
| 44 |
- Seed: `42`
|
| 45 |
- Resolution: `1024x1024`
|
| 46 |
+
- Skip-layer guidance:
|
| 47 |
|
| 48 |
Note: The validation settings are not necessarily the same as the [training settings](#training-settings).
|
| 49 |
|
|
|
|
| 58 |
|
| 59 |
## Training settings
|
| 60 |
|
| 61 |
+
- Training epochs: 0
|
| 62 |
+
- Training steps: 500
|
| 63 |
- Learning rate: 0.0001
|
| 64 |
+
- Learning rate schedule: polynomial
|
| 65 |
+
- Warmup steps: 100
|
| 66 |
+
- Max grad norm: 2.0
|
| 67 |
- Effective batch size: 1
|
| 68 |
- Micro-batch size: 1
|
| 69 |
- Gradient accumulation steps: 1
|
| 70 |
- Number of GPUs: 1
|
| 71 |
+
- Gradient checkpointing: True
|
| 72 |
+
- Prediction type: flow-matching (extra parameters=['shift=3', 'flux_guidance_mode=constant', 'flux_guidance_value=1.0', 'flow_matching_loss=compatible'])
|
| 73 |
- Optimizer: adamw_bf16
|
| 74 |
+
- Trainable parameter precision: Pure BF16
|
| 75 |
+
- Caption dropout probability: 5.0%
|
| 76 |
+
|
| 77 |
+
|
| 78 |
+
### LyCORIS Config:
|
| 79 |
```json
|
| 80 |
{
|
| 81 |
"algo": "lokr",
|
|
|
|
| 102 |
|
| 103 |
## Datasets
|
| 104 |
|
| 105 |
+
### my-dataset-256
|
| 106 |
+
- Repeats: 10
|
| 107 |
+
- Total number of images: 71
|
| 108 |
+
- Total number of aspect buckets: 1
|
| 109 |
+
- Resolution: 0.065536 megapixels
|
| 110 |
+
- Cropped: False
|
| 111 |
+
- Crop style: None
|
| 112 |
+
- Crop aspect: None
|
| 113 |
+
- Used for regularisation data: No
|
| 114 |
+
### my-dataset-crop-256
|
| 115 |
+
- Repeats: 10
|
| 116 |
+
- Total number of images: 71
|
| 117 |
+
- Total number of aspect buckets: 1
|
| 118 |
+
- Resolution: 0.065536 megapixels
|
| 119 |
+
- Cropped: True
|
| 120 |
+
- Crop style: center
|
| 121 |
+
- Crop aspect: square
|
| 122 |
+
- Used for regularisation data: No
|
| 123 |
+
### my-dataset-512
|
| 124 |
+
- Repeats: 10
|
| 125 |
+
- Total number of images: 71
|
| 126 |
+
- Total number of aspect buckets: 1
|
| 127 |
+
- Resolution: 0.262144 megapixels
|
| 128 |
+
- Cropped: False
|
| 129 |
+
- Crop style: None
|
| 130 |
+
- Crop aspect: None
|
| 131 |
+
- Used for regularisation data: No
|
| 132 |
+
### my-dataset-crop-512
|
| 133 |
+
- Repeats: 10
|
| 134 |
+
- Total number of images: 71
|
| 135 |
+
- Total number of aspect buckets: 1
|
| 136 |
+
- Resolution: 0.262144 megapixels
|
| 137 |
+
- Cropped: True
|
| 138 |
+
- Crop style: center
|
| 139 |
+
- Crop aspect: square
|
| 140 |
+
- Used for regularisation data: No
|
| 141 |
+
### my-dataset-768
|
| 142 |
+
- Repeats: 10
|
| 143 |
+
- Total number of images: 71
|
| 144 |
+
- Total number of aspect buckets: 1
|
| 145 |
+
- Resolution: 0.589824 megapixels
|
| 146 |
+
- Cropped: False
|
| 147 |
+
- Crop style: None
|
| 148 |
+
- Crop aspect: None
|
| 149 |
+
- Used for regularisation data: No
|
| 150 |
+
### my-dataset-crop-768
|
| 151 |
+
- Repeats: 10
|
| 152 |
+
- Total number of images: 71
|
| 153 |
+
- Total number of aspect buckets: 1
|
| 154 |
+
- Resolution: 0.589824 megapixels
|
| 155 |
+
- Cropped: True
|
| 156 |
+
- Crop style: center
|
| 157 |
+
- Crop aspect: square
|
| 158 |
+
- Used for regularisation data: No
|
| 159 |
### my-dataset-1024
|
| 160 |
+
- Repeats: 10
|
| 161 |
+
- Total number of images: 71
|
| 162 |
+
- Total number of aspect buckets: 1
|
| 163 |
- Resolution: 1.048576 megapixels
|
| 164 |
- Cropped: False
|
| 165 |
- Crop style: None
|
| 166 |
- Crop aspect: None
|
| 167 |
+
- Used for regularisation data: No
|
| 168 |
+
### my-dataset-crop-1024
|
| 169 |
+
- Repeats: 10
|
| 170 |
+
- Total number of images: 71
|
| 171 |
+
- Total number of aspect buckets: 1
|
| 172 |
+
- Resolution: 1.048576 megapixels
|
| 173 |
+
- Cropped: True
|
| 174 |
+
- Crop style: center
|
| 175 |
+
- Crop aspect: square
|
| 176 |
+
- Used for regularisation data: No
|
| 177 |
+
### my-dataset-1440
|
| 178 |
+
- Repeats: 10
|
| 179 |
+
- Total number of images: 71
|
| 180 |
+
- Total number of aspect buckets: 1
|
| 181 |
+
- Resolution: 2.0736 megapixels
|
| 182 |
+
- Cropped: False
|
| 183 |
+
- Crop style: None
|
| 184 |
+
- Crop aspect: None
|
| 185 |
+
- Used for regularisation data: No
|
| 186 |
+
### my-dataset-crop-1440
|
| 187 |
+
- Repeats: 10
|
| 188 |
+
- Total number of images: 71
|
| 189 |
+
- Total number of aspect buckets: 1
|
| 190 |
+
- Resolution: 2.0736 megapixels
|
| 191 |
+
- Cropped: True
|
| 192 |
+
- Crop style: center
|
| 193 |
+
- Crop aspect: square
|
| 194 |
+
- Used for regularisation data: No
|
| 195 |
|
| 196 |
|
| 197 |
## Inference
|
|
|
|
| 202 |
from diffusers import DiffusionPipeline
|
| 203 |
from lycoris import create_lycoris_from_weights
|
| 204 |
|
| 205 |
+
|
| 206 |
+
def download_adapter(repo_id: str):
|
| 207 |
+
import os
|
| 208 |
+
from huggingface_hub import hf_hub_download
|
| 209 |
+
adapter_filename = "pytorch_lora_weights.safetensors"
|
| 210 |
+
cache_dir = os.environ.get('HF_PATH', os.path.expanduser('~/.cache/huggingface/hub/models'))
|
| 211 |
+
cleaned_adapter_path = repo_id.replace("/", "_").replace("\\", "_").replace(":", "_")
|
| 212 |
+
path_to_adapter = os.path.join(cache_dir, cleaned_adapter_path)
|
| 213 |
+
path_to_adapter_file = os.path.join(path_to_adapter, adapter_filename)
|
| 214 |
+
os.makedirs(path_to_adapter, exist_ok=True)
|
| 215 |
+
hf_hub_download(
|
| 216 |
+
repo_id=repo_id, filename=adapter_filename, local_dir=path_to_adapter
|
| 217 |
+
)
|
| 218 |
+
|
| 219 |
+
return path_to_adapter_file
|
| 220 |
+
|
| 221 |
model_id = 'black-forest-labs/FLUX.1-dev'
|
| 222 |
+
adapter_repo_id = 'ossaili/simpletuner-lora'
|
| 223 |
+
adapter_filename = 'pytorch_lora_weights.safetensors'
|
| 224 |
+
adapter_file_path = download_adapter(repo_id=adapter_repo_id)
|
| 225 |
+
pipeline = DiffusionPipeline.from_pretrained(model_id, torch_dtype=torch.bfloat16) # loading directly in bf16
|
| 226 |
lora_scale = 1.0
|
| 227 |
+
wrapper, _ = create_lycoris_from_weights(lora_scale, adapter_file_path, pipeline.transformer)
|
| 228 |
wrapper.merge_to()
|
| 229 |
|
| 230 |
+
prompt = "modern architecture, canopy structures, white material, urban design, outdoor space, trees, landscaping, seating areas, people, daylight, clear sky, recreational area, paving pattern, public area, contemporary design, pergola-like elements, radial pattern, greenery, mixed-use space"
|
| 231 |
+
|
| 232 |
|
| 233 |
+
## Optional: quantise the model to save on vram.
|
| 234 |
+
## Note: The model was quantised during training, and so it is recommended to do the same during inference time.
|
| 235 |
+
from optimum.quanto import quantize, freeze, qint8
|
| 236 |
+
quantize(pipeline.transformer, weights=qint8)
|
| 237 |
+
freeze(pipeline.transformer)
|
| 238 |
+
|
| 239 |
+
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
|
| 240 |
image = pipeline(
|
| 241 |
prompt=prompt,
|
| 242 |
num_inference_steps=20,
|
| 243 |
+
generator=torch.Generator(device='cuda' if torch.cuda.is_available() else 'mps' if torch.backends.mps.is_available() else 'cpu').manual_seed(42),
|
| 244 |
width=1024,
|
| 245 |
height=1024,
|
| 246 |
guidance_scale=3.0,
|
|
|
|
| 248 |
image.save("output.png", format="PNG")
|
| 249 |
```
|
| 250 |
|
| 251 |
+
|
| 252 |
+
|