Skip to content
This repository has been archived by the owner on Oct 22, 2023. It is now read-only.

Add ckpt to diffusers script #94

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions scripts/convert_sd_to_diffusers_cli.py
Original file line number Diff line number Diff line change
@@ -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 <model_path> <output_path> <version> <prediction_type>')
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
)
11 changes: 9 additions & 2 deletions scripts/trainer.py
Original file line number Diff line number Diff line change
Expand Up @@ -1064,10 +1064,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}")
Expand Down