datnt114 commited on
Commit
4d3f0cd
·
verified ·
1 Parent(s): c0857f5

Model card auto-generated by SimpleTuner

Browse files
Files changed (1) hide show
  1. README.md +198 -0
README.md ADDED
@@ -0,0 +1,198 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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 girl in the sea'
22
+ parameters:
23
+ negative_prompt: 'blurry, cropped, ugly'
24
+ output:
25
+ url: ./assets/image_1_0.png
26
+ ---
27
+
28
+ # jazzy
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 girl in the sea
36
+ ```
37
+
38
+
39
+ ## Validation settings
40
+ - CFG: `3.5`
41
+ - CFG Rescale: `0.0`
42
+ - Steps: `28`
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: 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: 0.0%
76
+
77
+
78
+ ### LyCORIS Config:
79
+ ```json
80
+ {
81
+ "algo": "lokr",
82
+ "multiplier": 1.0,
83
+ "linear_dim": 10000,
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
+ ### jazy-512
106
+ - Repeats: 10
107
+ - Total number of images: 19
108
+ - Total number of aspect buckets: 1
109
+ - Resolution: 0.262144 megapixels
110
+ - Cropped: False
111
+ - Crop style: None
112
+ - Crop aspect: None
113
+ - Used for regularisation data: No
114
+ ### jazy-1024
115
+ - Repeats: 10
116
+ - Total number of images: 19
117
+ - Total number of aspect buckets: 1
118
+ - Resolution: 1.048576 megapixels
119
+ - Cropped: False
120
+ - Crop style: None
121
+ - Crop aspect: None
122
+ - Used for regularisation data: No
123
+ ### jazy-512-crop
124
+ - Repeats: 10
125
+ - Total number of images: 19
126
+ - Total number of aspect buckets: 1
127
+ - Resolution: 0.262144 megapixels
128
+ - Cropped: True
129
+ - Crop style: random
130
+ - Crop aspect: square
131
+ - Used for regularisation data: No
132
+ ### jazy-1024-crop
133
+ - Repeats: 10
134
+ - Total number of images: 19
135
+ - Total number of aspect buckets: 1
136
+ - Resolution: 1.048576 megapixels
137
+ - Cropped: True
138
+ - Crop style: random
139
+ - Crop aspect: square
140
+ - Used for regularisation data: No
141
+
142
+
143
+ ## Inference
144
+
145
+
146
+ ```python
147
+ import torch
148
+ from diffusers import DiffusionPipeline
149
+ from lycoris import create_lycoris_from_weights
150
+
151
+
152
+ def download_adapter(repo_id: str):
153
+ import os
154
+ from huggingface_hub import hf_hub_download
155
+ adapter_filename = "pytorch_lora_weights.safetensors"
156
+ cache_dir = os.environ.get('HF_PATH', os.path.expanduser('~/.cache/huggingface/hub/models'))
157
+ cleaned_adapter_path = repo_id.replace("/", "_").replace("\\", "_").replace(":", "_")
158
+ path_to_adapter = os.path.join(cache_dir, cleaned_adapter_path)
159
+ path_to_adapter_file = os.path.join(path_to_adapter, adapter_filename)
160
+ os.makedirs(path_to_adapter, exist_ok=True)
161
+ hf_hub_download(
162
+ repo_id=repo_id, filename=adapter_filename, local_dir=path_to_adapter
163
+ )
164
+
165
+ return path_to_adapter_file
166
+
167
+ model_id = 'black-forest-labs/FLUX.1-dev'
168
+ adapter_repo_id = 'datnt114/jazzy'
169
+ adapter_filename = 'pytorch_lora_weights.safetensors'
170
+ adapter_file_path = download_adapter(repo_id=adapter_repo_id)
171
+ pipeline = DiffusionPipeline.from_pretrained(model_id, torch_dtype=torch.bfloat16) # loading directly in bf16
172
+ lora_scale = 1.0
173
+ wrapper, _ = create_lycoris_from_weights(lora_scale, adapter_file_path, pipeline.transformer)
174
+ wrapper.merge_to()
175
+
176
+ prompt = " a girl in the sea"
177
+
178
+
179
+ ## Optional: quantise the model to save on vram.
180
+ ## Note: The model was quantised during training, and so it is recommended to do the same during inference time.
181
+ from optimum.quanto import quantize, freeze, qint8
182
+ quantize(pipeline.transformer, weights=qint8)
183
+ freeze(pipeline.transformer)
184
+
185
+ 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
186
+ image = pipeline(
187
+ prompt=prompt,
188
+ num_inference_steps=28,
189
+ generator=torch.Generator(device='cuda' if torch.cuda.is_available() else 'mps' if torch.backends.mps.is_available() else 'cpu').manual_seed(42),
190
+ width=1024,
191
+ height=1024,
192
+ guidance_scale=3.5,
193
+ ).images[0]
194
+ image.save("output.png", format="PNG")
195
+ ```
196
+
197
+
198
+