|
1 | 1 | import os
|
2 | 2 | import time
|
| 3 | +import logging |
3 | 4 |
|
4 | 5 | supported_pt_extensions = set(['.ckpt', '.pt', '.bin', '.pth', '.safetensors'])
|
5 | 6 |
|
|
44 | 45 | try:
|
45 | 46 | os.makedirs(input_directory)
|
46 | 47 | except:
|
47 |
| - print("Failed to create input directory") |
| 48 | + logging.error("Failed to create input directory") |
48 | 49 |
|
49 | 50 | def set_output_directory(output_dir):
|
50 | 51 | global output_directory
|
@@ -146,21 +147,23 @@ def recursive_search(directory, excluded_dir_names=None):
|
146 | 147 | try:
|
147 | 148 | dirs[directory] = os.path.getmtime(directory)
|
148 | 149 | except FileNotFoundError:
|
149 |
| - print(f"Warning: Unable to access {directory}. Skipping this path.") |
150 |
| - |
| 150 | + logging.warning(f"Warning: Unable to access {directory}. Skipping this path.") |
| 151 | + |
| 152 | + logging.debug("recursive file list on directory {}".format(directory)) |
151 | 153 | for dirpath, subdirs, filenames in os.walk(directory, followlinks=True, topdown=True):
|
152 | 154 | subdirs[:] = [d for d in subdirs if d not in excluded_dir_names]
|
153 | 155 | for file_name in filenames:
|
154 | 156 | relative_path = os.path.relpath(os.path.join(dirpath, file_name), directory)
|
155 | 157 | result.append(relative_path)
|
156 |
| - |
| 158 | + |
157 | 159 | for d in subdirs:
|
158 | 160 | path = os.path.join(dirpath, d)
|
159 | 161 | try:
|
160 | 162 | dirs[path] = os.path.getmtime(path)
|
161 | 163 | except FileNotFoundError:
|
162 |
| - print(f"Warning: Unable to access {path}. Skipping this path.") |
| 164 | + logging.warning(f"Warning: Unable to access {path}. Skipping this path.") |
163 | 165 | continue
|
| 166 | + logging.debug("found {} files".format(len(result))) |
164 | 167 | return result, dirs
|
165 | 168 |
|
166 | 169 | def filter_files_extensions(files, extensions):
|
@@ -248,8 +251,8 @@ def compute_vars(input, image_width, image_height):
|
248 | 251 | err = "**** ERROR: Saving image outside the output folder is not allowed." + \
|
249 | 252 | "\n full_output_folder: " + os.path.abspath(full_output_folder) + \
|
250 | 253 | "\n output_dir: " + output_dir + \
|
251 |
| - "\n commonpath: " + os.path.commonpath((output_dir, os.path.abspath(full_output_folder))) |
252 |
| - print(err) |
| 254 | + "\n commonpath: " + os.path.commonpath((output_dir, os.path.abspath(full_output_folder))) |
| 255 | + logging.error(err) |
253 | 256 | raise Exception(err)
|
254 | 257 |
|
255 | 258 | try:
|
|
0 commit comments