Adapted from https://note.com/kohya_ss/n/nbf7ce8d80f29 for easier cloning
Jupyter Notebook
1,902
612 commits
updated May 14, 2024
Github Repository for kohya-ss/sd-scripts colab notebook implementation
| Notebook Name | Description | Link | V14 |
|---|---|---|---|
| Kohya LoRA Dreambooth | LoRA Training (Dreambooth method) | ||
| Kohya LoRA Fine-Tuning | LoRA Training (Fine-tune method) | ||
| Kohya Trainer | Native Training | ||
| Kohya Dreambooth | Dreambooth Training | ||
Cagliostro Colab UI NEW | A Customizable Stable Diffusion Web UI |
What Changes?
class_token undefined if activation_word = 1 word https://github.com/Linaqruf/kohya-trainer/issues/198
token_to_captions function, because it's complicated and also it has the same function with 4.2.3. Custom Caption/TagWhat Changes?
(,)3.3. Image Scraper (Optional):
parameter that should be default, e.g. user_agenttags1 and tags2 field, and changed it to prompt. Now user can type their desired tags more than 2 (except: danbooru) by separating each tag with a comma (,)sub_folder to scrape images to desired path, useful for multi-concept or multi-directories training.
train_data_dirtrain_data_dir + sub_foldersub_folderrange to limit the number of images to scrape. How to use it: Add 1-200 to download 200 images. Newest Images in the server are prioritized.recursive option to 4.1. Data Cleaning, to clean unsupported files and convert RGBA to RGB recursively. Useful for multi-concept or multi-directories training.4.2.1. BLIP Captioning:
recursive option to 4.2.1. BLIP Captioning, to generate captions recursively, by checking sub-directories as well. Useful for multi-concept or multi-directories training.--debug or verbose_logging in 4.2.1. BLIP Captioning On by default.Waifu Diffusion 1.4 Tagger V2:
--remove_underscore args to the WD Tagger script.0) but also character tags (category = 4)--character_threshold parameter (default = 0.35)--thresh to --general_threshold (default = 0.35)--undesired_words args to not add specified words when interrogating images, separate each word by comma, e.g. 1girl, scenery--debug works, new template : {filename}
Character Tags = {character_tags}
General Tags = {general_tags}
--debug or verbose_logging On by default.--frequency_tags to print tags frequencyrecursive option to generate tags recursively, by checking sub-directories as well. Useful for multi-concept or multi-directories training.4.2.3. Custom Caption/Tag:
append() to add tags to the end of lines.insert() to add tags to the beginning of lines.remove() to remove tags separated by comma.Cheatsheet from v14.6 is outdated, now user can easily add or remove tags
"_" or " " doesn't matter anymore"_" will still be replaced with " "1girl to custom_tags then run, if you set append, it will be added to the end of lines instead.(,), e.g. 1girl, garden, school uniforminsert(), the result will be backward instead: school uniform, garden, 1girlcustom_tags to your desired words and set remove_tagssub_folder option, useful for multi-concept or multi-directories training.
--all it will process directory and subdirectories in train_data_dir recursively.train_data_dirtrain_data_dir + sub_foldersub_folderrecursive option to 4.3. Merge Annotation Into JSON and Create Buckets & Convert to Latents5.2. Dataset Config:
instance_token and class_token and changed into activation wordsupported_extensions exist (".png", ".jpg", ".jpeg", ".webp", ".bmp") it will add the path to [[dataset.subsets]] in dataset_config.tomltrain_data_dir like old version, and you can also normally set train_data_dir.<num_repeats>_<class_token>
10_mikapikazo, 10 will be added as num_repeats and mikapikazo will be added to class_token in dataset_config.tomlnum_repeats from dataset_repeats and class_token from activation_wordtoken_to_captions
activation_word to captions/tags<class_token> from folder name instead of activation wordkeep_tokens set to 1 if token_to_captions is enabled--dataset_config, reverted back to old fine-tuning dataset config.recursive to
4.3. Merge Annotation Into JSON4.4. Create Buckets & Convert to Latentsmin_snr_gamma, disabled by default, Gamma for reducing the weight of high-loss timesteps. Lower numbers have a stronger effect. The paper recommends 5. Read the paper here.vae_batch_size to dreambooth notebook6.4. Launch Portable Web UI to match the latest Cagliostro Colab UI
anapnoe-webui as repo by default.What Changes?
1.1. Install Dependencies cell for all notebooks, added main()0.0.16 and triton to 2.0.0, because 0.0.17 is now automatically installing torch 2.0.0 which is incompatible for Colab Notebook, for now. At least no more installing pre-release package.libunwind8-dev not found by installing latest version using !apt install libunwind8-dev -qqT4 in !nvidia-smi output, then do a lowram patch by sed -i "s@cpu@cuda@" library/model_util.pyremove_bitsandbytes_message by manually editing main.py, and then set os.environ["BITSANDBYTES_NOWELCOME"] = "1"
BITSANDBYTES_NOWELCOME is unavailable in bitsandbytes==0.35.0 and we don't have a plan to update bitsandbytes versionos.environ["TF_CPP_MIN_LOG_LEVEL"] = "3", credit: TheLastBen/fast-stable-diffusionLD_LIBRARY_PATH WITH os.environ["LD_LIBRARY_PATH"] = "/usr/local/cuda/lib64/:$LD_LIBRARY_PATH"What Changes?
xformers wheels version to 0.0.17.dev476 and triton to 2.0.0.post1, to prevent triton installing torch 2.0.0.delete metadata option in 4.1. Data Cleaning cell, no more accidentally deleted metadata.remove_underscore option in 4.2.2. Waifu Diffusion 1.4 Tagger V2 cell4.2.3. Custom Caption/Tag (Optional) cell, now you can add/remove desired tags.
1girl, brown hair, school uniform, smile ) with underscore (_):
blue_berryblue berry, 1girl, brown hair, school uniform, smileappend to True, your custom tag will be added to end of line instead
blue_berry1girl, brown hair, school uniform, smile, blue berry ):
blue_berry red_juice,blue berry, red juice, 1girl, brown hair, school uniform, smileremove_tag to True
brown hair1girl, school uniform, smile, blue berry.txt or .caption files in 4.2.3. Custom Caption/Tag (Optional), it's added additional (.), e.g. image..txt5.3. Sample prompt config, sample prompt automatically created. If you want to add another prompt. Edit sample_prompt.txt directly in colab notebook editortoken is not caption, now you can add token to caption files in 5.2. Dataset Config, this will function in the same way as the 4.2.3. Custom Caption/Tag (Optional) cell. By doing this, it automatically set keep_tokens to > 1
5.4. Training configLoRA notebook and every 100 steps for Dreambooth and Finetuning notebook( ) and [ ] are working.5.3. LoRA and Optimizer Config
No more manually setting the network_module
No more manually setting the network_args
Added `Recommended Values:
| network_category | network_dim | network_alpha | conv_dim | conv_alpha |
|---|---|---|---|---|
| LoRA | 32 | 1 | - | - |
| LoCon | 16 | 8 | 8 | 1 |
| LoHa | 8 | 4 | 4 | 1 |
User can choose which network_category to train, option: ["LoRA", "LoCon", "LoCon_Lycoris", "LoHa"]
LoRA is normal LoRA, only trained cross-attention/transformer layerLoCon is LoRA for Convolutional Network but using networks.lora as default network_module, doesn't support dropoutLoCon_Lycoris is LoRA for Convolutional Network but using lycoris.kohya as default network_module
cp_decompositionLoHa is LoRA with Hadamard Product representation, slower to train than other network_category, need more documentationDeleted network_module support for locon.locon_kohya as it's now deprecated
conv_dim and conv_alpha now has separated markdown field
Visualize loss graph (Optional) position to 6.1, because it seems has dependency conflict with 6.4. Launch Portable Web UI6.3. Inference set default network_module to networks.lora. Doesn't support LoCon and LoHa trained with LyCORIS.6.4. Launch Portable Web UI to match the latest Cagliostro Colab UIWhat Changes?
Python 3.9.16network_module : lycoris.kohya. Read KohakuBlueleaf/LyCORIS
LyCORIS, a Home for custom network module for kohya-ss/sd-scripts.locon.locon_kohya still exist, but you can train LoCon in the new lycoris.kohya module as well by specify ["algo=lora"] in the network_argsgenerating sample every n epochs/steps, by disabling it, sample_every_n_type_value automatically set to int(999999)What Changes?
support us button to separated and hidden sectionold commit link to all notebookclone sd-scripts option because too risky, small changes my break notebook if new updates contain syntax from python > 3.9wd-1.5-beta-2 and wd-1.5-beta-2-aesthetic as pretrained model for SDv2.1 768v model, please use --v2 and --v_parameterization if you wanna train with it.folder naming scheme cell for colab dreambooth method, thanks to everyone who made this changes possible. Now you can set train_data_dir from gdrive path without worrying <repeats>_<token> class> ever againV. Training Model section
v2 and or v_parameterization here.dataset_config.toml file based on your input. And that .toml file will be used for training.class_token and num_repeats here instead of renaming your folder like before.--dataset_config is powerful, but I'm making the workflow to only fit one train_data_dir and reg_data_dir, so probably it's not compatible to train on multiple concepts anymore. But you can always tweaks .toml file.show code and you can add or remove variable, dataset, or dataset.subset from dict, especially if you want to train on multiple concepts.sample_prompt.txt file based on your input. And that .txt file will be used for generating sample.sample_every_n_type if you want to generate sample every n epochs or every n steps.( ) and [ ] are not working.sample_prompt.txt and add another prompt based on arguments below.--n : Negative Prompt--w : Width--h : Height--d : Seed, set to -1 for using random seed--l : CFG Scale--s : Sampler stepslocon.locon_kohya in network_modulenetwork_args, now you can specify more than 2 custom args, but you need to specify it inside a list, e.g. ["conv_dim=64","conv_alpha=32"]network_args for LoCon training as follow: "conv_dim=RANK_FOR_CONV" "conv_alpha=ALPHA_FOR_CONV" "dropout=DROPOUT_RATE"network_args, now you can specify more than 2 custom args, but you need to specify it inside a list, e.g. for DAdaptation : ["decouple=true","weight_decay=0.6"]lr_scheduler_args and added lr_scheduler_num_cycles and lr_scheduler_power backAdafactor for lr_schedulerconfig_file.toml file based on your input. And that .toml file will be used for training.num_epochs back to LoRA notebook and max_train_steps to dreambooth and native trainingconfig_file.tomlVI. Testing section
Portable Web UI as an alternative to try your trained model and LoRA, make sure you still got more time.config_file to huggingface.What Changes?
Login to Huggingface Hub to Deployment section, in the same cell with defining repo.Install Kohya Trainer, Install Dependencies, and Mount Drive cellsDataset Cleaning and Convert RGB to RGBA cellsImage Upscaler cell, because bucketing automatically upscale your dataset (converted to image latents) to min_bucket_reso value.Colab Ram Patch because now you can set --lowram in the training script.Unzip dataset cell to make it look simplerA100Pretrained Model section
Anything V3.3, Chilloutmix, and Counterfeit V2.5 as new pretrained model for SD V1.x based modelReplicant V1.0, WD 1.5 Beta and Illuminati Diffusion V1 as new pretrained model for SD V2.x 768v based modelStable Diffusion 1.5 pretrained model to pruned one.beam_search enabled by defaultsafebooru to booru listcustom_url option, so you can copy and paste the url instead of specify which booru sites and tags to scrapeuser_agent field, because you can't access some image board with default user_agentlimit_rate field to limit your countwith_aria2c to scrape your dataset, not a wrapper, just a simple trick to extract urls with gallery-dl and download them with aria2c instead. Fast but seems igonoring --write-tags..txt format instead of .jpg.txtadditional_arguments to make it more flexible if you want to try other argsAppend Custom Tag cell
.txt/.caption) if you didn't want to use BLIP or WD Tagger--keep_tokens args to the cellTraining Model section.
prettytable for easier maintenance and bug fixingv2, v2_parameterization and all important folder and project_nameOptimizer Config for notebook outside LoRA traininglearning_rate and lr_scheduler goes hereDAdaptation if you're in Colab free tier because it need more VRAM--optimizer_args for custom args, useful if you want to try adjusting weight decay, betas etccaption dropout, you can drop your caption or tags by adjusting dropout rates.--bucket_reso_steps and --bucket_no_upscale--noise_offset, read Diffusion With Offset Noise--lowram to load the model in VRAM instead of CPUConvert Diffusers to Checkpoint cell, now it's more readable.output_dir located in google drive, it assert an error because of something like /content/drive/dreambooth_cmd.yaml which is forbidden, now instead of saved to {output_dir}, now training args history are saved to {training_dir}News
experimental section.

Training script changes:
What Changes?
--learning_rate function in kohya-LoRA-dreambooth.ipynb and kohya-LoRA-finetuner.ipynb #52--keep_tokens function to prevent custom tags from being shuffled.Microsoft/GIT as the auto-captioning for natural language (git-large-textcaps is the default model).0.85) if you are training on objects or characters, and lower the threshold (e.g. 0.35) for training on general, style, or environment.--min_bucket_reso=320 and --max_bucket_reso=1280 functions for training resolutions above 512 (e.g. 640 and 768), Thanks Trauter!Training script Changes(kohya_ss)
What Changes?
download and generate regularization images function from kohya-dreambooth.ipynb and kohya-LoRA-dreambooth.ipynb.train_folder_directory and reg_folder_directory folders in kohya-dreambooth.ipynb and kohya-LoRA-dreambooth.ipynb.huggingface using aria2c.Anything V3.1 which has been improved CLIP and VAE models as the default pretrained model.parameter table and created the remaining tables for the dreambooth notebooks.network_alpha as a supporting hyperparameter for network_dim in the LoRA notebook.lr_scheduler_num_cycles function for cosine_with_restarts and the lr_scheduler_power function for polynomial.--learning_rate in each LoRA notebook because unet_lr and text_encoder_lr are already available.upload to hf_hub cell function.Training script Changes(kohya_ss)
%store IPython magic command to store important variable1.1. Clone Kohya Trainer cell, and save it using %store magic command.unzip cell and adjust download zip cell to do auto unzip as well if it detect path startswith /content/--flip_aug to Buckets and Latents cell.--output_name (your-project) cell to save Trained Model with custom nam.train_data_dir, last-state and training_logs before upload them to Huggingfacecolab_ram_patch as temporary fix for newest version of Colab after Ubuntu update to load Stable Diffusion model in GPU instead of RAMTraining script Changes(kohya_ss)
make_caption.pyconvert_diffusers20_original_sd.pyprepare_buckets_latents.pyColab UI changes:
make_caption.py will now automatically download the BLIP weight, as will the wd taggergen_img_diffusers.py has been added below the training cellsave_model_as option to fine_tune.py, which allows you to save the model in any format.keep_tokens option to fine_tune.py, which allows you to fix the first n tokens of the caption and not shuffle them.prepare_buckets_latents.py and fine_tune.py with the flip_aug option.pip install -U diffusers[torch]==0.10.2 in your virtual environment.v-parameterization training and also supports safetensors).--full_path option. The arguments for the cleaning script have also changed, see "Caption and Tag Preprocessing" for details.pip install safetensors and specify the use_safetensors option when saving.log_prefix option.--train_text_encoder to train the Text Encoder.--save_precision to specify the data format of the saved checkpoint. Can be selected from float, fp16, or bf16.--save_state to save the training state, including the optimizer. Can be resumed with the --resume option.pip install -U diffusers[torch]==0.9.0.--v2 option when training (and when pre-acquiring latents). If you are using 768-v-ema.ckpt or stable-diffusion-2 instead of stable-diffusion-v2-base, also use the --v_parameterization option when training.While Stable Diffusion fine tuning is typically based on CompVis, using Diffusers as a base allows for efficient and fast fine tuning with less memory usage. We have also added support for the features proposed by Novel AI, so we hope this article will be useful for those who want to fine tune their models.
— kohya_ss
1,007 followers · starred Oct 2023
300 followers · starred Jan 2023
134 followers · starred Feb 2023
31 followers · starred Dec 2022
Adapted from https://note.com/kohya_ss/n/nbf7ce8d80f29 for easier cloning
Jupyter Notebook
1,902
612 commits
updated May 14, 2024
Github Repository for kohya-ss/sd-scripts colab notebook implementation
| Notebook Name | Description | Link | V14 |
|---|---|---|---|
| Kohya LoRA Dreambooth | LoRA Training (Dreambooth method) | ||
| Kohya LoRA Fine-Tuning | LoRA Training (Fine-tune method) | ||
| Kohya Trainer | Native Training | ||
| Kohya Dreambooth | Dreambooth Training | ||
Cagliostro Colab UI NEW | A Customizable Stable Diffusion Web UI |
What Changes?
class_token undefined if activation_word = 1 word https://github.com/Linaqruf/kohya-trainer/issues/198
token_to_captions function, because it's complicated and also it has the same function with 4.2.3. Custom Caption/TagWhat Changes?
(,)3.3. Image Scraper (Optional):
parameter that should be default, e.g. user_agenttags1 and tags2 field, and changed it to prompt. Now user can type their desired tags more than 2 (except: danbooru) by separating each tag with a comma (,)sub_folder to scrape images to desired path, useful for multi-concept or multi-directories training.
train_data_dirtrain_data_dir + sub_foldersub_folderrange to limit the number of images to scrape. How to use it: Add 1-200 to download 200 images. Newest Images in the server are prioritized.recursive option to 4.1. Data Cleaning, to clean unsupported files and convert RGBA to RGB recursively. Useful for multi-concept or multi-directories training.4.2.1. BLIP Captioning:
recursive option to 4.2.1. BLIP Captioning, to generate captions recursively, by checking sub-directories as well. Useful for multi-concept or multi-directories training.--debug or verbose_logging in 4.2.1. BLIP Captioning On by default.Waifu Diffusion 1.4 Tagger V2:
--remove_underscore args to the WD Tagger script.0) but also character tags (category = 4)--character_threshold parameter (default = 0.35)--thresh to --general_threshold (default = 0.35)--undesired_words args to not add specified words when interrogating images, separate each word by comma, e.g. 1girl, scenery--debug works, new template : {filename}
Character Tags = {character_tags}
General Tags = {general_tags}
--debug or verbose_logging On by default.--frequency_tags to print tags frequencyrecursive option to generate tags recursively, by checking sub-directories as well. Useful for multi-concept or multi-directories training.4.2.3. Custom Caption/Tag:
append() to add tags to the end of lines.insert() to add tags to the beginning of lines.remove() to remove tags separated by comma.Cheatsheet from v14.6 is outdated, now user can easily add or remove tags
"_" or " " doesn't matter anymore"_" will still be replaced with " "1girl to custom_tags then run, if you set append, it will be added to the end of lines instead.(,), e.g. 1girl, garden, school uniforminsert(), the result will be backward instead: school uniform, garden, 1girlcustom_tags to your desired words and set remove_tagssub_folder option, useful for multi-concept or multi-directories training.
--all it will process directory and subdirectories in train_data_dir recursively.train_data_dirtrain_data_dir + sub_foldersub_folderrecursive option to 4.3. Merge Annotation Into JSON and Create Buckets & Convert to Latents5.2. Dataset Config:
instance_token and class_token and changed into activation wordsupported_extensions exist (".png", ".jpg", ".jpeg", ".webp", ".bmp") it will add the path to [[dataset.subsets]] in dataset_config.tomltrain_data_dir like old version, and you can also normally set train_data_dir.<num_repeats>_<class_token>
10_mikapikazo, 10 will be added as num_repeats and mikapikazo will be added to class_token in dataset_config.tomlnum_repeats from dataset_repeats and class_token from activation_wordtoken_to_captions
activation_word to captions/tags<class_token> from folder name instead of activation wordkeep_tokens set to 1 if token_to_captions is enabled--dataset_config, reverted back to old fine-tuning dataset config.recursive to
4.3. Merge Annotation Into JSON4.4. Create Buckets & Convert to Latentsmin_snr_gamma, disabled by default, Gamma for reducing the weight of high-loss timesteps. Lower numbers have a stronger effect. The paper recommends 5. Read the paper here.vae_batch_size to dreambooth notebook6.4. Launch Portable Web UI to match the latest Cagliostro Colab UI
anapnoe-webui as repo by default.What Changes?
1.1. Install Dependencies cell for all notebooks, added main()0.0.16 and triton to 2.0.0, because 0.0.17 is now automatically installing torch 2.0.0 which is incompatible for Colab Notebook, for now. At least no more installing pre-release package.libunwind8-dev not found by installing latest version using !apt install libunwind8-dev -qqT4 in !nvidia-smi output, then do a lowram patch by sed -i "s@cpu@cuda@" library/model_util.pyremove_bitsandbytes_message by manually editing main.py, and then set os.environ["BITSANDBYTES_NOWELCOME"] = "1"
BITSANDBYTES_NOWELCOME is unavailable in bitsandbytes==0.35.0 and we don't have a plan to update bitsandbytes versionos.environ["TF_CPP_MIN_LOG_LEVEL"] = "3", credit: TheLastBen/fast-stable-diffusionLD_LIBRARY_PATH WITH os.environ["LD_LIBRARY_PATH"] = "/usr/local/cuda/lib64/:$LD_LIBRARY_PATH"What Changes?
xformers wheels version to 0.0.17.dev476 and triton to 2.0.0.post1, to prevent triton installing torch 2.0.0.delete metadata option in 4.1. Data Cleaning cell, no more accidentally deleted metadata.remove_underscore option in 4.2.2. Waifu Diffusion 1.4 Tagger V2 cell4.2.3. Custom Caption/Tag (Optional) cell, now you can add/remove desired tags.
1girl, brown hair, school uniform, smile ) with underscore (_):
blue_berryblue berry, 1girl, brown hair, school uniform, smileappend to True, your custom tag will be added to end of line instead
blue_berry1girl, brown hair, school uniform, smile, blue berry ):
blue_berry red_juice,blue berry, red juice, 1girl, brown hair, school uniform, smileremove_tag to True
brown hair1girl, school uniform, smile, blue berry.txt or .caption files in 4.2.3. Custom Caption/Tag (Optional), it's added additional (.), e.g. image..txt5.3. Sample prompt config, sample prompt automatically created. If you want to add another prompt. Edit sample_prompt.txt directly in colab notebook editortoken is not caption, now you can add token to caption files in 5.2. Dataset Config, this will function in the same way as the 4.2.3. Custom Caption/Tag (Optional) cell. By doing this, it automatically set keep_tokens to > 1
5.4. Training configLoRA notebook and every 100 steps for Dreambooth and Finetuning notebook( ) and [ ] are working.5.3. LoRA and Optimizer Config
No more manually setting the network_module
No more manually setting the network_args
Added `Recommended Values:
| network_category | network_dim | network_alpha | conv_dim | conv_alpha |
|---|---|---|---|---|
| LoRA | 32 | 1 | - | - |
| LoCon | 16 | 8 | 8 | 1 |
| LoHa | 8 | 4 | 4 | 1 |
User can choose which network_category to train, option: ["LoRA", "LoCon", "LoCon_Lycoris", "LoHa"]
LoRA is normal LoRA, only trained cross-attention/transformer layerLoCon is LoRA for Convolutional Network but using networks.lora as default network_module, doesn't support dropoutLoCon_Lycoris is LoRA for Convolutional Network but using lycoris.kohya as default network_module
cp_decompositionLoHa is LoRA with Hadamard Product representation, slower to train than other network_category, need more documentationDeleted network_module support for locon.locon_kohya as it's now deprecated
conv_dim and conv_alpha now has separated markdown field
Visualize loss graph (Optional) position to 6.1, because it seems has dependency conflict with 6.4. Launch Portable Web UI6.3. Inference set default network_module to networks.lora. Doesn't support LoCon and LoHa trained with LyCORIS.6.4. Launch Portable Web UI to match the latest Cagliostro Colab UIWhat Changes?
Python 3.9.16network_module : lycoris.kohya. Read KohakuBlueleaf/LyCORIS
LyCORIS, a Home for custom network module for kohya-ss/sd-scripts.locon.locon_kohya still exist, but you can train LoCon in the new lycoris.kohya module as well by specify ["algo=lora"] in the network_argsgenerating sample every n epochs/steps, by disabling it, sample_every_n_type_value automatically set to int(999999)What Changes?
support us button to separated and hidden sectionold commit link to all notebookclone sd-scripts option because too risky, small changes my break notebook if new updates contain syntax from python > 3.9wd-1.5-beta-2 and wd-1.5-beta-2-aesthetic as pretrained model for SDv2.1 768v model, please use --v2 and --v_parameterization if you wanna train with it.folder naming scheme cell for colab dreambooth method, thanks to everyone who made this changes possible. Now you can set train_data_dir from gdrive path without worrying <repeats>_<token> class> ever againV. Training Model section
v2 and or v_parameterization here.dataset_config.toml file based on your input. And that .toml file will be used for training.class_token and num_repeats here instead of renaming your folder like before.--dataset_config is powerful, but I'm making the workflow to only fit one train_data_dir and reg_data_dir, so probably it's not compatible to train on multiple concepts anymore. But you can always tweaks .toml file.show code and you can add or remove variable, dataset, or dataset.subset from dict, especially if you want to train on multiple concepts.sample_prompt.txt file based on your input. And that .txt file will be used for generating sample.sample_every_n_type if you want to generate sample every n epochs or every n steps.( ) and [ ] are not working.sample_prompt.txt and add another prompt based on arguments below.--n : Negative Prompt--w : Width--h : Height--d : Seed, set to -1 for using random seed--l : CFG Scale--s : Sampler stepslocon.locon_kohya in network_modulenetwork_args, now you can specify more than 2 custom args, but you need to specify it inside a list, e.g. ["conv_dim=64","conv_alpha=32"]network_args for LoCon training as follow: "conv_dim=RANK_FOR_CONV" "conv_alpha=ALPHA_FOR_CONV" "dropout=DROPOUT_RATE"network_args, now you can specify more than 2 custom args, but you need to specify it inside a list, e.g. for DAdaptation : ["decouple=true","weight_decay=0.6"]lr_scheduler_args and added lr_scheduler_num_cycles and lr_scheduler_power backAdafactor for lr_schedulerconfig_file.toml file based on your input. And that .toml file will be used for training.num_epochs back to LoRA notebook and max_train_steps to dreambooth and native trainingconfig_file.tomlVI. Testing section
Portable Web UI as an alternative to try your trained model and LoRA, make sure you still got more time.config_file to huggingface.What Changes?
Login to Huggingface Hub to Deployment section, in the same cell with defining repo.Install Kohya Trainer, Install Dependencies, and Mount Drive cellsDataset Cleaning and Convert RGB to RGBA cellsImage Upscaler cell, because bucketing automatically upscale your dataset (converted to image latents) to min_bucket_reso value.Colab Ram Patch because now you can set --lowram in the training script.Unzip dataset cell to make it look simplerA100Pretrained Model section
Anything V3.3, Chilloutmix, and Counterfeit V2.5 as new pretrained model for SD V1.x based modelReplicant V1.0, WD 1.5 Beta and Illuminati Diffusion V1 as new pretrained model for SD V2.x 768v based modelStable Diffusion 1.5 pretrained model to pruned one.beam_search enabled by defaultsafebooru to booru listcustom_url option, so you can copy and paste the url instead of specify which booru sites and tags to scrapeuser_agent field, because you can't access some image board with default user_agentlimit_rate field to limit your countwith_aria2c to scrape your dataset, not a wrapper, just a simple trick to extract urls with gallery-dl and download them with aria2c instead. Fast but seems igonoring --write-tags..txt format instead of .jpg.txtadditional_arguments to make it more flexible if you want to try other argsAppend Custom Tag cell
.txt/.caption) if you didn't want to use BLIP or WD Tagger--keep_tokens args to the cellTraining Model section.
prettytable for easier maintenance and bug fixingv2, v2_parameterization and all important folder and project_nameOptimizer Config for notebook outside LoRA traininglearning_rate and lr_scheduler goes hereDAdaptation if you're in Colab free tier because it need more VRAM--optimizer_args for custom args, useful if you want to try adjusting weight decay, betas etccaption dropout, you can drop your caption or tags by adjusting dropout rates.--bucket_reso_steps and --bucket_no_upscale--noise_offset, read Diffusion With Offset Noise--lowram to load the model in VRAM instead of CPUConvert Diffusers to Checkpoint cell, now it's more readable.output_dir located in google drive, it assert an error because of something like /content/drive/dreambooth_cmd.yaml which is forbidden, now instead of saved to {output_dir}, now training args history are saved to {training_dir}News
experimental section.

