Text-to-Image
Diffusers
flux
flux-diffusers
simpletuner
Not-For-All-Audiences
lora
template:sd-lora
standard
Model card auto-generated by SimpleTuner
Browse files
README.md
ADDED
@@ -0,0 +1,171 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
---
|
2 |
+
license: other
|
3 |
+
base_model: "flux/unknown-model"
|
4 |
+
tags:
|
5 |
+
- flux
|
6 |
+
- flux-diffusers
|
7 |
+
- text-to-image
|
8 |
+
- diffusers
|
9 |
+
- simpletuner
|
10 |
+
- not-for-all-audiences
|
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: 'A Simple Pencil sketch of Marilyn Monroe, showcasing her iconic smile and glamorous hairstyle. The shading captures the softness of her features and the elegance of her famous pose, framed by a hint of her signature wardrobe.'
|
22 |
+
parameters:
|
23 |
+
negative_prompt: 'blurry, cropped, ugly'
|
24 |
+
output:
|
25 |
+
url: ./assets/image_1_0.png
|
26 |
+
---
|
27 |
+
|
28 |
+
# random
|
29 |
+
|
30 |
+
This is a LyCORIS adapter derived from [flux/unknown-model](https://huggingface.co/flux/unknown-model).
|
31 |
+
|
32 |
+
|
33 |
+
The main validation prompt used during training was:
|
34 |
+
```
|
35 |
+
A Simple Pencil sketch of Marilyn Monroe, showcasing her iconic smile and glamorous hairstyle. The shading captures the softness of her features and the elegance of her famous pose, framed by a hint of her signature wardrobe.
|
36 |
+
```
|
37 |
+
|
38 |
+
|
39 |
+
## Validation settings
|
40 |
+
- CFG: `3.5`
|
41 |
+
- CFG Rescale: `0.0`
|
42 |
+
- Steps: `35`
|
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 |
+
|
50 |
+
You can find some example images in the following gallery:
|
51 |
+
|
52 |
+
|
53 |
+
<Gallery />
|
54 |
+
|
55 |
+
The text encoder **was not** trained.
|
56 |
+
You may reuse the base model text encoder for inference.
|
57 |
+
|
58 |
+
|
59 |
+
## Training settings
|
60 |
+
|
61 |
+
- Training epochs: 1
|
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: 10.0%
|
76 |
+
|
77 |
+
|
78 |
+
### LyCORIS Config:
|
79 |
+
```json
|
80 |
+
{
|
81 |
+
"algo": "lokr",
|
82 |
+
"multiplier": 1.0,
|
83 |
+
"linear_dim": 16,
|
84 |
+
"linear_alpha": 1,
|
85 |
+
"factor": 16,
|
86 |
+
"apply_preset": {
|
87 |
+
"target_module": [
|
88 |
+
"Attention",
|
89 |
+
"FeedForward"
|
90 |
+
],
|
91 |
+
"module_algo_map": {
|
92 |
+
"Attention": {
|
93 |
+
"factor": 16
|
94 |
+
},
|
95 |
+
"FeedForward": {
|
96 |
+
"factor": 8
|
97 |
+
}
|
98 |
+
}
|
99 |
+
}
|
100 |
+
}
|
101 |
+
```
|
102 |
+
|
103 |
+
## Datasets
|
104 |
+
|
105 |
+
### pencil-sketch-image
|
106 |
+
- Repeats: 10
|
107 |
+
- Total number of images: 31
|
108 |
+
- Total number of aspect buckets: 1
|
109 |
+
- Resolution: 1.048576 megapixels
|
110 |
+
- Cropped: True
|
111 |
+
- Crop style: random
|
112 |
+
- Crop aspect: square
|
113 |
+
- Used for regularisation data: No
|
114 |
+
|
115 |
+
|
116 |
+
## Inference
|
117 |
+
|
118 |
+
|
119 |
+
```python
|
120 |
+
import torch
|
121 |
+
from diffusers import DiffusionPipeline
|
122 |
+
from lycoris import create_lycoris_from_weights
|
123 |
+
|
124 |
+
|
125 |
+
def download_adapter(repo_id: str):
|
126 |
+
import os
|
127 |
+
from huggingface_hub import hf_hub_download
|
128 |
+
adapter_filename = "pytorch_lora_weights.safetensors"
|
129 |
+
cache_dir = os.environ.get('HF_PATH', os.path.expanduser('~/.cache/huggingface/hub/models'))
|
130 |
+
cleaned_adapter_path = repo_id.replace("/", "_").replace("\\", "_").replace(":", "_")
|
131 |
+
path_to_adapter = os.path.join(cache_dir, cleaned_adapter_path)
|
132 |
+
path_to_adapter_file = os.path.join(path_to_adapter, adapter_filename)
|
133 |
+
os.makedirs(path_to_adapter, exist_ok=True)
|
134 |
+
hf_hub_download(
|
135 |
+
repo_id=repo_id, filename=adapter_filename, local_dir=path_to_adapter
|
136 |
+
)
|
137 |
+
|
138 |
+
return path_to_adapter_file
|
139 |
+
|
140 |
+
model_id = '/workspace/FLUX.1-dev'
|
141 |
+
adapter_repo_id = 'mrtuandao/random'
|
142 |
+
adapter_filename = 'pytorch_lora_weights.safetensors'
|
143 |
+
adapter_file_path = download_adapter(repo_id=adapter_repo_id)
|
144 |
+
pipeline = DiffusionPipeline.from_pretrained(model_id, torch_dtype=torch.bfloat16) # loading directly in bf16
|
145 |
+
lora_scale = 1.0
|
146 |
+
wrapper, _ = create_lycoris_from_weights(lora_scale, adapter_file_path, pipeline.transformer)
|
147 |
+
wrapper.merge_to()
|
148 |
+
|
149 |
+
prompt = "A Simple Pencil sketch of Marilyn Monroe, showcasing her iconic smile and glamorous hairstyle. The shading captures the softness of her features and the elegance of her famous pose, framed by a hint of her signature wardrobe."
|
150 |
+
|
151 |
+
|
152 |
+
## Optional: quantise the model to save on vram.
|
153 |
+
## Note: The model was not quantised during training, so it is not necessary to quantise it during inference time.
|
154 |
+
#from optimum.quanto import quantize, freeze, qint8
|
155 |
+
#quantize(pipeline.transformer, weights=qint8)
|
156 |
+
#freeze(pipeline.transformer)
|
157 |
+
|
158 |
+
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
|
159 |
+
image = pipeline(
|
160 |
+
prompt=prompt,
|
161 |
+
num_inference_steps=35,
|
162 |
+
generator=torch.Generator(device='cuda' if torch.cuda.is_available() else 'mps' if torch.backends.mps.is_available() else 'cpu').manual_seed(42),
|
163 |
+
width=1024,
|
164 |
+
height=1024,
|
165 |
+
guidance_scale=3.5,
|
166 |
+
).images[0]
|
167 |
+
image.save("output.png", format="PNG")
|
168 |
+
```
|
169 |
+
|
170 |
+
|
171 |
+
|