Next (#544)
* Modernize CI * Modernize CI * Modernize CI * Implement dynamic config (#518) * Implement dynamic config * Fix apply config * Move config to general * Move config to general * Move config to general * Add Windows installer * Add --open-browser * Add Windows installer part2 * Use non-commercial license for the installer * Fix create environment in installer * Fix openvino for installer * Fix conda for installer * Fix conda for installer, Remove python and pip as it is part of conda * Improve installer - guess the path * Fix CI * Add missing accept-source-agreements to installer * Install WinGet * Improve WinGet installation steps * Use absolute path for winget * More installer polishing * Add final page to installer, disable version check for Gradio * Remove finish page again * Use NEXT for metadata * Support for /S mode * Use winget-less approach * Improve Conda uninstall * Improve code using platform helpers (#529) * Update dependencies * Feat/fix windows unicode paths (#531) * Fix the Windows unicode path dilemma * Update dependencies * Fix the Windows unicode path dilemma part2 * Remove conda environment on uninstall * Fix uninstall command * Install apps for local user only * Add ultra sharp * Add clear reality * Update README and FUNDING * Update FUNDING.yml * Prevent preview of large videos in Gradio (#540) * Fix order * Refactor temporary file management, Use temporary file for image processing (#542) * Allow webm on target component * Reduce mosaic effect for frame processors * clear static faces on trim frame changes * Fix trim frame component * Downgrade openvino dependency * Prepare next release * Move get_short_path to filesystem, Add/Improve some testing * Prepare installer, Prevent infinite loop for sanitize_path_for_windows * Introduce execution device id * Introduce execution device id * Seems like device id can be a string * Seems like device id can be a string * Make Intel Arc work with OpenVINOExecution * Use latest Git * Update wording * Fix create_float_range * Update preview * Fix Git link
This commit is contained in:
@@ -7,9 +7,10 @@ import filetype
|
||||
from pathlib import Path
|
||||
|
||||
import facefusion.globals
|
||||
from facefusion.common_helper import is_windows
|
||||
|
||||
TEMP_DIRECTORY_PATH = os.path.join(tempfile.gettempdir(), 'facefusion')
|
||||
TEMP_OUTPUT_VIDEO_NAME = 'temp.mp4'
|
||||
if is_windows():
|
||||
import ctypes
|
||||
|
||||
|
||||
def get_temp_frame_paths(target_path : str) -> List[str]:
|
||||
@@ -22,14 +23,16 @@ def get_temp_frames_pattern(target_path : str, temp_frame_prefix : str) -> str:
|
||||
return os.path.join(temp_directory_path, temp_frame_prefix + '.' + facefusion.globals.temp_frame_format)
|
||||
|
||||
|
||||
def get_temp_file_path(target_path : str) -> str:
|
||||
_, target_extension = os.path.splitext(os.path.basename(target_path))
|
||||
temp_directory_path = get_temp_directory_path(target_path)
|
||||
return os.path.join(temp_directory_path, 'temp' + target_extension)
|
||||
|
||||
|
||||
def get_temp_directory_path(target_path : str) -> str:
|
||||
target_name, _ = os.path.splitext(os.path.basename(target_path))
|
||||
return os.path.join(TEMP_DIRECTORY_PATH, target_name)
|
||||
|
||||
|
||||
def get_temp_output_video_path(target_path : str) -> str:
|
||||
temp_directory_path = get_temp_directory_path(target_path)
|
||||
return os.path.join(temp_directory_path, TEMP_OUTPUT_VIDEO_NAME)
|
||||
temp_directory_path = os.path.join(tempfile.gettempdir(), 'facefusion')
|
||||
return os.path.join(temp_directory_path, target_name)
|
||||
|
||||
|
||||
def create_temp(target_path : str) -> None:
|
||||
@@ -38,22 +41,30 @@ def create_temp(target_path : str) -> None:
|
||||
|
||||
|
||||
def move_temp(target_path : str, output_path : str) -> None:
|
||||
temp_output_video_path = get_temp_output_video_path(target_path)
|
||||
if is_file(temp_output_video_path):
|
||||
temp_file_path = get_temp_file_path(target_path)
|
||||
|
||||
if is_file(temp_file_path):
|
||||
if is_file(output_path):
|
||||
os.remove(output_path)
|
||||
shutil.move(temp_output_video_path, output_path)
|
||||
shutil.move(temp_file_path, output_path)
|
||||
|
||||
|
||||
def clear_temp(target_path : str) -> None:
|
||||
temp_directory_path = get_temp_directory_path(target_path)
|
||||
parent_directory_path = os.path.dirname(temp_directory_path)
|
||||
|
||||
if not facefusion.globals.keep_temp and is_directory(temp_directory_path):
|
||||
shutil.rmtree(temp_directory_path, ignore_errors = True)
|
||||
if os.path.exists(parent_directory_path) and not os.listdir(parent_directory_path):
|
||||
os.rmdir(parent_directory_path)
|
||||
|
||||
|
||||
def get_file_size(file_path : str) -> int:
|
||||
if is_file(file_path):
|
||||
return os.path.getsize(file_path)
|
||||
return 0
|
||||
|
||||
|
||||
def is_file(file_path : str) -> bool:
|
||||
return bool(file_path and os.path.isfile(file_path))
|
||||
|
||||
@@ -105,5 +116,20 @@ def resolve_relative_path(path : str) -> str:
|
||||
def list_directory(directory_path : str) -> Optional[List[str]]:
|
||||
if is_directory(directory_path):
|
||||
files = os.listdir(directory_path)
|
||||
return sorted([ Path(file).stem for file in files if not Path(file).stem.startswith(('.', '__')) ])
|
||||
files = [ Path(file).stem for file in files if not Path(file).stem.startswith(('.', '__')) ]
|
||||
return sorted(files)
|
||||
return None
|
||||
|
||||
|
||||
def sanitize_path_for_windows(full_path : str) -> Optional[str]:
|
||||
buffer_size = 0
|
||||
|
||||
while True:
|
||||
unicode_buffer = ctypes.create_unicode_buffer(buffer_size)
|
||||
buffer_threshold = ctypes.windll.kernel32.GetShortPathNameW(full_path, unicode_buffer, buffer_size) #type:ignore[attr-defined]
|
||||
|
||||
if buffer_size > buffer_threshold:
|
||||
return unicode_buffer.value
|
||||
if buffer_threshold == 0:
|
||||
return None
|
||||
buffer_size = buffer_threshold
|
||||
|
||||
Reference in New Issue
Block a user