INNER CODE UNIT · Python
cleanup
fofr/cog-face-to-sticker · predict.py:25
def cleanup(self):
self.comfyUI.clear_queue()
for directory in [OUTPUT_DIR, INPUT_DIR, COMFYUI_TEMP_OUTPUT_DIR]:
if os.path.exists(directory):
shutil.rmtree(directory)
os.makedirs(directory)
def handle_input_file(self, input_file: Path):
file_extension = os.path.splitext(input_file)[1].lower()
if file_extension in [".jpg", ".jpeg", ".png", ".webp"]:
filename = f"input{file_extension}"
shutil.copy(input_file, os.path.join(INPUT_DIR, filename))
else:
raise ValueError(f"Unsupported file type: {file_extension}")
return filename
def log_and_collect_files(self, directory, prefix=""):