From 2cdf4cf741f3602873cb77d821fe782e2aa5aa75 Mon Sep 17 00:00:00 2001 From: bmaltais Date: Fri, 23 Dec 2022 07:56:35 -0500 Subject: [PATCH] - Fix for conversion tool issue when the source was an sd1.x diffuser model - Other minor code and GUI fix --- README.md | 3 +++ README_dreambooth.md | 17 ++--------------- README_finetune.md | 17 ++--------------- dreambooth.cmd | 1 - finetune.cmd | 1 - finetune/make_captions.py | 5 ++++- kohya.cmd | 1 - tools/convert_diffusers20_original_sd.py | 6 +++--- train_db.py | 3 ++- upgrade.bat | 2 -- 10 files changed, 16 insertions(+), 40 deletions(-) delete mode 100644 dreambooth.cmd delete mode 100644 finetune.cmd delete mode 100644 kohya.cmd delete mode 100644 upgrade.bat diff --git a/README.md b/README.md index e75d529..3439be4 100644 --- a/README.md +++ b/README.md @@ -14,6 +14,9 @@ You can find the finetune solution spercific [Finetune README](README_finetune.m ## Change history +* 12/23 (v18.8) update: + - Fix for conversion tool issue when the source was an sd1.x diffuser model + - Other minor code and GUI fix * 12/22 (v18.7) update: - Merge dreambooth and finetune is a common GUI - General bug fixes and code improvements diff --git a/README_dreambooth.md b/README_dreambooth.md index 6735f78..0822aa4 100644 --- a/README_dreambooth.md +++ b/README_dreambooth.md @@ -67,12 +67,6 @@ python .\tools\cudann_1.8_install.py When a new release comes out you can upgrade your repo with the following command: -``` -.\upgrade.bat -``` - -alternatively you can do it manually with - ```powershell cd kohya_ss git pull @@ -87,15 +81,8 @@ Once the commands have completed successfully you should be ready to use the new There is now support for GUI based training using gradio. You can start the complete kohya training GUI interface by running: ```powershell -.\kohya.cmd -``` - -and select the Dreambooth tab. - -Alternativelly you can use the Dreambooth focus GUI with - -```powershell -.\dreambooth.cmd +.\venv\Scripts\activate +.\kohya_gui.cmd ``` ## CLI diff --git a/README_finetune.md b/README_finetune.md index a1f1240..962888d 100644 --- a/README_finetune.md +++ b/README_finetune.md @@ -67,12 +67,6 @@ python .\tools\cudann_1.8_install.py When a new release comes out you can upgrade your repo with the following command: -``` -.\upgrade.bat -``` - -or you can do it manually with - ```powershell cd kohya_ss git pull @@ -110,15 +104,8 @@ You can also use the `Captioning` tool found under the `Utilities` tab in the GU There is now support for GUI based training using gradio. You can start the complete kohya training GUI interface by running: ```powershell -.\kohya.cmd -``` - -and select the Finetune tab. - -Alternativelly you can use the Finetune focus GUI with - -```powershell -.\finetune.cmd +.\venv\Scripts\activate +.\kohya_gui.cmd ``` ## CLI diff --git a/dreambooth.cmd b/dreambooth.cmd deleted file mode 100644 index 57bc144..0000000 --- a/dreambooth.cmd +++ /dev/null @@ -1 +0,0 @@ -.\venv\Scripts\python.exe .\dreambooth_gui.py \ No newline at end of file diff --git a/finetune.cmd b/finetune.cmd deleted file mode 100644 index 6067935..0000000 --- a/finetune.cmd +++ /dev/null @@ -1 +0,0 @@ -.\venv\Scripts\python.exe .\finetune_gui.py \ No newline at end of file diff --git a/finetune/make_captions.py b/finetune/make_captions.py index 5808051..601f0cc 100644 --- a/finetune/make_captions.py +++ b/finetune/make_captions.py @@ -24,10 +24,13 @@ def main(args): random.seed(seed) if not os.path.exists("blip"): + args.train_data_dir = os.path.abspath(args.train_data_dir) # convert to absolute path + cwd = os.getcwd() print('Current Working Directory is: ', cwd) os.chdir('finetune') + print(f"load images from {args.train_data_dir}") image_paths = glob.glob(os.path.join(args.train_data_dir, "*.jpg")) + \ glob.glob(os.path.join(args.train_data_dir, "*.png")) + glob.glob(os.path.join(args.train_data_dir, "*.webp")) print(f"found {len(image_paths)} images.") @@ -105,4 +108,4 @@ if __name__ == '__main__': if args.caption_extention is not None: args.caption_extension = args.caption_extention - main(args) + main(args) \ No newline at end of file diff --git a/kohya.cmd b/kohya.cmd deleted file mode 100644 index c8129e3..0000000 --- a/kohya.cmd +++ /dev/null @@ -1 +0,0 @@ -.\venv\Scripts\python.exe .\kohya_gui.py \ No newline at end of file diff --git a/tools/convert_diffusers20_original_sd.py b/tools/convert_diffusers20_original_sd.py index d7f2c1e..3cff283 100644 --- a/tools/convert_diffusers20_original_sd.py +++ b/tools/convert_diffusers20_original_sd.py @@ -9,7 +9,7 @@ import os import torch from diffusers import StableDiffusionPipeline -from library import model_util as model_util +import library.model_util as model_util def convert(args): @@ -48,7 +48,7 @@ def convert(args): v2_model = unet.config.cross_attention_dim == 1024 print("checking model version: model is " + ('v2' if v2_model else 'v1')) else: - v2_model = args.v1 + v2_model = not args.v1 # 変換して保存する msg = ("checkpoint" + ("" if save_dtype is None else f" in {save_dtype}")) if is_save_ckpt else "Diffusers" @@ -90,4 +90,4 @@ if __name__ == '__main__': help="model to save: checkpoint (with extension) or Diffusers model's directory (without extension) / 変換後のモデル、拡張子がある場合はcheckpoint、ない場合はDiffusesモデルとして保存") args = parser.parse_args() - convert(args) + convert(args) \ No newline at end of file diff --git a/train_db.py b/train_db.py index 9ae6c8c..75186f5 100644 --- a/train_db.py +++ b/train_db.py @@ -1011,6 +1011,7 @@ def train(args): if stop_text_encoder_training: print(f"stop text encoder training at step {global_step}") text_encoder.train(False) + text_encoder.requires_grad_(False) with accelerator.accumulate(unet): with torch.no_grad(): @@ -1225,4 +1226,4 @@ if __name__ == '__main__': help="Number of steps for the warmup in the lr scheduler (default is 0) / 学習率のスケジューラをウォームアップするステップ数(デフォルト0)") args = parser.parse_args() - train(args) + train(args) \ No newline at end of file diff --git a/upgrade.bat b/upgrade.bat deleted file mode 100644 index 1db1b95..0000000 --- a/upgrade.bat +++ /dev/null @@ -1,2 +0,0 @@ -git pull -.\venv\Scripts\python.exe -m pip install -U -r .\requirements.txt \ No newline at end of file