awoo
Browse filesSigned-off-by: Balazs Horvath <[email protected]>
README.md
CHANGED
@@ -81,7 +81,6 @@ The Yiff Toolkit is a comprehensive set of tools designed to enhance your creati
|
|
81 |
- [`--sdpa` or `--xformers` or `--mem_eff_attn`](#--sdpa-or---xformers-or---mem_eff_attn)
|
82 |
- [`--multires_noise_iterations` and `--multires_noise_discount`](#--multires_noise_iterations-and---multires_noise_discount)
|
83 |
- [`--sample_prompts` and `--sample_sampler` and `--sample_every_n_steps`](#--sample_prompts-and---sample_sampler-and---sample_every_n_steps)
|
84 |
-
- [CosXL Training](#cosxl-training)
|
85 |
- [Embeddings for 1.5 and SDXL](#embeddings-for-15-and-sdxl)
|
86 |
- [ComfyUI Walkthrough any%](#comfyui-walkthrough-any)
|
87 |
- [AnimateDiff for Masochists](#animatediff-for-masochists)
|
@@ -444,6 +443,35 @@ for image_filename in image_files:
|
|
444 |
|
445 |
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!
|
446 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
447 |
---
|
448 |
|
449 |
### Pony Training
|
@@ -475,7 +503,7 @@ score_9, score_8_up, score_7_up, score_6_up, rating_explicit, source_furry, solo
|
|
475 |
|
476 |
Please note that sample prompts should not exceed 77 tokens, you can use [Count Tokens in Sample Prompts](https://huggingface.co/k4d3/yiff_toolkit/blob/main/dataset_tools/Count%20Tokens%20in%20Sample%20Prompts.ipynb) from [/dataset_tools](https://huggingface.co/k4d3/yiff_toolkit/tree/main/dataset_tools) to analyze your prompts.
|
477 |
|
478 |
-
If you are training with multiple GPUs, ensure that the total number of prompts is divisible by the number of GPUs without any remainder.
|
479 |
|
480 |
---
|
481 |
|
@@ -492,16 +520,21 @@ If you are training with multiple GPUs, ensure that the total number of prompts
|
|
492 |
For two GPUs:
|
493 |
|
494 |
```python
|
495 |
-
accelerate launch --num_processes=2 --multi_gpu --num_machines=1 --gpu_ids=0,1 --num_cpu_threads_per_process=2 "./sdxl_train_network.py"
|
496 |
```
|
497 |
|
498 |
Single GPU:
|
499 |
|
500 |
```python
|
501 |
-
accelerate launch --
|
502 |
```
|
503 |
|
504 |
---
|
|
|
|
|
|
|
|
|
|
|
505 |
|
506 |
##### `--lowram`
|
507 |
|
@@ -514,7 +547,7 @@ If you are running running out of system memory like I do with 2 GPUs and a real
|
|
514 |
The directory containing the checkpoint you just downloaded. I recommend closing the path if you are using a local diffusers model with a `/`. You can also specify a `.safetensors` or `.ckpt` if that is what you have!
|
515 |
|
516 |
```python
|
517 |
-
--pretrained_model_name_or_path="/ponydiffusers/"
|
518 |
```
|
519 |
|
520 |
---
|
@@ -524,7 +557,7 @@ The directory containing the checkpoint you just downloaded. I recommend closing
|
|
524 |
This is where all the saved epochs or steps will be saved, including the last one. If y
|
525 |
|
526 |
```python
|
527 |
-
--output_dir="/output_dir"
|
528 |
```
|
529 |
|
530 |
---
|
@@ -534,7 +567,7 @@ This is where all the saved epochs or steps will be saved, including the last on
|
|
534 |
The directory containing the dataset. We prepared this earlier together.
|
535 |
|
536 |
```python
|
537 |
-
--train_data_dir="/training_dir"
|
538 |
```
|
539 |
|
540 |
---
|
@@ -544,7 +577,7 @@ The directory containing the dataset. We prepared this earlier together.
|
|
544 |
Always set this to match the model's resolution, which in Pony's case it is 1024x1024. If you can't fit into the VRAM, you can decrease it to `512,512` as a last resort.
|
545 |
|
546 |
```python
|
547 |
-
--resolution="1024,1024"
|
548 |
```
|
549 |
|
550 |
---
|
@@ -553,10 +586,6 @@ Always set this to match the model's resolution, which in Pony's case it is 1024
|
|
553 |
|
554 |
Creates different buckets by pre-categorizing images with different aspect ratios into different buckets. This technique helps to avoid issues like unnatural crops that are common when models are trained to produce square images. This allows the creation of batches where every item has the same size, but the image size of batches may differ.
|
555 |
|
556 |
-
```python
|
557 |
-
--enable_bucket \
|
558 |
-
```
|
559 |
-
|
560 |
---
|
561 |
|
562 |
##### `--min_bucket_reso` and `--max_bucket_reso`
|
@@ -564,8 +593,7 @@ Creates different buckets by pre-categorizing images with different aspect ratio
|
|
564 |
Specifies the minimum and maximum resolutions used by the buckets. These values are ignored if `--bucket_no_upscale` is set.
|
565 |
|
566 |
```python
|
567 |
-
--min_bucket_reso=256
|
568 |
-
--max_bucket_reso=1024 \
|
569 |
```
|
570 |
|
571 |
---
|
@@ -575,7 +603,7 @@ Specifies the minimum and maximum resolutions used by the buckets. These values
|
|
575 |
Specifies how many of the trained Network Ranks are allowed to alter the base model.
|
576 |
|
577 |
```python
|
578 |
-
--network_alpha=4
|
579 |
```
|
580 |
|
581 |
---
|
@@ -585,7 +613,7 @@ Specifies how many of the trained Network Ranks are allowed to alter the base mo
|
|
585 |
You can use this to specify either `ckpt` or `safetensors` for the file format.
|
586 |
|
587 |
```python
|
588 |
-
--save_model_as=safetensors
|
589 |
```
|
590 |
|
591 |
---
|
@@ -595,7 +623,7 @@ You can use this to specify either `ckpt` or `safetensors` for the file format.
|
|
595 |
Specifies which network module you are going to train.
|
596 |
|
597 |
```python
|
598 |
-
--network_module=lycoris.kohya
|
599 |
```
|
600 |
|
601 |
---
|
@@ -824,9 +852,7 @@ The learning rate determines how much the weights of the network are updated in
|
|
824 |
For AdamW the optimal LR seems to be `0.0001` or `1e-4` if you want to impress your friends.
|
825 |
|
826 |
```py
|
827 |
-
--learning_rate=0.0001
|
828 |
-
--unet_lr=0.0001 \
|
829 |
-
--text_encoder_lr=0.0001 \
|
830 |
```
|
831 |
|
832 |
---
|
@@ -836,7 +862,7 @@ For AdamW the optimal LR seems to be `0.0001` or `1e-4` if you want to impress y
|
|
836 |
The Network Rank (Dimension) is responsible for how many features your LoRA will be training. It is in a close relation with Network Alpha and the Unet + TE learning rates and of course the quality of your dataset. Personal experimentation with these values is strongly recommended.
|
837 |
|
838 |
```py
|
839 |
-
--network_dim=8
|
840 |
```
|
841 |
|
842 |
---
|
@@ -848,7 +874,7 @@ Specify the output name excluding the file extension.
|
|
848 |
**WARNING**: If for some reason this is ever left empty your last epoch won't be saved!
|
849 |
|
850 |
```py
|
851 |
-
--output_name="last"
|
852 |
```
|
853 |
|
854 |
---
|
@@ -860,7 +886,7 @@ Max-norm regularization is a technique that constrains the norm of the incoming
|
|
860 |
Dropout affects the network architecture without changing the weights, while Max-Norm Regularization directly modifies the weights of the network. Both techniques are used to prevent overfitting and improve the generalization of the model. You can learn more about both in this [research paper](https://www.cs.toronto.edu/~rsalakhu/papers/srivastava14a.pdf).
|
861 |
|
862 |
```py
|
863 |
-
--scale_weight_norms=1.0
|
864 |
```
|
865 |
|
866 |
---
|
@@ -870,7 +896,7 @@ Dropout affects the network architecture without changing the weights, while Max
|
|
870 |
Also known as Gradient Clipping, if you notice that gradients are exploding during training (loss becomes NaN or very large), consider adjusting the `--max_grad_norm` parameter, it operates on the gradients during the backpropagation process, while `--scale_weight_norms` operates on the weights of the neural network. This allows them to complement each other and provide a more robust approach to stabilizing the learning process and improving model performance.
|
871 |
|
872 |
```py
|
873 |
-
--max_grad_norm=1.0
|
874 |
```
|
875 |
|
876 |
---
|
@@ -879,10 +905,6 @@ Also known as Gradient Clipping, if you notice that gradients are exploding duri
|
|
879 |
|
880 |
Disables mixed precision for the SDXL VAE and sets it to `float32`. Very useful if you don't like NaNs.
|
881 |
|
882 |
-
```py
|
883 |
-
--no_half_vae \
|
884 |
-
```
|
885 |
-
|
886 |
---
|
887 |
|
888 |
##### `--save_every_n_epochs` and `--save_last_n_epochs` or `--save_every_n_steps` and `--save_last_n_steps`
|
@@ -893,7 +915,7 @@ Disables mixed precision for the SDXL VAE and sets it to `float32`. Very useful
|
|
893 |
Learning will always end with what you specify in `--max_train_epochs` or `--max_train_steps`.
|
894 |
|
895 |
```py
|
896 |
-
--save_every_n_epochs=50
|
897 |
```
|
898 |
|
899 |
---
|
@@ -903,7 +925,7 @@ Learning will always end with what you specify in `--max_train_epochs` or `--max
|
|
903 |
⚠️
|
904 |
|
905 |
```py
|
906 |
-
--mixed_precision="fp16"
|
907 |
```
|
908 |
|
909 |
---
|
@@ -913,7 +935,7 @@ Learning will always end with what you specify in `--max_train_epochs` or `--max
|
|
913 |
⚠️
|
914 |
|
915 |
```py
|
916 |
-
--save_precision="fp16"
|
917 |
```
|
918 |
|
919 |
---
|
@@ -923,7 +945,7 @@ Learning will always end with what you specify in `--max_train_epochs` or `--max
|
|
923 |
⚠️
|
924 |
|
925 |
```py
|
926 |
-
--caption_extension=".txt"
|
927 |
```
|
928 |
|
929 |
##### `--cache_latents` and `--cache_latents_to_disk`
|
@@ -931,8 +953,7 @@ Learning will always end with what you specify in `--max_train_epochs` or `--max
|
|
931 |
⚠️
|
932 |
|
933 |
```py
|
934 |
-
--cache_latents
|
935 |
-
--cache_latents_to_disk \
|
936 |
```
|
937 |
|
938 |
---
|
@@ -942,7 +963,7 @@ Learning will always end with what you specify in `--max_train_epochs` or `--max
|
|
942 |
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!
|
943 |
|
944 |
```py
|
945 |
-
--optimizer_type="AdamW"
|
946 |
```
|
947 |
|
948 |
---
|
@@ -952,7 +973,7 @@ The default optimizer is `AdamW` and there are a bunch of them added every month
|
|
952 |
Repeats the dataset when training with captions, by default it is set to `1` so we'll set this to `0` with:
|
953 |
|
954 |
```py
|
955 |
-
--dataset_repeats=0
|
956 |
```
|
957 |
|
958 |
---
|
@@ -962,7 +983,7 @@ Repeats the dataset when training with captions, by default it is set to `1` so
|
|
962 |
Specify the number of steps or epochs to train. If both `--max_train_steps` and `--max_train_epochs` are specified, the number of epochs takes precedence.
|
963 |
|
964 |
```py
|
965 |
-
--max_train_steps=400
|
966 |
```
|
967 |
|
968 |
---
|
@@ -990,8 +1011,7 @@ The choice between `--xformers` or `--mem_eff_attn` and `--spda` will depend on
|
|
990 |
⚠️
|
991 |
|
992 |
```python
|
993 |
-
--multires_noise_iterations=10
|
994 |
-
--multires_noise_discount=0.1 \
|
995 |
```
|
996 |
|
997 |
---
|
@@ -1003,9 +1023,7 @@ You have the option of generating images during training so you can check the pr
|
|
1003 |
You can also use `--sample_every_n_epochs` instead which will take precedence over steps. The `k_` prefix means karras and the `_a` suffix means ancestral.
|
1004 |
|
1005 |
```py
|
1006 |
-
--sample_prompts=/training_dir/sample-prompts.txt
|
1007 |
-
--sample_sampler="euler_a" \
|
1008 |
-
--sample_every_n_steps=100
|
1009 |
```
|
1010 |
|
1011 |
My recommendation for Pony is to use `euler_a` for toony and for realistic `k_dpm_2`.
|
@@ -1021,18 +1039,71 @@ ddim, pndm, lms, euler, euler_a, heun, dpm_2, dpm_2_a, dpmsolver, dpmsolver++, d
|
|
1021 |
So, the whole thing would look something like this:
|
1022 |
|
1023 |
```python
|
1024 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1025 |
```
|
1026 |
|
1027 |
</details>
|
1028 |
</div>
|
1029 |
|
1030 |
-
### CosXL Training
|
1031 |
-
|
1032 |
-
<!--
|
1033 |
-
The only difference between CosXL training is that you need to enable `--v_parameterization`, and you can't sample the images. 😹 I also don't recommend using the `block_dims` and `block_alphas` from Pony.
|
1034 |
-
-->
|
1035 |
-
|
1036 |
---
|
1037 |
|
1038 |
## Embeddings for 1.5 and SDXL
|
|
|
81 |
- [`--sdpa` or `--xformers` or `--mem_eff_attn`](#--sdpa-or---xformers-or---mem_eff_attn)
|
82 |
- [`--multires_noise_iterations` and `--multires_noise_discount`](#--multires_noise_iterations-and---multires_noise_discount)
|
83 |
- [`--sample_prompts` and `--sample_sampler` and `--sample_every_n_steps`](#--sample_prompts-and---sample_sampler-and---sample_every_n_steps)
|
|
|
84 |
- [Embeddings for 1.5 and SDXL](#embeddings-for-15-and-sdxl)
|
85 |
- [ComfyUI Walkthrough any%](#comfyui-walkthrough-any)
|
86 |
- [AnimateDiff for Masochists](#animatediff-for-masochists)
|
|
|
443 |
|
444 |
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!
|
445 |
|
446 |
+
Ok, just in case you aren't smart enough how to install the sd-scripts under Miniconda for Windows I actually "guided" someone recently, just so I can tell you about it:
|
447 |
+
|
448 |
+
```bash
|
449 |
+
# Installing sd-scripts
|
450 |
+
git clone https://github.com/kohya-ss/sd-scripts
|
451 |
+
cd sd-scripts
|
452 |
+
|
453 |
+
# Creating the conda environment and installing requirements
|
454 |
+
conda create -n sdscripts python=3.10.14
|
455 |
+
conda activate sdscripts
|
456 |
+
conda install pytorch torchvision torchaudio pytorch-cuda=12.1 -c pytorch -c nvidia
|
457 |
+
python -m pip install --use-pep517 --upgrade -r requirements.txt
|
458 |
+
python -m pip install --use-pep517 lycoris_lora
|
459 |
+
accelerate config
|
460 |
+
```
|
461 |
+
|
462 |
+
`accelerate config` will ask you a bunch of questions, you need to actually read each one and reply with the truth. In most cases the truth looks like this: `This machine, No distributed training, no, no, no, all, fp16`.
|
463 |
+
|
464 |
+
You might also want to install `xformers` or `bitsandbytes`.
|
465 |
+
|
466 |
+
```bash
|
467 |
+
# Installing xformers
|
468 |
+
# Use the same command just replace 'xformers' with any other package you may need.
|
469 |
+
python -m pip install --use-pep517 xformers
|
470 |
+
|
471 |
+
# Installing bitsandbytes for windows
|
472 |
+
python -m pip install --use-pep517 bitsandbytes --index-url=https://jllllll.github.io/bitsandbytes-windows-webui
|
473 |
+
```
|
474 |
+
|
475 |
---
|
476 |
|
477 |
### Pony Training
|
|
|
503 |
|
504 |
Please note that sample prompts should not exceed 77 tokens, you can use [Count Tokens in Sample Prompts](https://huggingface.co/k4d3/yiff_toolkit/blob/main/dataset_tools/Count%20Tokens%20in%20Sample%20Prompts.ipynb) from [/dataset_tools](https://huggingface.co/k4d3/yiff_toolkit/tree/main/dataset_tools) to analyze your prompts.
|
505 |
|
506 |
+
If you are training with multiple GPUs, ensure that the total number of prompts is divisible by the number of GPUs without any remainder or a card will idle.
|
507 |
|
508 |
---
|
509 |
|
|
|
520 |
For two GPUs:
|
521 |
|
522 |
```python
|
523 |
+
accelerate launch --num_processes=2 --multi_gpu --num_machines=1 --gpu_ids=0,1 --num_cpu_threads_per_process=2 "./sdxl_train_network.py"
|
524 |
```
|
525 |
|
526 |
Single GPU:
|
527 |
|
528 |
```python
|
529 |
+
accelerate launch --num_cpu_threads_per_process=2 "./sdxl_train_network.py"
|
530 |
```
|
531 |
|
532 |
---
|
533 |
+
|
534 |
+
|
535 |
+
And now lets break down a bunch of arguments we can pass to `sd-scripts`.
|
536 |
+
|
537 |
+
|
538 |
|
539 |
##### `--lowram`
|
540 |
|
|
|
547 |
The directory containing the checkpoint you just downloaded. I recommend closing the path if you are using a local diffusers model with a `/`. You can also specify a `.safetensors` or `.ckpt` if that is what you have!
|
548 |
|
549 |
```python
|
550 |
+
--pretrained_model_name_or_path="/ponydiffusers/"
|
551 |
```
|
552 |
|
553 |
---
|
|
|
557 |
This is where all the saved epochs or steps will be saved, including the last one. If y
|
558 |
|
559 |
```python
|
560 |
+
--output_dir="/output_dir"
|
561 |
```
|
562 |
|
563 |
---
|
|
|
567 |
The directory containing the dataset. We prepared this earlier together.
|
568 |
|
569 |
```python
|
570 |
+
--train_data_dir="/training_dir"
|
571 |
```
|
572 |
|
573 |
---
|
|
|
577 |
Always set this to match the model's resolution, which in Pony's case it is 1024x1024. If you can't fit into the VRAM, you can decrease it to `512,512` as a last resort.
|
578 |
|
579 |
```python
|
580 |
+
--resolution="1024,1024"
|
581 |
```
|
582 |
|
583 |
---
|
|
|
586 |
|
587 |
Creates different buckets by pre-categorizing images with different aspect ratios into different buckets. This technique helps to avoid issues like unnatural crops that are common when models are trained to produce square images. This allows the creation of batches where every item has the same size, but the image size of batches may differ.
|
588 |
|
|
|
|
|
|
|
|
|
589 |
---
|
590 |
|
591 |
##### `--min_bucket_reso` and `--max_bucket_reso`
|
|
|
593 |
Specifies the minimum and maximum resolutions used by the buckets. These values are ignored if `--bucket_no_upscale` is set.
|
594 |
|
595 |
```python
|
596 |
+
--min_bucket_reso=256 --max_bucket_reso=1024
|
|
|
597 |
```
|
598 |
|
599 |
---
|
|
|
603 |
Specifies how many of the trained Network Ranks are allowed to alter the base model.
|
604 |
|
605 |
```python
|
606 |
+
--network_alpha=4
|
607 |
```
|
608 |
|
609 |
---
|
|
|
613 |
You can use this to specify either `ckpt` or `safetensors` for the file format.
|
614 |
|
615 |
```python
|
616 |
+
--save_model_as="safetensors"
|
617 |
```
|
618 |
|
619 |
---
|
|
|
623 |
Specifies which network module you are going to train.
|
624 |
|
625 |
```python
|
626 |
+
--network_module="lycoris.kohya"
|
627 |
```
|
628 |
|
629 |
---
|
|
|
852 |
For AdamW the optimal LR seems to be `0.0001` or `1e-4` if you want to impress your friends.
|
853 |
|
854 |
```py
|
855 |
+
--learning_rate=0.0001 --unet_lr=0.0001 --text_encoder_lr=0.0001
|
|
|
|
|
856 |
```
|
857 |
|
858 |
---
|
|
|
862 |
The Network Rank (Dimension) is responsible for how many features your LoRA will be training. It is in a close relation with Network Alpha and the Unet + TE learning rates and of course the quality of your dataset. Personal experimentation with these values is strongly recommended.
|
863 |
|
864 |
```py
|
865 |
+
--network_dim=8
|
866 |
```
|
867 |
|
868 |
---
|
|
|
874 |
**WARNING**: If for some reason this is ever left empty your last epoch won't be saved!
|
875 |
|
876 |
```py
|
877 |
+
--output_name="last"
|
878 |
```
|
879 |
|
880 |
---
|
|
|
886 |
Dropout affects the network architecture without changing the weights, while Max-Norm Regularization directly modifies the weights of the network. Both techniques are used to prevent overfitting and improve the generalization of the model. You can learn more about both in this [research paper](https://www.cs.toronto.edu/~rsalakhu/papers/srivastava14a.pdf).
|
887 |
|
888 |
```py
|
889 |
+
--scale_weight_norms=1.0
|
890 |
```
|
891 |
|
892 |
---
|
|
|
896 |
Also known as Gradient Clipping, if you notice that gradients are exploding during training (loss becomes NaN or very large), consider adjusting the `--max_grad_norm` parameter, it operates on the gradients during the backpropagation process, while `--scale_weight_norms` operates on the weights of the neural network. This allows them to complement each other and provide a more robust approach to stabilizing the learning process and improving model performance.
|
897 |
|
898 |
```py
|
899 |
+
--max_grad_norm=1.0
|
900 |
```
|
901 |
|
902 |
---
|
|
|
905 |
|
906 |
Disables mixed precision for the SDXL VAE and sets it to `float32`. Very useful if you don't like NaNs.
|
907 |
|
|
|
|
|
|
|
|
|
908 |
---
|
909 |
|
910 |
##### `--save_every_n_epochs` and `--save_last_n_epochs` or `--save_every_n_steps` and `--save_last_n_steps`
|
|
|
915 |
Learning will always end with what you specify in `--max_train_epochs` or `--max_train_steps`.
|
916 |
|
917 |
```py
|
918 |
+
--save_every_n_epochs=50
|
919 |
```
|
920 |
|
921 |
---
|
|
|
925 |
⚠️
|
926 |
|
927 |
```py
|
928 |
+
--mixed_precision="fp16"
|
929 |
```
|
930 |
|
931 |
---
|
|
|
935 |
⚠️
|
936 |
|
937 |
```py
|
938 |
+
--save_precision="fp16"
|
939 |
```
|
940 |
|
941 |
---
|
|
|
945 |
⚠️
|
946 |
|
947 |
```py
|
948 |
+
--caption_extension=".txt"
|
949 |
```
|
950 |
|
951 |
##### `--cache_latents` and `--cache_latents_to_disk`
|
|
|
953 |
⚠️
|
954 |
|
955 |
```py
|
956 |
+
--cache_latents --cache_latents_to_disk
|
|
|
957 |
```
|
958 |
|
959 |
---
|
|
|
963 |
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!
|
964 |
|
965 |
```py
|
966 |
+
--optimizer_type="AdamW"
|
967 |
```
|
968 |
|
969 |
---
|
|
|
973 |
Repeats the dataset when training with captions, by default it is set to `1` so we'll set this to `0` with:
|
974 |
|
975 |
```py
|
976 |
+
--dataset_repeats=0
|
977 |
```
|
978 |
|
979 |
---
|
|
|
983 |
Specify the number of steps or epochs to train. If both `--max_train_steps` and `--max_train_epochs` are specified, the number of epochs takes precedence.
|
984 |
|
985 |
```py
|
986 |
+
--max_train_steps=400
|
987 |
```
|
988 |
|
989 |
---
|
|
|
1011 |
⚠️
|
1012 |
|
1013 |
```python
|
1014 |
+
--multires_noise_iterations=10 --multires_noise_discount=0.1
|
|
|
1015 |
```
|
1016 |
|
1017 |
---
|
|
|
1023 |
You can also use `--sample_every_n_epochs` instead which will take precedence over steps. The `k_` prefix means karras and the `_a` suffix means ancestral.
|
1024 |
|
1025 |
```py
|
1026 |
+
--sample_prompts=/training_dir/sample-prompts.txt --sample_sampler="euler_a" --sample_every_n_steps=100
|
|
|
|
|
1027 |
```
|
1028 |
|
1029 |
My recommendation for Pony is to use `euler_a` for toony and for realistic `k_dpm_2`.
|
|
|
1039 |
So, the whole thing would look something like this:
|
1040 |
|
1041 |
```python
|
1042 |
+
accelerate launch --num_cpu_threads_per_process=2 "./sdxl_train_network.py" \
|
1043 |
+
--lowram \
|
1044 |
+
--pretrained_model_name_or_path="/ponydiffusers/" \
|
1045 |
+
--train_data_dir="/training_dir" \
|
1046 |
+
--resolution="1024,1024" \
|
1047 |
+
--output_dir="/output_dir" \
|
1048 |
+
--enable_bucket \
|
1049 |
+
--min_bucket_reso=256 \
|
1050 |
+
--max_bucket_reso=1024 \
|
1051 |
+
--network_alpha=4 \
|
1052 |
+
--save_model_as="safetensors" \
|
1053 |
+
--network_module="lycoris.kohya" \
|
1054 |
+
--network_args \
|
1055 |
+
"use_reentrant=False" \
|
1056 |
+
"preset=full" \
|
1057 |
+
"conv_dim=256" \
|
1058 |
+
"conv_alpha=4" \
|
1059 |
+
"dropout=None" \
|
1060 |
+
"rank_dropout=None" \
|
1061 |
+
"module_dropout=None" \
|
1062 |
+
"use_tucker=False" \
|
1063 |
+
"use_scalar=False" \
|
1064 |
+
"rank_dropout_scale=False" \
|
1065 |
+
"algo=locon" \
|
1066 |
+
"train_norm=False" \
|
1067 |
+
"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" \
|
1068 |
+
"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" \
|
1069 |
+
--network_dropout=0 \
|
1070 |
+
--lr_scheduler="cosine" \
|
1071 |
+
--learning_rate=0.0001 \
|
1072 |
+
--unet_lr=0.0001 \
|
1073 |
+
--text_encoder_lr=0.0001 \
|
1074 |
+
--network_dim=8 \
|
1075 |
+
--output_name="yifftoolkit" \
|
1076 |
+
--scale_weight_norms=1 \
|
1077 |
+
--no_half_vae \
|
1078 |
+
--save_every_n_epochs=50 \
|
1079 |
+
--mixed_precision="fp16" \
|
1080 |
+
--save_precision="fp16" \
|
1081 |
+
--caption_extension=".txt" \
|
1082 |
+
--cache_latents \
|
1083 |
+
--cache_latents_to_disk \
|
1084 |
+
--optimizer_type="AdamW" \
|
1085 |
+
--max_grad_norm=1 \
|
1086 |
+
--keep_tokens=1 \
|
1087 |
+
--max_data_loader_n_workers=8 \
|
1088 |
+
--bucket_reso_steps=32 \
|
1089 |
+
--multires_noise_iterations=10 \
|
1090 |
+
--multires_noise_discount=0.1 \
|
1091 |
+
--log_prefix=xl-locon \
|
1092 |
+
--gradient_accumulation_steps=12 \
|
1093 |
+
--gradient_checkpointing \
|
1094 |
+
--train_batch_size=8 \
|
1095 |
+
--dataset_repeats=0 \
|
1096 |
+
--max_train_steps=400 \
|
1097 |
+
--shuffle_caption \
|
1098 |
+
--sdpa \
|
1099 |
+
--sample_prompts=/training_dir/sample-prompts.txt \
|
1100 |
+
--sample_sampler="euler_a" \
|
1101 |
+
--sample_every_n_steps=100
|
1102 |
```
|
1103 |
|
1104 |
</details>
|
1105 |
</div>
|
1106 |
|
|
|
|
|
|
|
|
|
|
|
|
|
1107 |
---
|
1108 |
|
1109 |
## Embeddings for 1.5 and SDXL
|