PixelWormhole commited on
Commit
7408416
·
verified ·
1 Parent(s): afb6c43

Model card auto-generated by SimpleTuner

Browse files
Files changed (1) hide show
  1. README.md +239 -0
README.md ADDED
@@ -0,0 +1,239 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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: 'A photo-realistic image of a cat'
24
+ parameters:
25
+ negative_prompt: 'blurry, cropped, ugly'
26
+ output:
27
+ url: ./assets/image_1_0.png
28
+ ---
29
+
30
+ # mani-test-lora
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
+ A photo-realistic image of a cat
37
+ ```
38
+
39
+
40
+ ## Validation settings
41
+ - CFG: `3.0`
42
+ - CFG Rescale: `0.0`
43
+ - Steps: `28`
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: 12
63
+ - Training steps: 500
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: 5.0%
78
+
79
+
80
+
81
+ ### LyCORIS Config:
82
+ ```json
83
+ {
84
+ "algo": "lora",
85
+ "multiplier": 1.0,
86
+ "linear_dim": 64,
87
+ "linear_alpha": 32,
88
+ "apply_preset": {
89
+ "target_module": [
90
+ "Attention",
91
+ "FeedForward"
92
+ ],
93
+ "module_algo_map": {
94
+ "Attention": {
95
+ "factor": 16
96
+ },
97
+ "FeedForward": {
98
+ "factor": 8
99
+ }
100
+ }
101
+ }
102
+ }
103
+ ```
104
+
105
+
106
+ ## Datasets
107
+
108
+ ### hidream-test-dataset-256
109
+ - Repeats: 0
110
+ - Total number of images: 5
111
+ - Total number of aspect buckets: 2
112
+ - Resolution: 0.065536 megapixels
113
+ - Cropped: False
114
+ - Crop style: None
115
+ - Crop aspect: None
116
+ - Used for regularisation data: No
117
+ ### hidream-test-dataset-crop-256
118
+ - Repeats: 0
119
+ - Total number of images: 5
120
+ - Total number of aspect buckets: 1
121
+ - Resolution: 0.065536 megapixels
122
+ - Cropped: True
123
+ - Crop style: center
124
+ - Crop aspect: square
125
+ - Used for regularisation data: No
126
+ ### hidream-test-dataset-512
127
+ - Repeats: 0
128
+ - Total number of images: 5
129
+ - Total number of aspect buckets: 3
130
+ - Resolution: 0.262144 megapixels
131
+ - Cropped: False
132
+ - Crop style: None
133
+ - Crop aspect: None
134
+ - Used for regularisation data: No
135
+ ### hidream-test-dataset-crop-512
136
+ - Repeats: 0
137
+ - Total number of images: 5
138
+ - Total number of aspect buckets: 1
139
+ - Resolution: 0.262144 megapixels
140
+ - Cropped: True
141
+ - Crop style: center
142
+ - Crop aspect: square
143
+ - Used for regularisation data: No
144
+ ### hidream-test-dataset-768
145
+ - Repeats: 0
146
+ - Total number of images: 5
147
+ - Total number of aspect buckets: 2
148
+ - Resolution: 0.589824 megapixels
149
+ - Cropped: False
150
+ - Crop style: None
151
+ - Crop aspect: None
152
+ - Used for regularisation data: No
153
+ ### hidream-test-dataset-crop-768
154
+ - Repeats: 0
155
+ - Total number of images: 5
156
+ - Total number of aspect buckets: 1
157
+ - Resolution: 0.589824 megapixels
158
+ - Cropped: True
159
+ - Crop style: center
160
+ - Crop aspect: square
161
+ - Used for regularisation data: No
162
+ ### hidream-test-dataset-1024
163
+ - Repeats: 0
164
+ - Total number of images: 5
165
+ - Total number of aspect buckets: 3
166
+ - Resolution: 1.048576 megapixels
167
+ - Cropped: False
168
+ - Crop style: None
169
+ - Crop aspect: None
170
+ - Used for regularisation data: No
171
+ ### hidream-test-dataset-crop-1024
172
+ - Repeats: 0
173
+ - Total number of images: 5
174
+ - Total number of aspect buckets: 1
175
+ - Resolution: 1.048576 megapixels
176
+ - Cropped: True
177
+ - Crop style: center
178
+ - Crop aspect: square
179
+ - Used for regularisation data: No
180
+
181
+
182
+ ## Inference
183
+
184
+
185
+ ```python
186
+ import torch
187
+ from diffusers import DiffusionPipeline
188
+ from lycoris import create_lycoris_from_weights
189
+
190
+
191
+ def download_adapter(repo_id: str):
192
+ import os
193
+ from huggingface_hub import hf_hub_download
194
+ adapter_filename = "pytorch_lora_weights.safetensors"
195
+ cache_dir = os.environ.get('HF_PATH', os.path.expanduser('~/.cache/huggingface/hub/models'))
196
+ cleaned_adapter_path = repo_id.replace("/", "_").replace("\\", "_").replace(":", "_")
197
+ path_to_adapter = os.path.join(cache_dir, cleaned_adapter_path)
198
+ path_to_adapter_file = os.path.join(path_to_adapter, adapter_filename)
199
+ os.makedirs(path_to_adapter, exist_ok=True)
200
+ hf_hub_download(
201
+ repo_id=repo_id, filename=adapter_filename, local_dir=path_to_adapter
202
+ )
203
+
204
+ return path_to_adapter_file
205
+
206
+ model_id = 'black-forest-labs/FLUX.1-dev'
207
+ adapter_repo_id = 'PixelWormhole/mani-test-lora'
208
+ adapter_filename = 'pytorch_lora_weights.safetensors'
209
+ adapter_file_path = download_adapter(repo_id=adapter_repo_id)
210
+ pipeline = DiffusionPipeline.from_pretrained(model_id, torch_dtype=torch.bfloat16) # loading directly in bf16
211
+ lora_scale = 1.0
212
+ wrapper, _ = create_lycoris_from_weights(lora_scale, adapter_file_path, pipeline.transformer)
213
+ wrapper.merge_to()
214
+
215
+ prompt = "A photo-realistic image of a cat"
216
+
217
+
218
+ ## Optional: quantise the model to save on vram.
219
+ ## Note: The model was not quantised during training, so it is not necessary to quantise it during inference time.
220
+ #from optimum.quanto import quantize, freeze, qint8
221
+ #quantize(pipeline.transformer, weights=qint8)
222
+ #freeze(pipeline.transformer)
223
+
224
+ 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
225
+ model_output = pipeline(
226
+ prompt=prompt,
227
+ num_inference_steps=28,
228
+ generator=torch.Generator(device='cuda' if torch.cuda.is_available() else 'mps' if torch.backends.mps.is_available() else 'cpu').manual_seed(42),
229
+ width=1024,
230
+ height=1024,
231
+ guidance_scale=3.0,
232
+ ).images[0]
233
+
234
+ model_output.save("output.png", format="PNG")
235
+
236
+ ```
237
+
238
+
239
+