Training script changes:
What Changes?
--learning_rate function in kohya-LoRA-dreambooth.ipynb and kohya-LoRA-finetuner.ipynb #52--keep_tokens function to prevent custom tags from being shuffled.Microsoft/GIT as the auto-captioning for natural language (git-large-textcaps is the default model).0.85) if you are training on objects or characters, and lower the threshold (e.g. 0.35) for training on general, style, or environment.--min_bucket_reso=320 and --max_bucket_reso=1280 functions for training resolutions above 512 (e.g. 640 and 768), Thanks Trauter!Training script Changes(kohya_ss)
What Changes?
download and generate regularization images function from kohya-dreambooth.ipynb and kohya-LoRA-dreambooth.ipynb.train_folder_directory and reg_folder_directory folders in kohya-dreambooth.ipynb and kohya-LoRA-dreambooth.ipynb.huggingface using aria2c.Anything V3.1 which has been improved CLIP and VAE models as the default pretrained model.parameter table and created the remaining tables for the dreambooth notebooks.network_alpha as a supporting hyperparameter for network_dim in the LoRA notebook.lr_scheduler_num_cycles function for cosine_with_restarts and the lr_scheduler_power function for polynomial.--learning_rate in each LoRA notebook because unet_lr and text_encoder_lr are already available.upload to hf_hub cell function.Training script Changes(kohya_ss)
%store IPython magic command to store important variable1.1. Clone Kohya Trainer cell, and save it using %store magic command.unzip cell and adjust download zip cell to do auto unzip as well if it detect path startswith /content/--flip_aug to Buckets and Latents cell.--output_name (your-project) cell to save Trained Model with custom nam.train_data_dir, last-state and training_logs before upload them to Huggingfacecolab_ram_patch as temporary fix for newest version of Colab after Ubuntu update to load Stable Diffusion model in GPU instead of RAMTraining script Changes(kohya_ss)
make_caption.pyconvert_diffusers20_original_sd.pyprepare_buckets_latents.pyColab UI changes:
make_caption.py will now automatically download the BLIP weight, as will the wd taggergen_img_diffusers.py has been added below the training cellsave_model_as option to fine_tune.py, which allows you to save the model in any format.keep_tokens option to fine_tune.py, which allows you to fix the first n tokens of the caption and not shuffle them.prepare_buckets_latents.py and fine_tune.py with the flip_aug option.pip install -U diffusers[torch]==0.10.2 in your virtual environment.v-parameterization training and also supports safetensors).--full_path option. The arguments for the cleaning script have also changed, see "Caption and Tag Preprocessing" for details.pip install safetensors and specify the use_safetensors option when saving.log_prefix option.--train_text_encoder to train the Text Encoder.--save_precision to specify the data format of the saved checkpoint. Can be selected from float, fp16, or bf16.--save_state to save the training state, including the optimizer. Can be resumed with the --resume option.pip install -U diffusers[torch]==0.9.0.--v2 option when training (and when pre-acquiring latents). If you are using 768-v-ema.ckpt or stable-diffusion-2 instead of stable-diffusion-v2-base, also use the --v_parameterization option when training.While Stable Diffusion fine tuning is typically based on CompVis, using Diffusers as a base allows for efficient and fast fine tuning with less memory usage. We have also added support for the features proposed by Novel AI, so we hope this article will be useful for those who want to fine tune their models.
— kohya_ss
1,007 followers · starred Oct 2023
300 followers · starred Jan 2023
134 followers · starred Feb 2023
31 followers · starred Dec 2022