Feat/custom file format handling (#845)
* Purge filetype dependency, Rename file_extension to file_format, Introduce custom format detections * Changed a lot * Purge filetype dependency, Rename file_extension to file_format, Introduce custom format detections * Fix stuff * Fix stuff * Simplify all the is_ and has_ methods * Simplify all the is_ and has_ methods * Use the new helper on more places * Introduce are_ next to is_ and has_ * Get rid of the type-ignores * Add more video types
This commit is contained in:
@@ -2,11 +2,14 @@ import os
|
||||
from datetime import datetime
|
||||
from typing import Optional
|
||||
|
||||
from facefusion.filesystem import get_file_extension, get_file_name
|
||||
|
||||
|
||||
def get_step_output_path(job_id : str, step_index : int, output_path : str) -> Optional[str]:
|
||||
if output_path:
|
||||
output_directory_path, _ = os.path.split(output_path)
|
||||
output_file_name, output_file_extension = os.path.splitext(_)
|
||||
output_file_name = get_file_name(_)
|
||||
output_file_extension = get_file_extension(_)
|
||||
return os.path.join(output_directory_path, output_file_name + '-' + job_id + '-' + str(step_index) + output_file_extension)
|
||||
return None
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@ from typing import List, Optional
|
||||
|
||||
import facefusion.choices
|
||||
from facefusion.date_helper import get_current_date_time
|
||||
from facefusion.filesystem import create_directory, is_directory, is_file, move_file, remove_directory, remove_file, resolve_file_pattern
|
||||
from facefusion.filesystem import create_directory, get_file_name, is_directory, is_file, move_file, remove_directory, remove_file, resolve_file_pattern
|
||||
from facefusion.jobs.job_helper import get_step_output_path
|
||||
from facefusion.json import read_json, write_json
|
||||
from facefusion.typing import Args, Job, JobSet, JobStatus, JobStep, JobStepStatus
|
||||
@@ -90,7 +90,7 @@ def find_job_ids(job_status : JobStatus) -> List[str]:
|
||||
job_ids = []
|
||||
|
||||
for job_path in job_paths:
|
||||
job_id, _ = os.path.splitext(os.path.basename(job_path))
|
||||
job_id = get_file_name(job_path)
|
||||
job_ids.append(job_id)
|
||||
return job_ids
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
from facefusion.ffmpeg import concat_video
|
||||
from facefusion.filesystem import is_image, is_video, move_file, remove_file
|
||||
from facefusion.filesystem import are_images, are_videos, move_file, remove_file
|
||||
from facefusion.jobs import job_helper, job_manager
|
||||
from facefusion.typing import JobOutputSet, JobStep, ProcessStep
|
||||
|
||||
@@ -73,10 +73,10 @@ def finalize_steps(job_id : str) -> bool:
|
||||
output_set = collect_output_set(job_id)
|
||||
|
||||
for output_path, temp_output_paths in output_set.items():
|
||||
if all(map(is_video, temp_output_paths)):
|
||||
if are_videos(temp_output_paths):
|
||||
if not concat_video(output_path, temp_output_paths):
|
||||
return False
|
||||
if any(map(is_image, temp_output_paths)):
|
||||
if are_images(temp_output_paths):
|
||||
for temp_output_path in temp_output_paths:
|
||||
if not move_file(temp_output_path, output_path):
|
||||
return False
|
||||
|
||||
Reference in New Issue
Block a user