File size: 763 Bytes
3914b35 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
import hashlib
import os
from typing import Optional
from facefusion import state_manager
from facefusion.filesystem import get_file_extension, is_image, is_video
def convert_int_none(value : int) -> Optional[int]:
if value == 'none':
return None
return value
def convert_str_none(value : str) -> Optional[str]:
if value == 'none':
return None
return value
def suggest_output_path(output_directory_path : str, target_path : str) -> Optional[str]:
if is_image(target_path) or is_video(target_path):
output_file_name = hashlib.sha1(str(state_manager.get_state()).encode()).hexdigest()[:8]
target_file_extension = get_file_extension(target_path)
return os.path.join(output_directory_path, output_file_name + target_file_extension)
return None
|