uh
Browse filesSigned-off-by: Balazs Horvath <[email protected]>
- README.md +273 -4
- static/tutorial/grabber1.png +3 -0
- static/tutorial/grabber2.png +3 -0
README.md
CHANGED
@@ -24,9 +24,12 @@ The Yiff Toolkit is a comprehensive set of tools designed to enhance your creati
|
|
24 |
|
25 |
- [Hotdogwolf's Yiff Toolkit](#hotdogwolfs-yiff-toolkit)
|
26 |
- [Table of Contents](#table-of-contents)
|
|
|
|
|
|
|
|
|
27 |
- [LoRA Training Guide](#lora-training-guide)
|
28 |
- [Installation Tips](#installation-tips)
|
29 |
-
- [Dataset Preparation](#dataset-preparation)
|
30 |
- [Pony Training](#pony-training)
|
31 |
- [Download Pony in Diffusers Format](#download-pony-in-diffusers-format)
|
32 |
- [Sample Prompt File](#sample-prompt-file)
|
@@ -38,6 +41,25 @@ The Yiff Toolkit is a comprehensive set of tools designed to enhance your creati
|
|
38 |
- [`--resolution`](#--resolution)
|
39 |
- [`--enable_bucket`](#--enable_bucket)
|
40 |
- [`--min_bucket_reso` and `--max_bucket_reso`](#--min_bucket_reso-and---max_bucket_reso)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
41 |
- [`--optimizer_type`](#--optimizer_type)
|
42 |
- [`--dataset_repeats`](#--dataset_repeats)
|
43 |
- [`--max_train_steps`](#--max_train_steps)
|
@@ -108,6 +130,47 @@ The Yiff Toolkit is a comprehensive set of tools designed to enhance your creati
|
|
108 |
</details>
|
109 |
</div>
|
110 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
111 |
## LoRA Training Guide
|
112 |
|
113 |
### Installation Tips
|
@@ -116,8 +179,6 @@ The Yiff Toolkit is a comprehensive set of tools designed to enhance your creati
|
|
116 |
|
117 |
Firstly, download kohya_ss' [sd-scripts](https://github.com/kohya-ss/sd-scripts), you need to set up your environment either like [this](https://github.com/kohya-ss/sd-scripts?tab=readme-ov-file#windows-installation) tells you for Windows, or if you are using Linux or Miniconda on Windows, you are probably smart enough to figure out the installation for it. I recommend always installing the latest [PyTorch](https://pytorch.org/get-started/locally/) in the virtual environment you are going to use, which at the time of writing is `2.2.2`. I hope future me has faster PyTorch!
|
118 |
|
119 |
-
### Dataset Preparation
|
120 |
-
|
121 |
---
|
122 |
|
123 |
⚠️ **TODO:** Awoo this section.
|
@@ -157,9 +218,13 @@ If you are training with multiple GPUs, ensure that the total number of prompts
|
|
157 |
|
158 |
#### Training Commands
|
159 |
|
|
|
|
|
|
|
|
|
160 |
##### `--lowram`
|
161 |
|
162 |
-
If you are running running out of
|
163 |
|
164 |
---
|
165 |
|
@@ -224,6 +289,207 @@ Always set this to match the model's resolution, which in Pony's case it is 1024
|
|
224 |
|
225 |
---
|
226 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
227 |
##### `--optimizer_type`
|
228 |
|
229 |
The default optimizer is `AdamW` and there are a bunch of them added every month or so, therefore I'm not listing them all, you can find the list if you really want, but `AdamW` is the best as of this writing so we use that!
|
@@ -294,6 +560,9 @@ ddim, pndm, lms, euler, euler_a, heun, dpm_2, dpm_2_a, dpmsolver, dpmsolver++, d
|
|
294 |
|
295 |
---
|
296 |
|
|
|
|
|
|
|
297 |
### CosXL Training
|
298 |
|
299 |
<!--
|
|
|
24 |
|
25 |
- [Hotdogwolf's Yiff Toolkit](#hotdogwolfs-yiff-toolkit)
|
26 |
- [Table of Contents](#table-of-contents)
|
27 |
+
- [Dataset Tools](#dataset-tools)
|
28 |
+
- [Dataset Preparation](#dataset-preparation)
|
29 |
+
- [Grabber](#grabber)
|
30 |
+
- [Manual Method](#manual-method)
|
31 |
- [LoRA Training Guide](#lora-training-guide)
|
32 |
- [Installation Tips](#installation-tips)
|
|
|
33 |
- [Pony Training](#pony-training)
|
34 |
- [Download Pony in Diffusers Format](#download-pony-in-diffusers-format)
|
35 |
- [Sample Prompt File](#sample-prompt-file)
|
|
|
41 |
- [`--resolution`](#--resolution)
|
42 |
- [`--enable_bucket`](#--enable_bucket)
|
43 |
- [`--min_bucket_reso` and `--max_bucket_reso`](#--min_bucket_reso-and---max_bucket_reso)
|
44 |
+
- [`--network_alpha`](#--network_alpha)
|
45 |
+
- [`--save_model_as`](#--save_model_as)
|
46 |
+
- [`--network_module`](#--network_module)
|
47 |
+
- [`--network_args`](#--network_args)
|
48 |
+
- [`--network_dropout`](#--network_dropout)
|
49 |
+
- [`--lr_scheduler`](#--lr_scheduler)
|
50 |
+
- [`--lr_scheduler_num_cycles`](#--lr_scheduler_num_cycles)
|
51 |
+
- [`--learning_rate`](#--learning_rate)
|
52 |
+
- [`--unet_lr`](#--unet_lr)
|
53 |
+
- [`--text_encoder_lr`](#--text_encoder_lr)
|
54 |
+
- [`--network_dim`](#--network_dim)
|
55 |
+
- [`--output_name`](#--output_name)
|
56 |
+
- [`--scale_weight_norms`](#--scale_weight_norms)
|
57 |
+
- [`--no_half_vae`](#--no_half_vae)
|
58 |
+
- [`--save_every_n_epochs`](#--save_every_n_epochs)
|
59 |
+
- [`--mixed_precision`](#--mixed_precision)
|
60 |
+
- [`--save_precision`](#--save_precision)
|
61 |
+
- [`--caption_extension`](#--caption_extension)
|
62 |
+
- [`--cache_latents` and `--cache_latents_to_disk`](#--cache_latents-and---cache_latents_to_disk)
|
63 |
- [`--optimizer_type`](#--optimizer_type)
|
64 |
- [`--dataset_repeats`](#--dataset_repeats)
|
65 |
- [`--max_train_steps`](#--max_train_steps)
|
|
|
130 |
</details>
|
131 |
</div>
|
132 |
|
133 |
+
## Dataset Tools
|
134 |
+
|
135 |
+
I have uploaded all of the little handy Python scripts I use to [/dataset_tools](https://huggingface.co/k4d3/yiff_toolkit/tree/main/dataset_tools). They are pretty self explanatory by just the file name but almost all of them contain an AI generated description. If you want to use them you will need to edit the path to your `training_dir` folder, the variable will be called `path` or `directory` and look something like this:
|
136 |
+
|
137 |
+
```py
|
138 |
+
def main():
|
139 |
+
path = 'C:\\Users\\kade\\Desktop\\training_dir_staging'
|
140 |
+
```
|
141 |
+
|
142 |
+
Don't be afraid of editing Python scripts, unlike the real snake, these won't bite!
|
143 |
+
|
144 |
+
---
|
145 |
+
|
146 |
+
## Dataset Preparation
|
147 |
+
|
148 |
+
Before you begin collecting your dataset you will need to decide what you want to teach the model, it can be a character, a style or a new concept.
|
149 |
+
|
150 |
+
For now let's imagine you want to teach your model *wicerbeasts* so you can generate your VRChat avatar every night. For this we'll make good use of the furry <abbr title="image board">booru</abbr> [e621.net](https://e621.net/). There are two nice ways to download data from this site with the metadata intact, I'll start with the fastest and then I will explain how you can selectively browse around the site and get the images you like one by one.
|
151 |
+
|
152 |
+
### Grabber
|
153 |
+
|
154 |
+
[Grabber](https://github.com/Bionus/imgbrd-grabber) makes your life easier when trying to compile datasets quickly.
|
155 |
+
|
156 |
+
[![A screenshot of Grabber.](https://huggingface.co/k4d3/yiff_toolkit/resolve/main/static/tutorial/grabber1.png)](https://huggingface.co/k4d3/yiff_toolkit/resolve/main/static/tutorial/grabber1.png)
|
157 |
+
|
158 |
+
Clicking on the `Add` button
|
159 |
+
At the Download tab, `Tags` will be the column you can type in
|
160 |
+
`wickerbeast solo -meme -animated order:score`
|
161 |
+
|
162 |
+
You should also enable `Separate log files` for e621, this will download the metadata automatically alongside the pictures.
|
163 |
+
|
164 |
+
[![Another screenshot of Grabber.](https://huggingface.co/k4d3/yiff_toolkit/resolve/main/static/tutorial/grabber2.png)](https://huggingface.co/k4d3/yiff_toolkit/resolve/main/static/tutorial/grabber2.png)
|
165 |
+
|
166 |
+
For Pony I've set up the Text file content like so: `rating_%rating%, %all:separator=^, %` for other models you might want to replace `rating_%rating%` with just `%rating%`.
|
167 |
+
|
168 |
+
---
|
169 |
+
|
170 |
+
### Manual Method
|
171 |
+
|
172 |
+
---
|
173 |
+
|
174 |
## LoRA Training Guide
|
175 |
|
176 |
### Installation Tips
|
|
|
179 |
|
180 |
Firstly, download kohya_ss' [sd-scripts](https://github.com/kohya-ss/sd-scripts), you need to set up your environment either like [this](https://github.com/kohya-ss/sd-scripts?tab=readme-ov-file#windows-installation) tells you for Windows, or if you are using Linux or Miniconda on Windows, you are probably smart enough to figure out the installation for it. I recommend always installing the latest [PyTorch](https://pytorch.org/get-started/locally/) in the virtual environment you are going to use, which at the time of writing is `2.2.2`. I hope future me has faster PyTorch!
|
181 |
|
|
|
|
|
182 |
---
|
183 |
|
184 |
⚠️ **TODO:** Awoo this section.
|
|
|
218 |
|
219 |
#### Training Commands
|
220 |
|
221 |
+
<div style="background-color: lightyellow; padding: 10px;">
|
222 |
+
<details>
|
223 |
+
<summary>Click to reveal training commands.</summary>
|
224 |
+
|
225 |
##### `--lowram`
|
226 |
|
227 |
+
If you are running running out of system memory like I do with 2 GPUs and a really fat model that gets loaded into it per GPU, this option will help you save a bit of it and might get you out of OOM hell.
|
228 |
|
229 |
---
|
230 |
|
|
|
289 |
|
290 |
---
|
291 |
|
292 |
+
##### `--network_alpha`
|
293 |
+
|
294 |
+
⚠️
|
295 |
+
|
296 |
+
```py
|
297 |
+
--network_alpha=4 \
|
298 |
+
```
|
299 |
+
|
300 |
+
---
|
301 |
+
|
302 |
+
##### `--save_model_as`
|
303 |
+
|
304 |
+
⚠️
|
305 |
+
|
306 |
+
```py
|
307 |
+
--save_model_as=safetensors \
|
308 |
+
```
|
309 |
+
|
310 |
+
---
|
311 |
+
|
312 |
+
##### `--network_module`
|
313 |
+
|
314 |
+
⚠️
|
315 |
+
|
316 |
+
```py
|
317 |
+
--network_module=lycoris.kohya \
|
318 |
+
```
|
319 |
+
|
320 |
+
---
|
321 |
+
|
322 |
+
##### `--network_args`
|
323 |
+
|
324 |
+
⚠️
|
325 |
+
|
326 |
+
```py
|
327 |
+
--network_args \
|
328 |
+
"preset=full" \
|
329 |
+
"conv_dim=256" \
|
330 |
+
"conv_alpha=4" \
|
331 |
+
"rank_dropout=0" \
|
332 |
+
"module_dropout=0" \
|
333 |
+
"use_tucker=False" \
|
334 |
+
"use_scalar=False" \
|
335 |
+
"rank_dropout_scale=False" \
|
336 |
+
"algo=locon" \
|
337 |
+
"train_norm=False" \
|
338 |
+
"block_dims=8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8" \
|
339 |
+
"block_alphas=0.0625,0.0625,0.0625,0.0625,0.0625,0.0625,0.0625,0.0625,0.0625,0.0625,0.0625,0.0625,0.0625,0.0625,0.0625,0.0625,0.0625,0.0625,0.0625,0.0625,0.0625,0.0625,0.0625,0.0625,0.0625" \
|
340 |
+
```
|
341 |
+
|
342 |
+
---
|
343 |
+
|
344 |
+
##### `--network_dropout`
|
345 |
+
|
346 |
+
⚠️
|
347 |
+
|
348 |
+
```py
|
349 |
+
--network_dropout=0 \
|
350 |
+
```
|
351 |
+
|
352 |
+
---
|
353 |
+
|
354 |
+
##### `--lr_scheduler`
|
355 |
+
|
356 |
+
⚠️
|
357 |
+
|
358 |
+
```py
|
359 |
+
--lr_scheduler="cosine" \
|
360 |
+
```
|
361 |
+
|
362 |
+
---
|
363 |
+
|
364 |
+
##### `--lr_scheduler_num_cycles`
|
365 |
+
|
366 |
+
⚠️
|
367 |
+
|
368 |
+
```py
|
369 |
+
--lr_scheduler_num_cycles=1 \
|
370 |
+
```
|
371 |
+
|
372 |
+
---
|
373 |
+
|
374 |
+
##### `--learning_rate`
|
375 |
+
|
376 |
+
⚠️
|
377 |
+
|
378 |
+
```py
|
379 |
+
--learning_rate=0.0001 \
|
380 |
+
```
|
381 |
+
|
382 |
+
---
|
383 |
+
|
384 |
+
##### `--unet_lr`
|
385 |
+
|
386 |
+
⚠️
|
387 |
+
|
388 |
+
```py
|
389 |
+
--unet_lr=0.0001 \
|
390 |
+
```
|
391 |
+
|
392 |
+
---
|
393 |
+
|
394 |
+
##### `--text_encoder_lr`
|
395 |
+
|
396 |
+
⚠️
|
397 |
+
|
398 |
+
```py
|
399 |
+
--text_encoder_lr=0.0001 \
|
400 |
+
```
|
401 |
+
|
402 |
+
---
|
403 |
+
|
404 |
+
##### `--network_dim`
|
405 |
+
|
406 |
+
⚠️
|
407 |
+
|
408 |
+
```py
|
409 |
+
--network_dim=8 \
|
410 |
+
```
|
411 |
+
|
412 |
+
---
|
413 |
+
|
414 |
+
##### `--output_name`
|
415 |
+
|
416 |
+
⚠️
|
417 |
+
|
418 |
+
```py
|
419 |
+
--output_name="last" \
|
420 |
+
```
|
421 |
+
|
422 |
+
---
|
423 |
+
|
424 |
+
##### `--scale_weight_norms`
|
425 |
+
|
426 |
+
⚠️
|
427 |
+
|
428 |
+
```py
|
429 |
+
--scale_weight_norms=1 \
|
430 |
+
```
|
431 |
+
|
432 |
+
---
|
433 |
+
|
434 |
+
##### `--no_half_vae`
|
435 |
+
|
436 |
+
⚠️
|
437 |
+
|
438 |
+
```py
|
439 |
+
--no_half_vae \
|
440 |
+
```
|
441 |
+
|
442 |
+
---
|
443 |
+
|
444 |
+
##### `--save_every_n_epochs`
|
445 |
+
|
446 |
+
⚠️
|
447 |
+
|
448 |
+
```py
|
449 |
+
--save_every_n_epochs=10 \
|
450 |
+
```
|
451 |
+
|
452 |
+
---
|
453 |
+
|
454 |
+
##### `--mixed_precision`
|
455 |
+
|
456 |
+
⚠️
|
457 |
+
|
458 |
+
```py
|
459 |
+
--mixed_precision="fp16" \
|
460 |
+
```
|
461 |
+
|
462 |
+
---
|
463 |
+
|
464 |
+
##### `--save_precision`
|
465 |
+
|
466 |
+
⚠️
|
467 |
+
|
468 |
+
```py
|
469 |
+
--save_precision="fp16" \
|
470 |
+
```
|
471 |
+
|
472 |
+
---
|
473 |
+
|
474 |
+
##### `--caption_extension`
|
475 |
+
|
476 |
+
⚠️
|
477 |
+
|
478 |
+
```py
|
479 |
+
--caption_extension=".txt" \
|
480 |
+
```
|
481 |
+
|
482 |
+
##### `--cache_latents` and `--cache_latents_to_disk`
|
483 |
+
|
484 |
+
⚠️
|
485 |
+
|
486 |
+
```py
|
487 |
+
--cache_latents \
|
488 |
+
--cache_latents_to_disk \
|
489 |
+
```
|
490 |
+
|
491 |
+
---
|
492 |
+
|
493 |
##### `--optimizer_type`
|
494 |
|
495 |
The default optimizer is `AdamW` and there are a bunch of them added every month or so, therefore I'm not listing them all, you can find the list if you really want, but `AdamW` is the best as of this writing so we use that!
|
|
|
560 |
|
561 |
---
|
562 |
|
563 |
+
</details>
|
564 |
+
</div>
|
565 |
+
|
566 |
### CosXL Training
|
567 |
|
568 |
<!--
|
static/tutorial/grabber1.png
ADDED
Git LFS Details
|
static/tutorial/grabber2.png
ADDED
Git LFS Details
|