From 783d4b07fc4b7031122ab87ed1f3df55a23c68ac Mon Sep 17 00:00:00 2001 From: Mike Howles Date: Tue, 31 Jan 2023 14:03:29 -0600 Subject: [PATCH 1/2] Add ckpt to diffusers script --- scripts/convert_sd_to_diffusers_cli.py | 29 ++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 scripts/convert_sd_to_diffusers_cli.py diff --git a/scripts/convert_sd_to_diffusers_cli.py b/scripts/convert_sd_to_diffusers_cli.py new file mode 100644 index 0000000..1bde976 --- /dev/null +++ b/scripts/convert_sd_to_diffusers_cli.py @@ -0,0 +1,29 @@ +import sys +import os +try: + import converters +except ImportError: + + #if there's a scripts folder where the script is, add it to the path + if 'scripts' in os.listdir(os.path.dirname(os.path.abspath(__file__))): + sys.path.append(os.path.dirname(os.path.abspath(__file__)) + '\\scripts') + else: + print('Could not find scripts folder. Please add it to the path manually or place this file in it.') + import converters + + +if __name__ == '__main__': + args = sys.argv[1:] + if len(args) != 4: + print('Usage: python3 convert_sd_to_diffusers.py ') + sys.exit(1) + checkpoint_path = args[0] + output_path = args[1] + version = args[2] + prediction_type = args[3] + converters.Convert_SD_to_Diffusers( + checkpoint_path, + output_path, + version = version, + prediction_type = prediction_type + ) \ No newline at end of file From 222a8c1961a277ec4d53105e6173d685ef9e9209 Mon Sep 17 00:00:00 2001 From: Mike Howles Date: Wed, 1 Feb 2023 17:31:50 -0600 Subject: [PATCH 2/2] Only image files when autobalancing concepts --- scripts/trainer.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/scripts/trainer.py b/scripts/trainer.py index a8cc97a..1d5a870 100644 --- a/scripts/trainer.py +++ b/scripts/trainer.py @@ -1047,10 +1047,17 @@ def __init__( if concept['use_sub_dirs'] == 1: tot = 0 for root, dirs, files in os.walk(concept['instance_data_dir']): - tot += len(files) + for file in files: + if file.endswith( ('.jpg','.jpeg','.png','.webp','.bmp','.JPG','.JPEG','.PNG','.WEBP','.BMP')): + tot += 1 count = tot else: - count = len(os.listdir(concept['instance_data_dir'])) + tot = 0 + files = os.listdir(concept['instance_data_dir']) + for file in files: + if file.endswith( ('.jpg','.jpeg','.png','.webp','.bmp','.JPG','.JPEG','.PNG','.WEBP','.BMP')): + tot += 1 + count = tot else: count = len(os.listdir(concept['instance_data_dir'])) print(f"{concept['instance_data_dir']} has count of {count}")