Hello and welcome back.
Over the past few weeks, I've shown you how to train a model with a specific style. The limitation with that method is that the model is unique and if I want to apply the same style to a second model, I have to repeat the training process and also use up significant hard drive space. But today, I'm going to show you how to train a Lora Style that can be applied to any model in your Stablediffusion library. As always, this tutorial will be a quick learning method and we won't delve into all the tool's parameters in detail. Naturally, you'll need to have Kohya installed.
1. On windows explorer let's create three folders: 'model', 'img', and 'log'. If you're thinking of sharing the Lora with someone, you must use copyright-free images.
2. Inside the 'img' folder, let's create another folder named '100', followed by an underscore and the name of the Lora we'll be using
3. Next, insert the training images. I recommend resizing them to 512x512 if you're training a model for SD 1.5, although it's not mandatory.
4. As always, we should pair the images with their descriptions, Fortunately, Kohya provides a feature to automatically describe our images for us.
5. Open Kohya and navigate to Utilities, then select Blip Captioning. Input the path to our folder with the images, and then hit 'Caption Images'.
6. On Windows, a Triton error might pop up, but you can ignore it.
7. In Dreambooth Lora - Source Model, let's input the 'base' model we'll use for training.
8. In the 'folder' section, let's input the paths of the three folders we created earlier. Make sure to use the root 'img' path, not the '100' folder, and so on. Don't forget to enter the name you wish to give to your Lora as well
9. Now let's move on to the 'Training Parameters' section. If you have 50 training images, feel free to copy the parameters you see on the screen. Once you've copied the parameters, simply hit 'Train' and wait for about 20-30 minutes for the training to finish
10. If you've used images of different dimensions from 512x512, remember to leave 'Enable Buckets' checked
11. Press Train
12. Inside the 'model' folder created at the beginning, you'll find the Lora with the name you chose. All that's left for you to do is to take it and move it into the 'models\lora' folder within Stablediffusion.
13. Open Automatic1111
14. Have fun
{
"pretrained_model_name_or_path": "xxx",
"v2": false,
"v_parameterization": false,
"logging_dir": "xxx",
"train_data_dir": "xxx",
"reg_data_dir": "",
"output_dir": "xxx",
"max_resolution": "512,512",
"learning_rate": 0.0001,
"lr_scheduler": "constant",
"lr_warmup": 0,
"train_batch_size": 4,
"epoch": 1,
"save_every_n_epochs": 1,
"mixed_precision": "fp16",
"save_precision": "fp16",
"seed": "1234",
"num_cpu_threads_per_process": 10,
"cache_latents": true,
"cache_latents_to_disk": false,
"caption_extension": ".txt",
"enable_bucket": true,
"gradient_checkpointing": false,
"full_fp16": false,
"no_token_padding": false,
"stop_text_encoder_training": 0,
"xformers": true,
"save_model_as": "safetensors",
"shuffle_caption": false,
"save_state": false,
"resume": "",
"prior_loss_weight": 1.0,
"text_encoder_lr": 5e-05,
"unet_lr": 0.0001,
"network_dim": 128,
"lora_network_weights": "",
"dim_from_weights": false,
"color_aug": false,
"flip_aug": false,
"clip_skip": 2,
"gradient_accumulation_steps": 1,
"mem_eff_attn": false,
"output_name": "LoraAlCappRV",
"model_list": "custom",
"max_token_length": "75",
"max_train_epochs": "",
"max_data_loader_n_workers": "1",
"network_alpha": 128,
"training_comment": "",
"keep_tokens": "0",
"lr_scheduler_num_cycles": "",
"lr_scheduler_power": "",
"persistent_data_loader_workers": false,
"bucket_no_upscale": true,
"random_crop": false,
"bucket_reso_steps": 64.0,
"caption_dropout_every_n_epochs": 0.0,
"caption_dropout_rate": 0,
"optimizer": "AdamW8bit",
"optimizer_args": "",
"noise_offset_type": "Original",
"noise_offset": 0,
"adaptive_noise_scale": 0,
"multires_noise_iterations": 0,
"multires_noise_discount": 0,
"LoRA_type": "Standard",
"factor": -1,
"use_cp": false,
"decompose_both": false,
"train_on_input": false,
"conv_dim": 1,
"conv_alpha": 1,
"sample_every_n_steps": 0,
"sample_every_n_epochs": 0,
"sample_sampler": "euler_a",
"sample_prompts": "",
"additional_parameters": "",
"vae_batch_size": 0,
"min_snr_gamma": 0,
"down_lr_weight": "",
"mid_lr_weight": "",
"up_lr_weight": "",
"block_lr_zero_threshold": "",
"block_dims": "",
"block_alphas": "",
"conv_dims": "",
"conv_alphas": "",
"weighted_captions": false,
"unit": 1,
"save_every_n_steps": 0,
"save_last_n_steps": 0,
"save_last_n_steps_state": 0,
"use_wandb": false,
"wandb_api_key": "",
"scale_v_pred_loss_like_noise_pred": false,
"scale_weight_norms": 0,
"network_dropout": 0,
"rank_dropout": 0,
"module_dropout": 0
}
Train a style for StableDiffusion with Kohya
Теги
kohyastablediffusionai trainingstyle trainingmodelimglogcopyright-free imagesLoratraining imagesimage resizing512x512 dimensionsimage descriptionsBlip Captioningimage captioningDreambooth LoraStablediffusion 1.5Training ParametersNumber of CPU Threads Per CoretrainingEnable BucketsLora trainingmodel folderStablediffusionAutomatic1111AI trainingmachine learningAI tutorialimage processingartificial intelligence.