From 4eae58fd0e7a492d7a542b08e2a984c0305564b6 Mon Sep 17 00:00:00 2001 From: Bernard Maltais Date: Sat, 5 Nov 2022 16:56:34 -0400 Subject: [PATCH] Update readme with finetuing --- README.md | 26 ++++++++++++++ train.ps | 106 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 132 insertions(+) create mode 100644 train.ps diff --git a/README.md b/README.md index 63218c3..847a6a8 100644 --- a/README.md +++ b/README.md @@ -93,3 +93,29 @@ accelerate launch --num_cpu_threads_per_process 6 train_db_fixed_v6.py ` --cache_latents ` --gradient_checkpointing ` --save_every_n_epochs=1 + +## Finetuning + +If you would rather use model finetuning rather than the dreambooth method you can use a command similat to the following. The advantage of fine tuning is that you do not need to worry about regularization images... but you need to provide captions for every images. The caption will be used to train the model. You can use auto1111 to preprocess your training images and add either BLIP or danbooru captions to them. You then need to edit those to add the name of the model and correct any wrong description. + +``` +accelerate launch --num_cpu_threads_per_process 6 train_db_fixed_v6-ber.py ` + --pretrained_model_name_or_path="D:\models\v1-5-pruned-mse-vae.ckpt" ` + --train_data_dir="D:\dreambooth\source\alet_et_bernard\landscape-pp" ` + --output_dir="D:\dreambooth\train_alex_and_bernard" ` + --resolution="640,448" ` + --train_batch_size=8 ` + --learning_rate=1e-6 ` + --max_train_steps=550 ` + --use_8bit_adam ` + --xformers ` + --mixed_precision="fp16" ` + --cache_latents ` + --save_every_n_epochs=1 ` + --fine_tuning ` + --fine_tuning_repeat=200 ` + --seed=23 ` + --save_half +``` + +Refer to this url for more details about finetuning: https://note.com/kohya_ss/n/n1269f1e1a54e diff --git a/train.ps b/train.ps new file mode 100644 index 0000000..e17d46a --- /dev/null +++ b/train.ps @@ -0,0 +1,106 @@ +accelerate launch --num_cpu_threads_per_process 6 train_db_fixed_v6.py ` + --pretrained_model_name_or_path="D:\models\v1-5-pruned.ckpt" ` + --train_data_dir="D:\dreambooth\train_bernard\train_man" ` + --reg_data_dir="D:\dreambooth\train_bernard\reg_man" ` + --output_dir="D:\dreambooth\train_bernard" ` + --prior_loss_weight=1.0 ` + --resolution="512,512" ` + --train_batch_size=1 ` + --learning_rate=1e-6 ` + --max_train_steps=3000 ` + --use_8bit_adam ` + --xformers ` + --mixed_precision="fp16" ` + --cache_latents ` + --gradient_checkpointing ` + --save_every_n_epochs=1 + +accelerate launch --num_cpu_threads_per_process 6 train_db_fixed_v6.py ` + --pretrained_model_name_or_path="D:\models\bernard\asd man-3000-remgb-sd15.ckpt" ` + --train_data_dir="D:\dreambooth\train_bernard\train_man" ` + --reg_data_dir="D:\dreambooth\train_bernard\reg_man" ` + --output_dir="D:\dreambooth\train_bernard" ` + --prior_loss_weight=1.0 ` + --resolution="512,512" ` + --train_batch_size=1 ` + --learning_rate=1e-6 ` + --max_train_steps=1500 ` + --use_8bit_adam ` + --xformers ` + --mixed_precision="fp16" ` + --cache_latents ` + --gradient_checkpointing ` + --save_every_n_epochs=1 + +accelerate launch --num_cpu_threads_per_process 6 train_db_fixed_v6.py ` + --pretrained_model_name_or_path="D:\models\v1-5-pruned-mse-vae.ckpt" ` + --train_data_dir="D:\dreambooth\train_bernard\train_man" ` + --reg_data_dir="D:\dreambooth\train_bernard\reg_man" ` + --output_dir="D:\dreambooth\train_bernard" ` + --prior_loss_weight=1.0 ` + --resolution="512,512" ` + --train_batch_size=1 ` + --learning_rate=1e-6 ` + --max_train_steps=4500 ` + --use_8bit_adam ` + --xformers ` + --mixed_precision="fp16" ` + --cache_latents ` + --gradient_checkpointing ` + --no_token_padding ` + --save_every_n_epochs=1 + +accelerate launch --num_cpu_threads_per_process 6 train_db_fixed_v6.py ` + --pretrained_model_name_or_path="D:\models\v1-5-pruned-mse-vae.ckpt" ` + --train_data_dir="D:\dreambooth\source\alex\train" ` + --output_dir="D:\dreambooth\train_alex" ` + --prior_loss_weight=1.0 ` + --resolution="448,640" ` + --train_batch_size=8 ` + --learning_rate=1e-6 ` + --max_train_steps=4500 ` + --use_8bit_adam ` + --xformers ` + --mixed_precision="fp16" ` + --cache_latents ` + --save_every_n_epochs=1 ` + --shuffle_caption + +# -fine_tuning + +accelerate launch --num_cpu_threads_per_process 6 train_db_fixed_v6.py ` + --pretrained_model_name_or_path="D:\models\v1-5-pruned-mse-vae.ckpt" ` + --train_data_dir="D:\dreambooth\source\alex\train\50_portrait-pp" ` + --output_dir="D:\dreambooth\train_alex" ` + --resolution="448,640" ` + --train_batch_size=8 ` + --learning_rate=1e-6 ` + --max_train_steps=4500 ` + --use_8bit_adam ` + --xformers ` + --mixed_precision="fp16" ` + --cache_latents ` + --save_every_n_epochs=1 ` + --fine_tuning ` + --shuffle_caption + +Resume: + +accelerate launch --num_cpu_threads_per_process 6 train_db_fixed_v6-ber.py ` + --pretrained_model_name_or_path="D:\models\v1-5-pruned-mse-vae.ckpt" ` + --train_data_dir="D:\dreambooth\source\alet_et_bernard\landscape-pp" ` + --output_dir="D:\dreambooth\train_alex_and_bernard" ` + --resolution="640,448" ` + --train_batch_size=8 ` + --learning_rate=1e-6 ` + --max_train_steps=550 ` + --use_8bit_adam ` + --xformers ` + --mixed_precision="fp16" ` + --cache_latents ` + --save_every_n_epochs=1 ` + --fine_tuning ` + --fine_tuning_repeat=200 ` + --seed=23 ` + --save_half + \ No newline at end of file