quzo commited on
Commit
f927165
·
verified ·
1 Parent(s): d3da11a

Model card auto-generated by SimpleTuner

Browse files
Files changed (1) hide show
  1. README.md +258 -0
README.md ADDED
@@ -0,0 +1,258 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ - image-to-image
9
+ - diffusers
10
+ - simpletuner
11
+ - safe-for-work
12
+ - lora
13
+ - template:sd-lora
14
+ - lycoris
15
+ pipeline_tag: text-to-image
16
+ inference: true
17
+ widget:
18
+ - text: 'unconditional (blank prompt)'
19
+ parameters:
20
+ negative_prompt: 'blurry, cropped, ugly'
21
+ output:
22
+ url: ./assets/image_0_0.png
23
+ - text: 'photo of iwatch'
24
+ parameters:
25
+ negative_prompt: 'blurry, cropped, ugly'
26
+ output:
27
+ url: ./assets/image_1_0.png
28
+ ---
29
+
30
+ # iwatch
31
+
32
+ This is a LyCORIS adapter derived from [black-forest-labs/FLUX.1-dev](https://huggingface.co/black-forest-labs/FLUX.1-dev).
33
+
34
+ The main validation prompt used during training was:
35
+ ```
36
+ photo of iwatch
37
+ ```
38
+
39
+
40
+ ## Validation settings
41
+ - CFG: `3.0`
42
+ - CFG Rescale: `0.0`
43
+ - Steps: `20`
44
+ - Sampler: `FlowMatchEulerDiscreteScheduler`
45
+ - Seed: `42`
46
+ - Resolution: `1024x1024`
47
+ - Skip-layer guidance:
48
+
49
+ Note: The validation settings are not necessarily the same as the [training settings](#training-settings).
50
+
51
+ You can find some example images in the following gallery:
52
+
53
+
54
+ <Gallery />
55
+
56
+ The text encoder **was not** trained.
57
+ You may reuse the base model text encoder for inference.
58
+
59
+
60
+ ## Training settings
61
+
62
+ - Training epochs: 0
63
+ - Training steps: 250
64
+ - Learning rate: 0.0001
65
+ - Learning rate schedule: polynomial
66
+ - Warmup steps: 100
67
+ - Max grad value: 2.0
68
+ - Effective batch size: 1
69
+ - Micro-batch size: 1
70
+ - Gradient accumulation steps: 1
71
+ - Number of GPUs: 1
72
+ - Gradient checkpointing: True
73
+ - Prediction type: flow_matching (extra parameters=['shift=3', 'flux_guidance_mode=constant', 'flux_guidance_value=1.0'])
74
+ - Optimizer: adamw_bf16
75
+ - Trainable parameter precision: Pure BF16
76
+ - Base model precision: `no_change`
77
+ - Caption dropout probability: 0.05%
78
+
79
+
80
+
81
+ ### LyCORIS Config:
82
+ ```json
83
+ {
84
+ "algo": "lokr",
85
+ "multiplier": 1.0,
86
+ "linear_dim": 10000,
87
+ "linear_alpha": 1,
88
+ "factor": 16,
89
+ "apply_preset": {
90
+ "target_module": [
91
+ "Attention",
92
+ "FeedForward"
93
+ ],
94
+ "module_algo_map": {
95
+ "Attention": {
96
+ "factor": 16
97
+ },
98
+ "FeedForward": {
99
+ "factor": 8
100
+ }
101
+ }
102
+ }
103
+ }
104
+ ```
105
+
106
+
107
+ ## Datasets
108
+
109
+ ### emi-256
110
+ - Repeats: 10
111
+ - Total number of images: 22
112
+ - Total number of aspect buckets: 2
113
+ - Resolution: 0.065536 megapixels
114
+ - Cropped: False
115
+ - Crop style: None
116
+ - Crop aspect: None
117
+ - Used for regularisation data: No
118
+ ### emi-crop-256
119
+ - Repeats: 10
120
+ - Total number of images: 22
121
+ - Total number of aspect buckets: 1
122
+ - Resolution: 0.065536 megapixels
123
+ - Cropped: True
124
+ - Crop style: center
125
+ - Crop aspect: square
126
+ - Used for regularisation data: No
127
+ ### emi-512
128
+ - Repeats: 10
129
+ - Total number of images: 22
130
+ - Total number of aspect buckets: 3
131
+ - Resolution: 0.262144 megapixels
132
+ - Cropped: False
133
+ - Crop style: None
134
+ - Crop aspect: None
135
+ - Used for regularisation data: No
136
+ ### emi-crop-512
137
+ - Repeats: 10
138
+ - Total number of images: 22
139
+ - Total number of aspect buckets: 1
140
+ - Resolution: 0.262144 megapixels
141
+ - Cropped: True
142
+ - Crop style: center
143
+ - Crop aspect: square
144
+ - Used for regularisation data: No
145
+ ### emi-768
146
+ - Repeats: 10
147
+ - Total number of images: 22
148
+ - Total number of aspect buckets: 2
149
+ - Resolution: 0.589824 megapixels
150
+ - Cropped: False
151
+ - Crop style: None
152
+ - Crop aspect: None
153
+ - Used for regularisation data: No
154
+ ### emi-crop-768
155
+ - Repeats: 10
156
+ - Total number of images: 22
157
+ - Total number of aspect buckets: 1
158
+ - Resolution: 0.589824 megapixels
159
+ - Cropped: True
160
+ - Crop style: center
161
+ - Crop aspect: square
162
+ - Used for regularisation data: No
163
+ ### emi-1024
164
+ - Repeats: 10
165
+ - Total number of images: 22
166
+ - Total number of aspect buckets: 3
167
+ - Resolution: 1.048576 megapixels
168
+ - Cropped: False
169
+ - Crop style: None
170
+ - Crop aspect: None
171
+ - Used for regularisation data: No
172
+ ### emi-crop-1024
173
+ - Repeats: 10
174
+ - Total number of images: 22
175
+ - Total number of aspect buckets: 1
176
+ - Resolution: 1.048576 megapixels
177
+ - Cropped: True
178
+ - Crop style: center
179
+ - Crop aspect: square
180
+ - Used for regularisation data: No
181
+ ### emi-1440
182
+ - Repeats: 10
183
+ - Total number of images: 22
184
+ - Total number of aspect buckets: 2
185
+ - Resolution: 2.0736 megapixels
186
+ - Cropped: False
187
+ - Crop style: None
188
+ - Crop aspect: None
189
+ - Used for regularisation data: No
190
+ ### emi-crop-1440
191
+ - Repeats: 10
192
+ - Total number of images: 22
193
+ - Total number of aspect buckets: 1
194
+ - Resolution: 2.0736 megapixels
195
+ - Cropped: True
196
+ - Crop style: center
197
+ - Crop aspect: square
198
+ - Used for regularisation data: No
199
+
200
+
201
+ ## Inference
202
+
203
+
204
+ ```python
205
+ import torch
206
+ from diffusers import DiffusionPipeline
207
+ from lycoris import create_lycoris_from_weights
208
+
209
+
210
+ def download_adapter(repo_id: str):
211
+ import os
212
+ from huggingface_hub import hf_hub_download
213
+ adapter_filename = "pytorch_lora_weights.safetensors"
214
+ cache_dir = os.environ.get('HF_PATH', os.path.expanduser('~/.cache/huggingface/hub/models'))
215
+ cleaned_adapter_path = repo_id.replace("/", "_").replace("\\", "_").replace(":", "_")
216
+ path_to_adapter = os.path.join(cache_dir, cleaned_adapter_path)
217
+ path_to_adapter_file = os.path.join(path_to_adapter, adapter_filename)
218
+ os.makedirs(path_to_adapter, exist_ok=True)
219
+ hf_hub_download(
220
+ repo_id=repo_id, filename=adapter_filename, local_dir=path_to_adapter
221
+ )
222
+
223
+ return path_to_adapter_file
224
+
225
+ model_id = 'black-forest-labs/FLUX.1-dev'
226
+ adapter_repo_id = 'quzo/iwatch'
227
+ adapter_filename = 'pytorch_lora_weights.safetensors'
228
+ adapter_file_path = download_adapter(repo_id=adapter_repo_id)
229
+ pipeline = DiffusionPipeline.from_pretrained(model_id, torch_dtype=torch.bfloat16) # loading directly in bf16
230
+ lora_scale = 1.0
231
+ wrapper, _ = create_lycoris_from_weights(lora_scale, adapter_file_path, pipeline.transformer)
232
+ wrapper.merge_to()
233
+
234
+ prompt = "photo of iwatch"
235
+
236
+
237
+ ## Optional: quantise the model to save on vram.
238
+ ## Note: The model was not quantised during training, so it is not necessary to quantise it during inference time.
239
+ #from optimum.quanto import quantize, freeze, qint8
240
+ #quantize(pipeline.transformer, weights=qint8)
241
+ #freeze(pipeline.transformer)
242
+
243
+ 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
244
+ model_output = pipeline(
245
+ prompt=prompt,
246
+ num_inference_steps=20,
247
+ generator=torch.Generator(device='cuda' if torch.cuda.is_available() else 'mps' if torch.backends.mps.is_available() else 'cpu').manual_seed(42),
248
+ width=1024,
249
+ height=1024,
250
+ guidance_scale=3.0,
251
+ ).images[0]
252
+
253
+ model_output.save("output.png", format="PNG")
254
+
255
+ ```
256
+
257
+
258
+