From cf4d4e1f28d877c15fc1999af7bbeeeb75265176 Mon Sep 17 00:00:00 2001 From: bmaltais Date: Sun, 10 Sep 2023 15:56:20 -0400 Subject: [PATCH 1/3] Add preset, fix make_caption library path --- finetune/make_captions.py | 2 +- presets/lora/SDXL - LoRA dogu_cat v1.0.json | 97 +++++++++++++++++++++ tools/create_txt_from_images.py | 32 +++++++ 3 files changed, 130 insertions(+), 1 deletion(-) create mode 100644 presets/lora/SDXL - LoRA dogu_cat v1.0.json create mode 100644 tools/create_txt_from_images.py diff --git a/finetune/make_captions.py b/finetune/make_captions.py index b20c41068..7178c22a3 100644 --- a/finetune/make_captions.py +++ b/finetune/make_captions.py @@ -12,7 +12,7 @@ import torch from torchvision import transforms from torchvision.transforms.functional import InterpolationMode -sys.path.append(os.path.dirname(__file__)) +sys.path.append(os.path.join(os.path.dirname(__file__), '..')) # sys.path.append(os.path.dirname(__file__)) from blip.blip import blip_decoder import library.train_util as train_util diff --git a/presets/lora/SDXL - LoRA dogu_cat v1.0.json b/presets/lora/SDXL - LoRA dogu_cat v1.0.json new file mode 100644 index 000000000..910e28885 --- /dev/null +++ b/presets/lora/SDXL - LoRA dogu_cat v1.0.json @@ -0,0 +1,97 @@ +{ + "LoRA_type": "Standard", + "adaptive_noise_scale": 0.00357, + "additional_parameters": "", + "block_alphas": "", + "block_dims": "", + "block_lr_zero_threshold": "", + "bucket_no_upscale": false, + "bucket_reso_steps": 32, + "cache_latents": true, + "cache_latents_to_disk": true, + "caption_dropout_every_n_epochs": 0.0, + "caption_dropout_rate": 0, + "caption_extension": ".txt", + "clip_skip": "1", + "color_aug": false, + "conv_alpha": 4, + "conv_block_alphas": "", + "conv_block_dims": "", + "conv_dim": 4, + "decompose_both": false, + "dim_from_weights": false, + "down_lr_weight": "", + "enable_bucket": true, + "epoch": 10, + "factor": -1, + "flip_aug": false, + "full_bf16": false, + "full_fp16": false, + "gradient_accumulation_steps": 1, + "gradient_checkpointing": true, + "keep_tokens": 1, + "learning_rate": 0.0001, + "lora_network_weights": "", + "lr_scheduler": "cosine", + "lr_scheduler_args": "", + "lr_scheduler_num_cycles": "1", + "lr_scheduler_power": "", + "lr_warmup": 0, + "max_bucket_reso": 2048, + "max_data_loader_n_workers": "0", + "max_resolution": "1024,1024", + "max_timestep": 1000, + "max_token_length": "75", + "max_train_epochs": "", + "max_train_steps": "", + "mem_eff_attn": false, + "mid_lr_weight": "", + "min_bucket_reso": 64, + "min_snr_gamma": 0, + "min_timestep": 0, + "mixed_precision": "bf16", + "module_dropout": 0, + "multires_noise_discount": 0, + "multires_noise_iterations": 0, + "network_alpha": 46, + "network_dim": 92, + "network_dropout": 0, + "no_token_padding": false, + "noise_offset": 0.0357, + "noise_offset_type": "Original", + "num_cpu_threads_per_process": 2, + "optimizer": "AdamW8bit", + "optimizer_args": "", + "persistent_data_loader_workers": false, + "prior_loss_weight": 1.0, + "random_crop": false, + "rank_dropout": 0, + "save_every_n_epochs": 2, + "save_every_n_steps": 0, + "save_last_n_steps": 0, + "save_last_n_steps_state": 0, + "save_precision": "bf16", + "scale_v_pred_loss_like_noise_pred": false, + "scale_weight_norms": 1, + "sdxl": true, + "sdxl_cache_text_encoder_outputs": false, + "sdxl_no_half_vae": true, + "seed": "12345", + "shuffle_caption": false, + "stop_text_encoder_training_pct": 0, + "text_encoder_lr": 0.0001, + "train_batch_size": 1, + "train_on_input": false, + "training_comment": "20 1024x1024 cropped images, 20 repeats, Blip captions, but 'woman' replaced with 'khls woman'", + "unet_lr": 0.0001, + "unit": 1, + "up_lr_weight": "", + "use_cp": false, + "use_wandb": false, + "v2": false, + "v_parameterization": false, + "v_pred_like_loss": 0, + "vae_batch_size": 0, + "weighted_captions": false, + "xformers": "xformers" +} \ No newline at end of file diff --git a/tools/create_txt_from_images.py b/tools/create_txt_from_images.py new file mode 100644 index 000000000..e1a4aec7d --- /dev/null +++ b/tools/create_txt_from_images.py @@ -0,0 +1,32 @@ +import os +import argparse + +def main(folder_path): + # Validate if the folder exists + if not os.path.exists(folder_path): + print("The specified folder does not exist.") + return + + # Loop through all files in the directory + for filename in os.listdir(folder_path): + # Check if the file is an image file (webp, jpg, png) + if filename.lower().endswith(('.webp', '.jpg', '.png')): + # Remove the file extension from the filename + name_without_extension = os.path.splitext(filename)[0] + + # Construct the name of the txt file + txt_filename = f"{name_without_extension}.txt" + + # Extract the content before the underscore + content = name_without_extension.split("_")[0] + + # Write the content to the txt file + with open(os.path.join(folder_path, txt_filename), "w") as txt_file: + txt_file.write(content) + +if __name__ == "__main__": + parser = argparse.ArgumentParser(description='Process a folder.') + parser.add_argument('folder_path', type=str, help='Path to the folder to process') + + args = parser.parse_args() + main(args.folder_path) From 3a25858cb89828dc9f5a174473aa1b1cf7a1cd9d Mon Sep 17 00:00:00 2001 From: bmaltais Date: Sun, 10 Sep 2023 16:00:08 -0400 Subject: [PATCH 2/3] Update --- presets/lora/SDXL - LoRA dogu_cat v1.0.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/presets/lora/SDXL - LoRA dogu_cat v1.0.json b/presets/lora/SDXL - LoRA dogu_cat v1.0.json index 910e28885..78d628b98 100644 --- a/presets/lora/SDXL - LoRA dogu_cat v1.0.json +++ b/presets/lora/SDXL - LoRA dogu_cat v1.0.json @@ -82,7 +82,7 @@ "text_encoder_lr": 0.0001, "train_batch_size": 1, "train_on_input": false, - "training_comment": "20 1024x1024 cropped images, 20 repeats, Blip captions, but 'woman' replaced with 'khls woman'", + "training_comment": "20 1024x1024 cropped images, 20 repeats, Blip captions, but 'woman' replaced with 'khls woman', https://civitai.com/user/dogu_cat/models", "unet_lr": 0.0001, "unit": 1, "up_lr_weight": "", From 5449d1b47b3663c8f49d5a78099d1e19411d23e7 Mon Sep 17 00:00:00 2001 From: bmaltais Date: Sat, 23 Sep 2023 09:25:42 -0400 Subject: [PATCH 3/3] v21.8.10 --- .release | 2 +- README.md | 5 ++++- ...ogu_cat v1.0.json => SDXL - LoRA face dogu_cat v1.0.json} | 2 +- 3 files changed, 6 insertions(+), 3 deletions(-) rename presets/lora/{SDXL - LoRA dogu_cat v1.0.json => SDXL - LoRA face dogu_cat v1.0.json} (93%) diff --git a/.release b/.release index 33e5e97d9..3db656719 100644 --- a/.release +++ b/.release @@ -1 +1 @@ -v21.8.9 +v21.8.10 diff --git a/README.md b/README.md index ae937b9b0..a0e93bc28 100644 --- a/README.md +++ b/README.md @@ -533,6 +533,9 @@ If you come across a `FileNotFoundError`, it is likely due to an installation is ## Change History +* 2023/09/23 (v21.8.10) + - Minor point upgrade. Mostly adding a new preset. + * 2023/08/05 (v21.8.9) - Update sd-script to caode as of Sept 3 2023 * ControlNet-LLLite is added. See documentation for details. @@ -541,4 +544,4 @@ If you come across a `FileNotFoundError`, it is likely due to an installation is * Input perturbation noise is added. See #798 for details. * Dataset subset now has caption_prefix and caption_suffix options. The strings are added to the beginning and the end of the captions before shuffling. You can specify the options in .toml. * Other minor changes. - - Added support fir Chinese locallisation \ No newline at end of file + - Added support for Chinese locallisation \ No newline at end of file diff --git a/presets/lora/SDXL - LoRA dogu_cat v1.0.json b/presets/lora/SDXL - LoRA face dogu_cat v1.0.json similarity index 93% rename from presets/lora/SDXL - LoRA dogu_cat v1.0.json rename to presets/lora/SDXL - LoRA face dogu_cat v1.0.json index 78d628b98..25ad855cb 100644 --- a/presets/lora/SDXL - LoRA dogu_cat v1.0.json +++ b/presets/lora/SDXL - LoRA face dogu_cat v1.0.json @@ -82,7 +82,7 @@ "text_encoder_lr": 0.0001, "train_batch_size": 1, "train_on_input": false, - "training_comment": "20 1024x1024 cropped images, 20 repeats, Blip captions, but 'woman' replaced with 'khls woman', https://civitai.com/user/dogu_cat/models", + "training_comment": "Good for faces. Use 20 1024x1024 cropped images, 20 repeats, Blip captions, but 'woman' replaced with 'khls woman', https://civitai.com/user/dogu_cat/models", "unet_lr": 0.0001, "unit": 1, "up_lr_weight": "",