|
|
@ -1,5 +1,6 @@ |
|
|
|
import os |
|
|
|
import os |
|
|
|
import time |
|
|
|
import time |
|
|
|
|
|
|
|
import logging |
|
|
|
|
|
|
|
|
|
|
|
supported_pt_extensions = set(['.ckpt', '.pt', '.bin', '.pth', '.safetensors']) |
|
|
|
supported_pt_extensions = set(['.ckpt', '.pt', '.bin', '.pth', '.safetensors']) |
|
|
|
|
|
|
|
|
|
|
@ -44,7 +45,7 @@ if not os.path.exists(input_directory): |
|
|
|
try: |
|
|
|
try: |
|
|
|
os.makedirs(input_directory) |
|
|
|
os.makedirs(input_directory) |
|
|
|
except: |
|
|
|
except: |
|
|
|
print("Failed to create input directory") |
|
|
|
logging.error("Failed to create input directory") |
|
|
|
|
|
|
|
|
|
|
|
def set_output_directory(output_dir): |
|
|
|
def set_output_directory(output_dir): |
|
|
|
global output_directory |
|
|
|
global output_directory |
|
|
@ -146,21 +147,23 @@ def recursive_search(directory, excluded_dir_names=None): |
|
|
|
try: |
|
|
|
try: |
|
|
|
dirs[directory] = os.path.getmtime(directory) |
|
|
|
dirs[directory] = os.path.getmtime(directory) |
|
|
|
except FileNotFoundError: |
|
|
|
except FileNotFoundError: |
|
|
|
print(f"Warning: Unable to access {directory}. Skipping this path.") |
|
|
|
logging.warning(f"Warning: Unable to access {directory}. Skipping this path.") |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
logging.debug("recursive file list on directory {}".format(directory)) |
|
|
|
for dirpath, subdirs, filenames in os.walk(directory, followlinks=True, topdown=True): |
|
|
|
for dirpath, subdirs, filenames in os.walk(directory, followlinks=True, topdown=True): |
|
|
|
subdirs[:] = [d for d in subdirs if d not in excluded_dir_names] |
|
|
|
subdirs[:] = [d for d in subdirs if d not in excluded_dir_names] |
|
|
|
for file_name in filenames: |
|
|
|
for file_name in filenames: |
|
|
|
relative_path = os.path.relpath(os.path.join(dirpath, file_name), directory) |
|
|
|
relative_path = os.path.relpath(os.path.join(dirpath, file_name), directory) |
|
|
|
result.append(relative_path) |
|
|
|
result.append(relative_path) |
|
|
|
|
|
|
|
|
|
|
|
for d in subdirs: |
|
|
|
for d in subdirs: |
|
|
|
path = os.path.join(dirpath, d) |
|
|
|
path = os.path.join(dirpath, d) |
|
|
|
try: |
|
|
|
try: |
|
|
|
dirs[path] = os.path.getmtime(path) |
|
|
|
dirs[path] = os.path.getmtime(path) |
|
|
|
except FileNotFoundError: |
|
|
|
except FileNotFoundError: |
|
|
|
print(f"Warning: Unable to access {path}. Skipping this path.") |
|
|
|
logging.warning(f"Warning: Unable to access {path}. Skipping this path.") |
|
|
|
continue |
|
|
|
continue |
|
|
|
|
|
|
|
logging.debug("found {} files".format(len(result))) |
|
|
|
return result, dirs |
|
|
|
return result, dirs |
|
|
|
|
|
|
|
|
|
|
|
def filter_files_extensions(files, extensions): |
|
|
|
def filter_files_extensions(files, extensions): |
|
|
@ -248,8 +251,8 @@ def get_save_image_path(filename_prefix, output_dir, image_width=0, image_height |
|
|
|
err = "**** ERROR: Saving image outside the output folder is not allowed." + \ |
|
|
|
err = "**** ERROR: Saving image outside the output folder is not allowed." + \ |
|
|
|
"\n full_output_folder: " + os.path.abspath(full_output_folder) + \ |
|
|
|
"\n full_output_folder: " + os.path.abspath(full_output_folder) + \ |
|
|
|
"\n output_dir: " + output_dir + \ |
|
|
|
"\n output_dir: " + output_dir + \ |
|
|
|
"\n commonpath: " + os.path.commonpath((output_dir, os.path.abspath(full_output_folder))) |
|
|
|
"\n commonpath: " + os.path.commonpath((output_dir, os.path.abspath(full_output_folder))) |
|
|
|
print(err) |
|
|
|
logging.error(err) |
|
|
|
raise Exception(err) |
|
|
|
raise Exception(err) |
|
|
|
|
|
|
|
|
|
|
|
try: |
|
|
|
try: |
|
|
|