mirror of
https://github.com/facefusion/facefusion.git
synced 2026-04-23 09:56:11 +02:00
56 lines
1.7 KiB
Python
56 lines
1.7 KiB
Python
import io
|
|
import os
|
|
import tempfile
|
|
from functools import partial
|
|
|
|
from facefusion.filesystem import are_images, create_directory, is_directory, is_file, remove_directory, resolve_file_paths
|
|
from facefusion.types import JobStatus
|
|
|
|
|
|
def is_test_job_file(file_path : str, job_status : JobStatus) -> bool:
|
|
return is_file(get_test_job_file(file_path, job_status))
|
|
|
|
|
|
def get_test_job_file(file_path : str, job_status : JobStatus) -> str:
|
|
return os.path.join(get_test_jobs_directory(), job_status, file_path)
|
|
|
|
|
|
def get_test_jobs_directory() -> str:
|
|
return os.path.join(tempfile.gettempdir(), 'facefusion-test-jobs')
|
|
|
|
|
|
def get_test_example_file(file_path : str) -> str:
|
|
return os.path.join(get_test_examples_directory(), file_path)
|
|
|
|
|
|
def get_test_examples_directory() -> str:
|
|
return os.path.join(tempfile.gettempdir(), 'facefusion-test-examples')
|
|
|
|
|
|
def is_test_output_file(file_path : str) -> bool:
|
|
return is_file(get_test_output_path(file_path))
|
|
|
|
|
|
def is_test_output_sequence(directory_path : str) -> bool:
|
|
return are_images(resolve_file_paths(directory_path))
|
|
|
|
|
|
def get_test_output_path(file_path : str) -> str:
|
|
return os.path.join(get_test_outputs_directory(), file_path)
|
|
|
|
|
|
def get_test_outputs_directory() -> str:
|
|
return os.path.join(tempfile.gettempdir(), 'facefusion-test-outputs')
|
|
|
|
|
|
def prepare_test_output_directory() -> bool:
|
|
test_outputs_directory = get_test_outputs_directory()
|
|
remove_directory(test_outputs_directory)
|
|
create_directory(test_outputs_directory)
|
|
return is_directory(test_outputs_directory)
|
|
|
|
|
|
def create_media_reader(file_path : str) -> partial[bytes]: #todo: kill this
|
|
file_buffer = io.BytesIO(open(file_path, 'rb').read())
|
|
return partial(file_buffer.read, 1024)
|