kneiff commited on
Commit
92bc8c2
·
1 Parent(s): d84529f

Add FLUX.2 Klein Base 9B LoRA config template

Browse files
configs/{F2K.knf.yaml → F2K_4B.knf.yaml} RENAMED
File without changes
configs/F2K_9B.knf.yaml ADDED
@@ -0,0 +1,311 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # ==============================================================
2
+ # == Directories
3
+ # ==============================================================
4
+
5
+
6
+ # > Dataset sync derives SOURCE/, MANIFEST.knf.xlsx, and HF/<config-id>/ from this filename.
7
+
8
+ # -- Map exported subset names to source subfolders in MANIFEST.knf.xlsx.
9
+ mappings:
10
+ # > Anchor identity examples get sampled at a lower probability below.
11
+ felkin_anchor:
12
+ - "0-ANCHOR" # Source folder for anchor identity images.
13
+ # > Explicit anatomy close-up subsets are kept separate for sampling control.
14
+ genitals:
15
+ - "6-DICK" # Source folder for exposed anatomy close-ups.
16
+ - "6-SHEATH" # Source folder for sheathed anatomy close-ups.
17
+ # > Complete body.
18
+ fullbody:
19
+ - "0-FULLBODY" # Full-body identity examples; also included in rest subset.
20
+ - "99-VERSION-LEANER" # Alternate leaner full-body examples.
21
+ # > General body, hand, leg, tail, and leaner variant images.
22
+ body_details:
23
+ - "1-TORSO" # Torso detail examples.
24
+ - "3-HANDS" # Hand detail examples.
25
+ - "4-LEGS" # Leg/foot detail examples.
26
+ - "5-TAIL" # Tail detail examples.
27
+ # > Focused fur-texture crops derived from high-resolution Rook sources.
28
+ fur:
29
+ - "7-FUR" # Fur crops for coat, mane, spots, paws, tail, and anatomy-adjacent texture.
30
+ head:
31
+ - "2-HEAD" # Face/head detail examples.
32
+
33
+ # > Also export manifest rows marked sfw into an additional generated sfw subset.
34
+ export_sfw_subset: true # < Add generated sfw subset from rows marked sfw.
35
+
36
+ # ==============================================================
37
+ # == Images
38
+ # ==============================================================
39
+
40
+ # Export-time mirroring writes fixed extra image/caption pairs before
41
+ # SimpleTuner sees the dataset. flip_only keeps kneifftools from applying its
42
+ # own random crop, rotation, or color jitter.
43
+ augmentations:
44
+ mirrored_extra: true # Add one mirrored copy per selected source image.
45
+ mirrored_transform: flip_only # Exact horizontal mirror, no kneifftools crop/jitter.
46
+ seed: 12345 # Makes mirrored export naming deterministic.
47
+
48
+ # Export image area bounds before SimpleTuner sees the dataset. The upper bound
49
+ # preserves more source detail than Chroma while staying below roughly 1280x1280.
50
+ image_resize:
51
+ min_pixel_area: 512 # Upscale tiny images below roughly 512x512 area.
52
+ max_pixel_area: 1280 # Downscale large images above roughly 1280x1280 area.
53
+
54
+ # ==============================================================
55
+ # == Captions
56
+ # ==============================================================
57
+
58
+ # Controlled caption rendering context used by all generated sidecars.
59
+ caption:
60
+ subject_sex: male # Adds male subject wording to prose renderers.
61
+ add_domains_to_tags: false # Flux2 captions are natural prose, not domain-tag tails.
62
+
63
+ # Flux2 Klein uses a Qwen-style text stack; use Kneiff's natural-language flux2 profile.
64
+ caption_outputs:
65
+ mode: hybrid_txt # One .txt sidecar per image containing selected formats.
66
+ formats: [flux2] # Natural-language caption profile for Flux2 Klein training.
67
+ tag_scope: supplemental # Kept explicit for consistency with shipped overlays.
68
+
69
+ # Optional per-subset caption output overrides. Keep commented unless a subset
70
+ # needs different caption files or formats.
71
+ # caption_outputs_overrides:
72
+ # felkin_anchor:
73
+ # mode: hybrid_txt
74
+ # formats: [flux2]
75
+ # genitals:
76
+ # mode: hybrid_txt
77
+ # formats: [flux2]
78
+ # fullbody:
79
+ # mode: hybrid_txt
80
+ # formats: [flux2]
81
+ # body_details:
82
+ # mode: hybrid_txt
83
+ # formats: [flux2]
84
+ # fur:
85
+ # mode: hybrid_txt
86
+ # formats: [flux2]
87
+ # head:
88
+ # mode: hybrid_txt
89
+ # formats: [flux2]
90
+ # sfw:
91
+ # mode: hybrid_txt
92
+ # formats: [flux2]
93
+
94
+ # ==============================================================
95
+ # == Publishing
96
+ # ==============================================================
97
+
98
+ publishing:
99
+ huggingface:
100
+ pretty_name: Ladybug Felkin # Human-readable dataset-card base title.
101
+ version: v5.6-f2k # Public dataset version label.
102
+ optimized_for_model: FLUX.2 Klein Base 9B # Rendered as [For FLUX.2 Klein Base 9B].
103
+ tags: [flux2, flux2-klein, flux2-klein-9b, flux2-klein-base-9b, lora, diffusion-training, image-captioning]
104
+ adult_content: true # Render the adult-content notice in README.md.
105
+
106
+ # ==============================================================
107
+ # == LoRA Training
108
+ # ==============================================================
109
+
110
+ training:
111
+ enabled: true # Enables kneifftools training artifact generation.
112
+ backend: simpletuner # Selects the SimpleTuner LoRA backend.
113
+
114
+ simpletuner:
115
+
116
+ # enabled: true # Optional backend-specific switch; defaults to enabled.
117
+
118
+ # -- Generated artifact filenames written into TRAINING/<config-id>_<run>.
119
+ config_filename: simpletuner-config.json # Top-level SimpleTuner config.
120
+ data_backend_filename: simpletuner-multidatabackend.json # Multi-databackend config.
121
+
122
+ # Generated cache/output directories. Relative paths resolve below TRAINING/<config-id>_<run>.
123
+ cache_root: .simpletuner-cache # Shared model, text, and VAE cache root.
124
+ output_dir: _simpletuner-output # Normal full-run checkpoint output dir.
125
+
126
+ # Subset-specific SimpleTuner dataloader overrides. Any key here is merged
127
+ # into the subset backend entry after the dataset defaults below.
128
+ subsets:
129
+ felkin_anchor:
130
+ probability: 1 # Sample anchor identity images at steady exposure.
131
+ resolution: 1280 # High-resolution identity anchors support 1280 area.
132
+ # minimum_image_size: 1024 # Avoid using weakly upscaled anchors.
133
+ crop: false # Preserve full source composition.
134
+ # repeats: 0 # Optional per-subset repeat count.
135
+ # disabled: false # Optional per-subset on/off switch.
136
+ fullbody:
137
+ probability: 8.0 # Sample full-body subset at high probability.
138
+ resolution: 1280 # Full-body images are the strongest high-res subset.
139
+ crop: false # Preserve full-body composition.
140
+ # repeats: 0
141
+ # disabled: false
142
+ body_details:
143
+ probability: 3 # Sample body detail subset at normal probability.
144
+ crop: false # Preserve detail framing; many samples are already close crops.
145
+ # repeats: 0
146
+ # disabled: false
147
+ fur:
148
+ probability: 2.0 # Give focused fur crops extra exposure.
149
+ crop: false # Preserve texture crop intent; do not random-crop fur samples.
150
+ # repeats: 0
151
+ # disabled: false
152
+ head:
153
+ probability: 2 # Sample head/face details at extra exposure.
154
+ resolution: 1280 # Preserve detail in high-res head crops.
155
+ crop: false # Preserve detail framing; many samples are close crops.
156
+ genitals:
157
+ probability: 4 # Sample anatomy subset at normal probability.
158
+ crop: false # Preserve anatomy crop framing.
159
+ # repeats: 0
160
+ # disabled: false
161
+
162
+ # Dataset backend defaults copied into every image subset entry.
163
+ dataset:
164
+ type: local # SimpleTuner local filesystem backend.
165
+ dataset_type: image # Image dataset backend, not text embeds.
166
+ resolution: 1024 # Default target area edge for mixed-resolution subsets.
167
+ minimum_image_size: 512 # Keep smaller detail/anatomy crops after export upscaling.
168
+ maximum_image_size: 1280 # Upper bound for input image sizing.
169
+ target_downsample_size: 1280 # Downsample target for cache generation.
170
+ resolution_type: pixel_area # Area-based buckets, not smaller-edge resize.
171
+ caption_strategy: textfile # Read captions from exported .txt sidecars.
172
+ metadata_backend: discovery # Discover images/captions from directories.
173
+ crop: false # Preserve source framing for this Flux2 Klein run.
174
+ crop_style: center # Inert while crop is false; avoids random-crop defaults.
175
+ crop_aspect: preserve # Preserve original aspect instead of square crop.
176
+ # repeats: 0 # Dataset-level repeat count; subset can override.
177
+ # disabled: false # Dataset-level backend switch.
178
+
179
+ # Optional shared text-embedding backend overrides. Commented keys show the
180
+ # kneifftools-owned defaults for the generated text_embeds backend.
181
+ # text_embeds:
182
+ # id: text-embeds # Backend id used by SimpleTuner.
183
+ # type: local # Store embeddings on local filesystem.
184
+ # dataset_type: text_embeds
185
+ # default: true # Marks this as the shared embedding backend.
186
+ # cache_dir: .simpletuner-cache/text # Override generated text cache dir.
187
+ # disabled: false
188
+
189
+ # Generate a SimpleTuner user_prompt_library JSON from fixed Flux2 prompts
190
+ # plus manifest-derived controls.
191
+ validation_prompts:
192
+ enabled: true
193
+ filename: simpletuner-validation-prompts.json
194
+ # positive_prefix: "masterpiece, best quality, score_7, safe, "
195
+ custom:
196
+ f2k_portrait: "Rook_Kaefer is shown in a portrait as a male Felkin character with an expressive face, soft studio lighting, red-and-black ladybug fur markings."
197
+ f2k_fullbody_reference: "Rook_Kaefer is shown from the rear in a full-body view, walking away from the viewer with his back, legs, tail, and red-and-black fur markings clearly visible."
198
+ f2k_body_detail: "Rook_Kaefer is walking sideways across the frame in a clear profile view, with his torso, arms, legs, tail, and fully sheathed genital."
199
+ from_manifest:
200
+ enabled: true
201
+ seed: 42
202
+ profile: flux2
203
+ activation_token: Rook_Kaefer
204
+ species_token: felkin
205
+ negative_control_species: wolf
206
+ exchanges:
207
+ - [erection, fully_sheathed]
208
+
209
+ # Model and LoRA settings merged into the top-level SimpleTuner config.
210
+ model:
211
+ model_type: lora # Train a LoRA adapter.
212
+ model_family: flux2 # Use SimpleTuner's FLUX.2 model family.
213
+ model_flavour: klein-9b # Balanced 32GB+ run for the undistilled 9B base.
214
+ lora_rank: 64 # LoRA rank/capacity.
215
+ lora_alpha: 64 # LoRA alpha scaling.
216
+ lora_type: standard # Standard LoRA, not an alternate adapter type.
217
+ lora_format: comfyui # Ask SimpleTuner to save ComfyUI-style LoRA keys.
218
+ flux_lora_target: all # Train all Flux2 LoRA target modules.
219
+
220
+ # Base FLUX.2 Klein asset. Klein models use the bundled Qwen3 text
221
+ # encoder, so no separate T5/text-encoder path is set here.
222
+ pretrained_model_name_or_path: black-forest-labs/FLUX.2-klein-base-9B
223
+ pretrained_transformer_model_name_or_path: null
224
+ pretrained_transformer_subfolder: null
225
+ pretrained_unet_model_name_or_path: null
226
+ pretrained_vae_model_name_or_path: null
227
+ pretrained_t5_model_name_or_path: null
228
+ pretrained_text_encoder_model_name_or_path: null
229
+
230
+ # Precision defaults for FLUX.2 Klein LoRA training.
231
+ base_model_precision: no_change
232
+ base_model_default_dtype: bf16
233
+ mixed_precision: bf16
234
+ # init_lora: /path/to/existing.safetensors # Optional LoRA resume/init weights.
235
+ # lycoris_config: /path/to/lycoris.json # Optional LyCORIS config path.
236
+
237
+ # == Curricular warmup
238
+ subset_warmup:
239
+ enabled: true
240
+ subsets: [genitals, fullbody, head]
241
+ steps: 800 # !! First steps of the total run are ONLY listed subsets!
242
+
243
+ # Full-run trainer config. trainer_testrun below overrides selected keys
244
+ # only when knf lora sync/train is called with --testrun.
245
+ trainer:
246
+ tracker_project_name: kneifftools-lora-training # Experiment tracker project.
247
+ tracker_run_name: ladybird-f2k9b # Full-run tracker name.
248
+ hub_model_id: ladybird-f2k9b-lora # Optional Hub model id if push_to_hub is enabled.
249
+
250
+ optimizer: adamw_bf16 # BF16 AdamW optimizer.
251
+ learning_rate: 0.0001 # 1.2e-4; carried over from the earlier F2K run.
252
+ lr_scheduler: constant_with_warmup # Ramp up LR to avoid weird color biases.
253
+ lr_warmup_steps: 100
254
+ seed: 42 # Training seed.
255
+ gradient_checkpointing: true # Reduce VRAM by recomputing activations.
256
+ max_grad_norm: 1.0 # Clip gradients for stability.
257
+ grad_clip_method: norm # Clip by gradient norm.
258
+
259
+ train_batch_size: 2 # 32GB+ balanced per-device batch size.
260
+ gradient_accumulation_steps: 2 # Keep effective batch at 4 for 9B.
261
+ num_train_epochs: 0 # Step-based training; max_train_steps controls run length.
262
+ max_train_steps: 2600 # Full Flux2 Klein character run.
263
+ ignore_final_epochs: true # This fixes early stop due to weird epoch calculation by simpletuner
264
+
265
+ caption_dropout_probability: 0.0 # Disable caption dropout; keep trigger behavior stable.
266
+ data_backend_sampling: auto-weighting # Auto-balance dataloader sampling based on subset probabilities and sizes.
267
+
268
+ # push_to_hub: false # Upload final artifacts to Hugging Face Hub.
269
+ # push_checkpoints_to_hub: false # Upload intermediate checkpoints.
270
+ checkpoints_total_limit: 5 # Keep latest 5 checkpoints.
271
+ checkpoint_step_interval: 200 # Save checkpoint every 200 steps.
272
+ validation_step_interval: 200 # Run validation every 200 steps.
273
+ validation_on_startup: true # Render baseline validation before training.
274
+ validation_prompt_library: false # Disable SimpleTuner built-in prompt library.
275
+ validation_disable_unconditional: true # Skip unconditional validation branch.
276
+ validation_resolution: 1024x1024 # Keep validation affordable for the Flux2 run.
277
+ validation_num_inference_steps: 30 # Full-run validation sampling steps.
278
+ validation_guidance: 4.0 # Inference guidance used by validation.
279
+ validation_guidance_real: null # Remove Chroma default guidance-real from generated config.
280
+ validation_guidance_rescale: 0.0 # Guidance rescale; 0 disables rescale.
281
+ validation_seed: 42 # Deterministic validation seed.
282
+ num_eval_images: 1 # Images per validation prompt.
283
+ flux_guidance_mode: constant # Keep Flux2 validation guidance stable across prompts.
284
+ flux_guidance_value: 1.0 # Flux2 Klein guidance value from packaged template.
285
+
286
+ report_to: tensorboard # Write TensorBoard logs.
287
+ logging_dir: logs # TensorBoard log dir relative to TRAINING/<config-id>_<run>.
288
+
289
+ # Additional kneifftools-owned SimpleTuner defaults. Leave commented to
290
+ # use defaults from src/kneiff/training/lora/simpletuner.py.
291
+ # use_ema: false
292
+ # vae_batch_size: 1
293
+ # data_backend_sampling: uniform
294
+ # allow_dataset_oversubscription: true
295
+ # aspect_bucket_alignment: 64
296
+ tokenizer_max_length: 512
297
+ # t5_padding: zero
298
+ # fully_unload_text_encoder: true
299
+ # offload_during_startup: true
300
+ # keep_vae_loaded: false
301
+ # resume_from_checkpoint: /path/to/checkpoint
302
+
303
+ # Short smoke-run overrides. These merge last only with --testrun.
304
+ trainer_testrun:
305
+ validation_on_startup: false
306
+ tracker_run_name: ladybird-f2k9b-testrun # Separate tracker/log name for smoke runs.
307
+ output_dir: _simpletuner-output-testrun # Keep smoke checkpoints away from full run.
308
+ max_train_steps: 12 # Tiny run to verify plumbing.
309
+ checkpoint_step_interval: 12 # Save at the end of the smoke run.
310
+ validation_step_interval: 12 # Validate at the end of the smoke run.
311
+ validation_num_inference_steps: 12 # Faster validation for smoke runs.