uxoah commited on
Commit
8f5ab93
·
verified ·
1 Parent(s): be43e89

Model card auto-generated by SimpleTuner

Browse files
Files changed (1) hide show
  1. README.md +199 -0
README.md ADDED
@@ -0,0 +1,199 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ - 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 heavily armored man standing in a dark, forested environment. He wears a full suit of medieval armor with a helmet featuring a pointed visor. The man holds a long, red sword with a distinctive design. Surrounding him are red, glowing plants and symbols etched into the ground. The background includes tall trees and an eerie red glow.'
22
+ parameters:
23
+ negative_prompt: 'blurry, cropped, ugly'
24
+ output:
25
+ url: ./assets/image_1_0.png
26
+ ---
27
+
28
+ # fantasy_dev_lokr_adamw_2e-4_ema
29
+
30
+ This is a LyCORIS adapter derived from [black-forest-labs/FLUX.1-dev](https://huggingface.co/black-forest-labs/FLUX.1-dev).
31
+
32
+
33
+ The main validation prompt used during training was:
34
+ ```
35
+ a heavily armored man standing in a dark, forested environment. He wears a full suit of medieval armor with a helmet featuring a pointed visor. The man holds a long, red sword with a distinctive design. Surrounding him are red, glowing plants and symbols etched into the ground. The background includes tall trees and an eerie red glow.
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
+
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: 70
62
+ - Training steps: 4000
63
+ - Learning rate: 0.0002
64
+ - Learning rate schedule: polynomial
65
+ - Warmup steps: 400
66
+ - Max grad norm: 0.01
67
+ - Effective batch size: 2
68
+ - Micro-batch size: 2
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: 0.0%
76
+
77
+
78
+ ### LyCORIS Config:
79
+ ```json
80
+ {
81
+ "algo": "lokr",
82
+ "bypass_mode": true,
83
+ "multiplier": 1.0,
84
+ "full_matrix": true,
85
+ "linear_dim": 10000,
86
+ "linear_alpha": 1,
87
+ "factor": 10,
88
+ "apply_preset": {
89
+ "target_module": [
90
+ "Attention",
91
+ "FeedForward"
92
+ ],
93
+ "module_algo_map": {
94
+ "Attention": {
95
+ "factor": 10
96
+ },
97
+ "FeedForward": {
98
+ "factor": 4
99
+ }
100
+ }
101
+ }
102
+ }
103
+ ```
104
+
105
+ ## Datasets
106
+
107
+ ### domonikmayerart_source2_ST-1024
108
+ - Repeats: 0
109
+ - Total number of images: 33
110
+ - Total number of aspect buckets: 1
111
+ - Resolution: 1.048576 megapixels
112
+ - Cropped: False
113
+ - Crop style: None
114
+ - Crop aspect: None
115
+ - Used for regularisation data: No
116
+ ### domonikmayerart_source2_ST-768
117
+ - Repeats: 0
118
+ - Total number of images: 39
119
+ - Total number of aspect buckets: 2
120
+ - Resolution: 0.589824 megapixels
121
+ - Cropped: False
122
+ - Crop style: None
123
+ - Crop aspect: None
124
+ - Used for regularisation data: No
125
+ ### domonikmayerart_source2_ST-512
126
+ - Repeats: 0
127
+ - Total number of images: 39
128
+ - Total number of aspect buckets: 2
129
+ - Resolution: 0.262144 megapixels
130
+ - Cropped: False
131
+ - Crop style: None
132
+ - Crop aspect: None
133
+ - Used for regularisation data: No
134
+
135
+
136
+ ## Inference
137
+
138
+
139
+ ```python
140
+ import torch
141
+ from diffusers import DiffusionPipeline
142
+ from lycoris import create_lycoris_from_weights
143
+
144
+
145
+ def download_adapter(repo_id: str):
146
+ import os
147
+ from huggingface_hub import hf_hub_download
148
+ adapter_filename = "pytorch_lora_weights.safetensors"
149
+ cache_dir = os.environ.get('HF_PATH', os.path.expanduser('~/.cache/huggingface/hub/models'))
150
+ cleaned_adapter_path = repo_id.replace("/", "_").replace("\\", "_").replace(":", "_")
151
+ path_to_adapter = os.path.join(cache_dir, cleaned_adapter_path)
152
+ path_to_adapter_file = os.path.join(path_to_adapter, adapter_filename)
153
+ os.makedirs(path_to_adapter, exist_ok=True)
154
+ hf_hub_download(
155
+ repo_id=repo_id, filename=adapter_filename, local_dir=path_to_adapter
156
+ )
157
+
158
+ return path_to_adapter_file
159
+
160
+ model_id = 'black-forest-labs/FLUX.1-dev'
161
+ adapter_repo_id = 'uxoah/fantasy_dev_lokr_adamw_2e-4_ema'
162
+ adapter_filename = 'pytorch_lora_weights.safetensors'
163
+ adapter_file_path = download_adapter(repo_id=adapter_repo_id)
164
+ pipeline = DiffusionPipeline.from_pretrained(model_id, torch_dtype=torch.bfloat16) # loading directly in bf16
165
+ lora_scale = 1.0
166
+ wrapper, _ = create_lycoris_from_weights(lora_scale, adapter_file_path, pipeline.transformer)
167
+ wrapper.merge_to()
168
+
169
+ prompt = "a heavily armored man standing in a dark, forested environment. He wears a full suit of medieval armor with a helmet featuring a pointed visor. The man holds a long, red sword with a distinctive design. Surrounding him are red, glowing plants and symbols etched into the ground. The background includes tall trees and an eerie red glow."
170
+
171
+
172
+ ## Optional: quantise the model to save on vram.
173
+ ## Note: The model was quantised during training, and so it is recommended to do the same during inference time.
174
+ from optimum.quanto import quantize, freeze, qint8
175
+ quantize(pipeline.transformer, weights=qint8)
176
+ freeze(pipeline.transformer)
177
+
178
+ 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
179
+ image = pipeline(
180
+ prompt=prompt,
181
+ num_inference_steps=20,
182
+ generator=torch.Generator(device='cuda' if torch.cuda.is_available() else 'mps' if torch.backends.mps.is_available() else 'cpu').manual_seed(42),
183
+ width=1024,
184
+ height=1024,
185
+ guidance_scale=3.0,
186
+ ).images[0]
187
+ image.save("output.png", format="PNG")
188
+ ```
189
+
190
+
191
+
192
+ ## Exponential Moving Average (EMA)
193
+
194
+ SimpleTuner generates a safetensors variant of the EMA weights and a pt file.
195
+
196
+ The safetensors file is intended to be used for inference, and the pt file is for continuing finetuning.
197
+
198
+ 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.
199
+