Compare commits

..
Author SHA1 Message Date
Henry RuhsandGitHub 11bbc89a0e modernize ffmpeg in test suite (#1190) 2026-07-23 15:07:27 +02:00
0ce48da740 rename workflow to workflow-mode ahead of workflow-strategy (#1186)
Claude-Session: https://claude.ai/code/session_01Tbcd6VWCiU4BQP1gywPr2a

Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
2026-07-23 13:12:20 +02:00
2c72bb21c8 drop the unused format_to_value from ffprobe_builder (#1183)
Claude-Session: https://claude.ai/code/session_01Tbcd6VWCiU4BQP1gywPr2a

Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
2026-07-23 11:39:24 +02:00
henryruhs 280713ed13 move analyse_image to the correct file 2026-07-23 09:46:38 +02:00
Henry Ruhs 3834e3856a patch-3.7.1 (#1178)
* patch 3.7.1

* fix bug for 2 processors on image to image pipeline (#1177)

* reduce default value of target_frame_amount

* restore old performance

* restore old performance

* restore old performance

* restore old performance
2026-07-05 18:39:08 +02:00
ac9f514d60 3.7.0 (#1175)
* mark as next, introduce dynamic scale for face debugger

* use latest onnxruntime

* update within Gradio 5

* Remove system memory limit (#986)

* remove system memory limit from ui

* remove system memory limit from args.py

* flatten the face store

* prevent countless importlib.import_module calls

* remove --onnxruntime from install.py

* remove --onnxruntime from install.py

* resolve static inference providers to fix macos (#1127)

* resolve static inference providers to fix macos

* fix lint

* restore old behaviour

* restore old behaviour

* handle ghost and uniface as well

* adjust condition for ghost and uniface

* fix Gradio gallery styles

* remove face store (#1132)

* fix dataflow in streamer

* Face selector auto mode (#1137)

* introduce face selector auto mode

* introduce face selector auto mode

* introduce face selector auto mode

* correct way is to pass source_vision_frames

* make the world a better place

* fix dataflow in faceswapper, no read of files withing inner methods (#1148)

* fix dataflow in faceswapper, no read of files withing inner methods

* fix lint

* adjust code more

* adjust code more

* bring back the face store but for source and reference only (#1149)

* bring back the face store but for source and reference only

* fix ci

* minor improvement

* guard for tobytes()

* drop condition in select_faces()

* Replace CONFIG_PARSER global with @lru_cache (#1147)

* remove global config_parser

* fix import order

* remove lambda

* remove unused block

* optimize app context detection

* decouple common modules from core (#1152)

* decouple common modules from core

* remove that nonsense

* remove that nonsense

* minor adjustment to workflows

* Tag HEVC output as hvc1 and move moov atom to the front (#1153)

* Tag HEVC output as hvc1 and move moov atom to the front

ffmpeg defaults HEVC in MP4 to the 'hev1' sample entry and leaves the moov
atom at the tail. Apple players (QuickTime, Finder QuickLook) refuse to decode
'hev1' and stall reading a tail-placed moov on large files, so hevc_nvenc /
libx265 renders cannot be previewed on macOS.

- add ffmpeg_builder.set_video_tag(): emit `-tag:v hvc1` for every HEVC
  encoder (libx265, hevc_nvenc, hevc_amf, hevc_qsv, hevc_videotoolbox).
  Applied in merge_video where the encoder is known; `-c:v copy` in the audio
  mux / concat steps preserves the tag.
- add ffmpeg_builder.set_faststart(): emit `-movflags +faststart`, applied in
  restore_audio / replace_audio / concat_video which write the final output.

H.264 and other codecs are left untouched. Verified on a real hevc_nvenc
render: hev1 hung QuickLook (no thumbnail); after the patch the file is hvc1
with a front-placed moov and QuickLook generates a thumbnail.

* Restrict hvc1 tag and faststart to quicktime containers

Gate set_video_tag / set_faststart on the output container format
(m4v, mov, mp4) via get_file_format(), so non-quicktime muxers no longer
receive -tag:v hvc1 / -movflags +faststart. Trim test_set_video_tag to a
single positive and negative assertion.

Addresses review on #1153.

* Move hvc1 tag and faststart gates into ffmpeg_builder

Rename set_video_tag / set_faststart to conditional_* and push the
container-format gate (m4v, mov, mp4) inside the builders, keeping
ffmpeg.py free of inline conditionals. Matches the set_image_quality
pattern. Addresses review on #1153.

* post cleanup after merge

* Pack target frames (#1158)

* pack target frames

* add todos

* add todos, resolve todos

* resolve todos

* change names

* revert to single target frame for select faces

* fix lint

* return empty frame

* get() have no default

* Fix trim (#1162)

* fix trim

* fix trim

* rename ffmpeg builder method

* rename to temp_frame_set and temp_frame_pattern

---------

Co-authored-by: harisreedhar <h4harisreedhar.s.s@gmail.com>
Co-authored-by: Harisreedhar <46858047+harisreedhar@users.noreply.github.com>

* Implement face tracker (#1163)

* add face tracker

* change get_nearest_track_face -> get_nearest_track_index

* create face_creator.py and move methods around

* add type FaceTrack

* naming

* remove iou test, don't belong there

* fix spaces

* rename to interpolate_points

* rename to find_best_face_track

* just track_faces

* cleanp

* previous next naming

* remove >= and >=

* rename

* remove helper from test and use face from source.jpg

* make get_anchor_indices more readable

* track_faces() call before and is forwarded to select_faces

* change to interpolate_faces

* rename methods

* rename methods

* rename variables

* remove dtype

* move face_anlyser -> face_creator

* claenup face_creator.py

* move tests to dedicated test face detector

* move tracking inside select_faces

* simplify face_tracker (#1165)

* minor renaming

* improve face_tracker test (#1166)

* improve face_tracker test

* cleanup

* Add target frame amount (#1167)

* introduce --target-frame-amount

* add ui

* make track_faces conditional

* update choices.py

* fix []

* rename component file to frame_process.py

* fix track preview (#1168)

* introduce face origin (#1169)

* add guard to prevent failure

* show and hide voice extractor according to lip syncer

* rename average_face_coordinates to average_face_geometry

* use static faces for select_faces()

* face store with lock (#1171)

* face store with lock

* face store with lock

* remove refill color from bbox

* adjust tests and handle frame_position proper way

* enforce similar naming

* introduce face tracker score

* introduce face tracker score

* fix/audio-trim-alignment (#1173)

* fix audio offset

* fix audio offset

* remove reference_frame_number check

---------

Co-authored-by: harisreedhar <h4harisreedhar.s.s@gmail.com>

* reduce face tracker score from 0 to 0.5

* mark as 3.7.0

* make face tracker stateless

---------

Co-authored-by: Harisreedhar <46858047+harisreedhar@users.noreply.github.com>
Co-authored-by: kazuki nakai <kazuki.nakai@agiletec.net>
Co-authored-by: harisreedhar <h4harisreedhar.s.s@gmail.com>
2026-07-05 18:31:39 +02:00
55 changed files with 617 additions and 377 deletions
+1 -1
View File
@@ -1,5 +1,5 @@
[workflow] [workflow]
workflow = workflow_mode =
[paths] [paths]
temp_path = temp_path =
+1 -1
View File
@@ -15,6 +15,6 @@ async def get_capabilities(request : Request) -> JSONResponse:
'image': facefusion.choices.image_formats, 'image': facefusion.choices.image_formats,
'video': facefusion.choices.video_formats 'video': facefusion.choices.video_formats
}, },
'arguments': capability_store.get_api_capability_group() 'arguments': capability_store.get_api_capability_set()
} }
return JSONResponse(capabilities, status_code = HTTP_200_OK) return JSONResponse(capabilities, status_code = HTTP_200_OK)
+1 -1
View File
@@ -11,7 +11,7 @@ from facefusion.vision import detect_video_fps
def apply_args(args : Args, apply_state_item : ApplyStateItem) -> None: def apply_args(args : Args, apply_state_item : ApplyStateItem) -> None:
apply_state_item('command', args.get('command')) apply_state_item('command', args.get('command'))
apply_state_item('workflow', args.get('workflow')) apply_state_item('workflow_mode', args.get('workflow_mode'))
apply_state_item('temp_path', args.get('temp_path')) apply_state_item('temp_path', args.get('temp_path'))
apply_state_item('jobs_path', args.get('jobs_path')) apply_state_item('jobs_path', args.get('jobs_path'))
apply_state_item('source_paths', args.get('source_paths')) apply_state_item('source_paths', args.get('source_paths'))
+3 -14
View File
@@ -1,7 +1,7 @@
from argparse import Action from argparse import Action
from typing import Dict, List from typing import Dict, List
from facefusion.types import CapabilityGroup, CapabilitySet, CapabilityStore, Group, Scope from facefusion.types import CapabilitySet, CapabilityStore, Scope
CAPABILITY_STORE : CapabilityStore =\ CAPABILITY_STORE : CapabilityStore =\
{ {
@@ -11,16 +11,6 @@ CAPABILITY_STORE : CapabilityStore =\
} }
def get_api_capability_group() -> CapabilityGroup:
capability_group : CapabilityGroup = {}
for name, value in CAPABILITY_STORE.get('api').items():
for group in value.get('groups'):
capability_group.setdefault(group, {})[name] = value
return capability_group
def get_api_capability_set() -> Dict[str, CapabilitySet]: def get_api_capability_set() -> Dict[str, CapabilitySet]:
return CAPABILITY_STORE.get('api') return CAPABILITY_STORE.get('api')
@@ -45,12 +35,11 @@ def get_sys_arguments() -> List[str]:
return list(get_sys_capability_set().keys()) return list(get_sys_capability_set().keys())
def register_capability_set(actions : List[Action], scopes : List[Scope], groups : List[Group]) -> None: def register_capability_set(actions : List[Action], scopes : List[Scope]) -> None:
for action in actions: for action in actions:
value : CapabilitySet =\ value : CapabilitySet =\
{ {
'default': action.default, 'default': action.default
'groups': groups
} }
if action.choices: if action.choices:
+2 -2
View File
@@ -2,7 +2,7 @@ import logging
from typing import List, Sequence, get_args from typing import List, Sequence, get_args
from facefusion.common_helper import create_float_range, create_int_range from facefusion.common_helper import create_float_range, create_int_range
from facefusion.types import Angle, ApiSecurityStrategy, AudioEncoder, AudioFormat, AudioSet, BenchmarkMode, BenchmarkResolution, BenchmarkSet, DownloadProvider, DownloadProviderSet, DownloadScope, ExecutionProvider, ExecutionProviderSet, FaceDetectorModel, FaceDetectorSet, FaceLandmarkerModel, FaceMaskArea, FaceMaskAreaSet, FaceMaskRegion, FaceMaskRegionSet, FaceMaskType, FaceOccluderModel, FaceParserModel, FaceSelectorGender, FaceSelectorMode, FaceSelectorOrder, FaceSelectorRace, Gender, ImageEncoder, ImageFormat, ImageSet, JobStatus, LogLevel, LogLevelSet, Race, Score, TempFrameFormat, VideoEncoder, VideoFormat, VideoMemoryStrategy, VideoPreset, VideoSet, VoiceExtractorModel, WorkFlow from facefusion.types import Angle, ApiSecurityStrategy, AudioEncoder, AudioFormat, AudioSet, BenchmarkMode, BenchmarkResolution, BenchmarkSet, DownloadProvider, DownloadProviderSet, DownloadScope, ExecutionProvider, ExecutionProviderSet, FaceDetectorModel, FaceDetectorSet, FaceLandmarkerModel, FaceMaskArea, FaceMaskAreaSet, FaceMaskRegion, FaceMaskRegionSet, FaceMaskType, FaceOccluderModel, FaceParserModel, FaceSelectorGender, FaceSelectorMode, FaceSelectorOrder, FaceSelectorRace, Gender, ImageEncoder, ImageFormat, ImageSet, JobStatus, LogLevel, LogLevelSet, Race, Score, TempFrameFormat, VideoEncoder, VideoFormat, VideoMemoryStrategy, VideoPreset, VideoSet, VoiceExtractorModel, WorkflowMode
face_detector_set : FaceDetectorSet =\ face_detector_set : FaceDetectorSet =\
{ {
@@ -47,7 +47,7 @@ face_mask_regions : List[FaceMaskRegion] = list(get_args(FaceMaskRegion))
voice_extractor_models : List[VoiceExtractorModel] = list(get_args(VoiceExtractorModel)) voice_extractor_models : List[VoiceExtractorModel] = list(get_args(VoiceExtractorModel))
workflows : List[WorkFlow] = [ 'auto', 'audio-to-image:frames', 'audio-to-image:video', 'image-to-image', 'image-to-video', 'image-to-video:frames' ] workflow_modes : List[WorkflowMode] = [ 'auto', 'audio-to-image:frames', 'audio-to-image:video', 'image-to-image', 'image-to-video', 'image-to-video:frames' ]
audio_set : AudioSet =\ audio_set : AudioSet =\
{ {
+9 -9
View File
@@ -19,7 +19,7 @@ from facefusion.jobs.job_list import compose_job_list
from facefusion.processors.core import get_processors_modules from facefusion.processors.core import get_processors_modules
from facefusion.program import create_program from facefusion.program import create_program
from facefusion.program_helper import validate_args from facefusion.program_helper import validate_args
from facefusion.types import Args, ErrorCode, WorkFlow from facefusion.types import Args, ErrorCode, WorkflowMode
from facefusion.workflows import audio_to_image, audio_to_image_as_frames, image_to_image, image_to_video, image_to_video_as_frames from facefusion.workflows import audio_to_image, audio_to_image_as_frames, image_to_image, image_to_video, image_to_video_as_frames
@@ -317,28 +317,28 @@ def process_step(job_id : str, step_index : int, step_args : Args) -> bool:
def conditional_process() -> ErrorCode: def conditional_process() -> ErrorCode:
start_time = time() start_time = time()
if state_manager.get_item('workflow') == 'auto': if state_manager.get_item('workflow_mode') == 'auto':
state_manager.set_item('workflow', detect_workflow()) state_manager.set_item('workflow_mode', detect_workflow_mode())
for processor_module in get_processors_modules(state_manager.get_item('processors')): for processor_module in get_processors_modules(state_manager.get_item('processors')):
if not processor_module.pre_process('output'): if not processor_module.pre_process('output'):
return 2 return 2
if state_manager.get_item('workflow') == 'audio-to-image:video': if state_manager.get_item('workflow_mode') == 'audio-to-image:video':
return audio_to_image.process(start_time) return audio_to_image.process(start_time)
if state_manager.get_item('workflow') == 'audio-to-image:frames': if state_manager.get_item('workflow_mode') == 'audio-to-image:frames':
return audio_to_image_as_frames.process(start_time) return audio_to_image_as_frames.process(start_time)
if state_manager.get_item('workflow') == 'image-to-image': if state_manager.get_item('workflow_mode') == 'image-to-image':
return image_to_image.process(start_time) return image_to_image.process(start_time)
if state_manager.get_item('workflow') == 'image-to-video': if state_manager.get_item('workflow_mode') == 'image-to-video':
return image_to_video.process(start_time) return image_to_video.process(start_time)
if state_manager.get_item('workflow') == 'image-to-video:frames': if state_manager.get_item('workflow_mode') == 'image-to-video:frames':
return image_to_video_as_frames.process(start_time) return image_to_video_as_frames.process(start_time)
return 0 return 0
def detect_workflow() -> WorkFlow: def detect_workflow_mode() -> WorkflowMode:
if has_video([ state_manager.get_item('target_path') ]): if has_video([ state_manager.get_item('target_path') ]):
if get_file_extension(state_manager.get_item('output_path')): if get_file_extension(state_manager.get_item('output_path')):
return 'image-to-video' return 'image-to-video'
-4
View File
@@ -17,10 +17,6 @@ def show_entries(entries : List[str]) -> List[Command]:
return [ '-show_entries', 'stream=' + ','.join(entries) ] return [ '-show_entries', 'stream=' + ','.join(entries) ]
def format_to_value() -> List[Command]:
return [ '-of', 'default=noprint_wrappers=1:nokey=1' ]
def format_to_key_value() -> List[Command]: def format_to_key_value() -> List[Command]:
return [ '-of', 'default=noprint_wrappers=1' ] return [ '-of', 'default=noprint_wrappers=1' ]
+1 -1
View File
@@ -103,7 +103,7 @@ LOCALES : Locales =\
{ {
'install_dependency': 'choose the variant of {dependency} to install', 'install_dependency': 'choose the variant of {dependency} to install',
'skip_conda': 'skip the conda environment check', 'skip_conda': 'skip the conda environment check',
'workflow': 'choose the workflow', 'workflow_mode': 'choose the workflow mode',
'config_path': 'choose the config file to override defaults', 'config_path': 'choose the config file to override defaults',
'temp_path': 'specify the directory for the temporary resources', 'temp_path': 'specify the directory for the temporary resources',
'jobs_path': 'specify the directory to store jobs', 'jobs_path': 'specify the directory to store jobs',
@@ -142,8 +142,7 @@ def register_args(program : ArgumentParser) -> None:
metavar = create_int_metavar(age_modifier_choices.age_modifier_direction_range) metavar = create_int_metavar(age_modifier_choices.age_modifier_direction_range)
) )
], ],
scopes = [ 'api', 'cli' ], scopes = [ 'api', 'cli' ]
groups = [ 'age_modifier' ]
) )
@@ -171,7 +170,7 @@ def pre_process(mode : ProcessMode) -> bool:
if mode in [ 'output', 'preview' ] and not is_image(state_manager.get_item('target_path')) and not is_video(state_manager.get_item('target_path')): if mode in [ 'output', 'preview' ] and not is_image(state_manager.get_item('target_path')) and not is_video(state_manager.get_item('target_path')):
logger.error(translator.get('choose_image_or_video_target') + translator.get('exclamation_mark'), __name__) logger.error(translator.get('choose_image_or_video_target') + translator.get('exclamation_mark'), __name__)
return False return False
if state_manager.get_item('workflow') in [ 'audio-to-image:video', 'image-to-image', 'image-to-video' ]: if state_manager.get_item('workflow_mode') in [ 'audio-to-image:video', 'image-to-image', 'image-to-video' ]:
if mode == 'output' and not in_directory(state_manager.get_item('output_path')): if mode == 'output' and not in_directory(state_manager.get_item('output_path')):
logger.error(translator.get('specify_image_or_video_output') + translator.get('exclamation_mark'), __name__) logger.error(translator.get('specify_image_or_video_output') + translator.get('exclamation_mark'), __name__)
return False return False
@@ -519,8 +519,7 @@ def register_args(program : ArgumentParser) -> None:
nargs = '+' nargs = '+'
) )
], ],
scopes = [ 'api', 'cli' ], scopes = [ 'api', 'cli' ]
groups = [ 'background_remover' ]
) )
@@ -549,7 +548,7 @@ def pre_process(mode : ProcessMode) -> bool:
if mode in [ 'output', 'preview' ] and not is_image(state_manager.get_item('target_path')) and not is_video(state_manager.get_item('target_path')): if mode in [ 'output', 'preview' ] and not is_image(state_manager.get_item('target_path')) and not is_video(state_manager.get_item('target_path')):
logger.error(translator.get('choose_image_or_video_target') + translator.get('exclamation_mark'), __name__) logger.error(translator.get('choose_image_or_video_target') + translator.get('exclamation_mark'), __name__)
return False return False
if state_manager.get_item('workflow') in [ 'audio-to-image:video', 'image-to-image', 'image-to-video' ]: if state_manager.get_item('workflow_mode') in [ 'audio-to-image:video', 'image-to-image', 'image-to-video' ]:
if mode == 'output' and not in_directory(state_manager.get_item('output_path')): if mode == 'output' and not in_directory(state_manager.get_item('output_path')):
logger.error(translator.get('specify_image_or_video_output') + translator.get('exclamation_mark'), __name__) logger.error(translator.get('specify_image_or_video_output') + translator.get('exclamation_mark'), __name__)
return False return False
@@ -294,8 +294,7 @@ def register_args(program : ArgumentParser) -> None:
metavar = create_int_metavar(deep_swapper_choices.deep_swapper_morph_range) metavar = create_int_metavar(deep_swapper_choices.deep_swapper_morph_range)
) )
], ],
scopes = [ 'api', 'cli' ], scopes = [ 'api', 'cli' ]
groups = [ 'deep_swapper' ]
) )
@@ -325,7 +324,7 @@ def pre_process(mode : ProcessMode) -> bool:
if mode in [ 'output', 'preview' ] and not is_image(state_manager.get_item('target_path')) and not is_video(state_manager.get_item('target_path')): if mode in [ 'output', 'preview' ] and not is_image(state_manager.get_item('target_path')) and not is_video(state_manager.get_item('target_path')):
logger.error(translator.get('choose_image_or_video_target') + translator.get('exclamation_mark'), __name__) logger.error(translator.get('choose_image_or_video_target') + translator.get('exclamation_mark'), __name__)
return False return False
if state_manager.get_item('workflow') in [ 'audio-to-image:video', 'image-to-image', 'image-to-video' ]: if state_manager.get_item('workflow_mode') in [ 'audio-to-image:video', 'image-to-image', 'image-to-video' ]:
if mode == 'output' and not in_directory(state_manager.get_item('output_path')): if mode == 'output' and not in_directory(state_manager.get_item('output_path')):
logger.error(translator.get('specify_image_or_video_output') + translator.get('exclamation_mark'), __name__) logger.error(translator.get('specify_image_or_video_output') + translator.get('exclamation_mark'), __name__)
return False return False
@@ -125,8 +125,7 @@ def register_args(program : ArgumentParser) -> None:
metavar = 'EXPRESSION_RESTORER_AREAS' metavar = 'EXPRESSION_RESTORER_AREAS'
) )
], ],
scopes = [ 'api', 'cli' ], scopes = [ 'api', 'cli' ]
groups = [ 'expression_restorer' ]
) )
@@ -158,7 +157,7 @@ def pre_process(mode : ProcessMode) -> bool:
if mode in [ 'output', 'preview' ] and not is_image(state_manager.get_item('target_path')) and not is_video(state_manager.get_item('target_path')): if mode in [ 'output', 'preview' ] and not is_image(state_manager.get_item('target_path')) and not is_video(state_manager.get_item('target_path')):
logger.error(translator.get('choose_image_or_video_target') + translator.get('exclamation_mark'), __name__) logger.error(translator.get('choose_image_or_video_target') + translator.get('exclamation_mark'), __name__)
return False return False
if state_manager.get_item('workflow') in [ 'audio-to-image:video', 'image-to-image', 'image-to-video' ]: if state_manager.get_item('workflow_mode') in [ 'audio-to-image:video', 'image-to-image', 'image-to-video' ]:
if mode == 'output' and not in_directory(state_manager.get_item('output_path')): if mode == 'output' and not in_directory(state_manager.get_item('output_path')):
logger.error(translator.get('specify_image_or_video_output') + translator.get('exclamation_mark'), __name__) logger.error(translator.get('specify_image_or_video_output') + translator.get('exclamation_mark'), __name__)
return False return False
@@ -44,8 +44,7 @@ def register_args(program : ArgumentParser) -> None:
metavar = 'FACE_DEBUGGER_ITEMS' metavar = 'FACE_DEBUGGER_ITEMS'
) )
], ],
scopes = [ 'api', 'cli' ], scopes = [ 'api', 'cli' ]
groups = [ 'face_debugger' ]
) )
@@ -68,7 +67,7 @@ def pre_process(mode : ProcessMode) -> bool:
if mode in [ 'output', 'preview' ] and not is_image(state_manager.get_item('target_path')) and not is_video(state_manager.get_item('target_path')): if mode in [ 'output', 'preview' ] and not is_image(state_manager.get_item('target_path')) and not is_video(state_manager.get_item('target_path')):
logger.error(translator.get('choose_image_or_video_target') + translator.get('exclamation_mark'), __name__) logger.error(translator.get('choose_image_or_video_target') + translator.get('exclamation_mark'), __name__)
return False return False
if state_manager.get_item('workflow') in [ 'audio-to-image:video', 'image-to-image', 'image-to-video' ]: if state_manager.get_item('workflow_mode') in [ 'audio-to-image:video', 'image-to-image', 'image-to-video' ]:
if mode == 'output' and not in_directory(state_manager.get_item('output_path')): if mode == 'output' and not in_directory(state_manager.get_item('output_path')):
logger.error(translator.get('specify_image_or_video_output') + translator.get('exclamation_mark'), __name__) logger.error(translator.get('specify_image_or_video_output') + translator.get('exclamation_mark'), __name__)
return False return False
@@ -251,8 +251,7 @@ def register_args(program : ArgumentParser) -> None:
metavar = create_float_metavar(face_editor_choices.face_editor_head_roll_range) metavar = create_float_metavar(face_editor_choices.face_editor_head_roll_range)
) )
], ],
scopes = [ 'api', 'cli' ], scopes = [ 'api', 'cli' ]
groups = [ 'face_editor' ]
) )
@@ -293,7 +292,7 @@ def pre_process(mode : ProcessMode) -> bool:
if mode in [ 'output', 'preview' ] and not is_image(state_manager.get_item('target_path')) and not is_video(state_manager.get_item('target_path')): if mode in [ 'output', 'preview' ] and not is_image(state_manager.get_item('target_path')) and not is_video(state_manager.get_item('target_path')):
logger.error(translator.get('choose_image_or_video_target') + translator.get('exclamation_mark'), __name__) logger.error(translator.get('choose_image_or_video_target') + translator.get('exclamation_mark'), __name__)
return False return False
if state_manager.get_item('workflow') in [ 'audio-to-image:video', 'image-to-image', 'image-to-video' ]: if state_manager.get_item('workflow_mode') in [ 'audio-to-image:video', 'image-to-image', 'image-to-video' ]:
if mode == 'output' and not in_directory(state_manager.get_item('output_path')): if mode == 'output' and not in_directory(state_manager.get_item('output_path')):
logger.error(translator.get('specify_image_or_video_output') + translator.get('exclamation_mark'), __name__) logger.error(translator.get('specify_image_or_video_output') + translator.get('exclamation_mark'), __name__)
return False return False
@@ -319,8 +319,7 @@ def register_args(program : ArgumentParser) -> None:
metavar = create_float_metavar(face_enhancer_choices.face_enhancer_weight_range) metavar = create_float_metavar(face_enhancer_choices.face_enhancer_weight_range)
) )
], ],
scopes = [ 'api', 'cli' ], scopes = [ 'api', 'cli' ]
groups = [ 'face_enhancer' ]
) )
@@ -349,7 +348,7 @@ def pre_process(mode : ProcessMode) -> bool:
if mode in [ 'output', 'preview' ] and not is_image(state_manager.get_item('target_path')) and not is_video(state_manager.get_item('target_path')): if mode in [ 'output', 'preview' ] and not is_image(state_manager.get_item('target_path')) and not is_video(state_manager.get_item('target_path')):
logger.error(translator.get('choose_image_or_video_target') + translator.get('exclamation_mark'), __name__) logger.error(translator.get('choose_image_or_video_target') + translator.get('exclamation_mark'), __name__)
return False return False
if state_manager.get_item('workflow') in [ 'audio-to-image:video', 'image-to-image', 'image-to-video' ]: if state_manager.get_item('workflow_mode') in [ 'audio-to-image:video', 'image-to-image', 'image-to-video' ]:
if mode == 'output' and not in_directory(state_manager.get_item('output_path')): if mode == 'output' and not in_directory(state_manager.get_item('output_path')):
logger.error(translator.get('specify_image_or_video_output') + translator.get('exclamation_mark'), __name__) logger.error(translator.get('specify_image_or_video_output') + translator.get('exclamation_mark'), __name__)
return False return False
@@ -537,8 +537,7 @@ def register_args(program : ArgumentParser) -> None:
choices = face_swapper_choices.face_swapper_models choices = face_swapper_choices.face_swapper_models
) )
], ],
scopes = [ 'api', 'cli' ], scopes = [ 'api', 'cli' ]
groups = [ 'face_swapper' ]
) )
known_args, _ = program.parse_known_args() known_args, _ = program.parse_known_args()
face_swapper_pixel_boost_choices = face_swapper_choices.face_swapper_set.get(known_args.face_swapper_model) face_swapper_pixel_boost_choices = face_swapper_choices.face_swapper_set.get(known_args.face_swapper_model)
@@ -558,8 +557,7 @@ def register_args(program : ArgumentParser) -> None:
choices = face_swapper_choices.face_swapper_weight_range choices = face_swapper_choices.face_swapper_weight_range
) )
], ],
scopes = [ 'api', 'cli' ], scopes = [ 'api', 'cli' ]
groups = [ 'face_swapper' ]
) )
@@ -601,7 +599,7 @@ def pre_process(mode : ProcessMode) -> bool:
logger.error(translator.get('choose_image_or_video_target') + translator.get('exclamation_mark'), __name__) logger.error(translator.get('choose_image_or_video_target') + translator.get('exclamation_mark'), __name__)
return False return False
if state_manager.get_item('workflow') in [ 'audio-to-image:video', 'image-to-image', 'image-to-video' ]: if state_manager.get_item('workflow_mode') in [ 'audio-to-image:video', 'image-to-image', 'image-to-video' ]:
if mode == 'output' and not in_directory(state_manager.get_item('output_path')): if mode == 'output' and not in_directory(state_manager.get_item('output_path')):
logger.error(translator.get('specify_image_or_video_output') + translator.get('exclamation_mark'), __name__) logger.error(translator.get('specify_image_or_video_output') + translator.get('exclamation_mark'), __name__)
return False return False
@@ -211,8 +211,7 @@ def register_args(program : ArgumentParser) -> None:
metavar = create_int_metavar(frame_colorizer_choices.frame_colorizer_blend_range) metavar = create_int_metavar(frame_colorizer_choices.frame_colorizer_blend_range)
) )
], ],
scopes = [ 'api', 'cli' ], scopes = [ 'api', 'cli' ]
groups = [ 'frame_colorizer' ]
) )
@@ -241,7 +240,7 @@ def pre_process(mode : ProcessMode) -> bool:
if mode in [ 'output', 'preview' ] and not is_image(state_manager.get_item('target_path')) and not is_video(state_manager.get_item('target_path')): if mode in [ 'output', 'preview' ] and not is_image(state_manager.get_item('target_path')) and not is_video(state_manager.get_item('target_path')):
logger.error(translator.get('choose_image_or_video_target') + translator.get('exclamation_mark'), __name__) logger.error(translator.get('choose_image_or_video_target') + translator.get('exclamation_mark'), __name__)
return False return False
if state_manager.get_item('workflow') in [ 'audio-to-image:video', 'image-to-image', 'image-to-video' ]: if state_manager.get_item('workflow_mode') in [ 'audio-to-image:video', 'image-to-image', 'image-to-video' ]:
if mode == 'output' and not in_directory(state_manager.get_item('output_path')): if mode == 'output' and not in_directory(state_manager.get_item('output_path')):
logger.error(translator.get('specify_image_or_video_output') + translator.get('exclamation_mark'), __name__) logger.error(translator.get('specify_image_or_video_output') + translator.get('exclamation_mark'), __name__)
return False return False
@@ -599,8 +599,7 @@ def register_args(program : ArgumentParser) -> None:
metavar = create_int_metavar(frame_enhancer_choices.frame_enhancer_blend_range) metavar = create_int_metavar(frame_enhancer_choices.frame_enhancer_blend_range)
) )
], ],
scopes = [ 'api', 'cli' ], scopes = [ 'api', 'cli' ]
groups = [ 'frame_enhancer' ]
) )
@@ -628,7 +627,7 @@ def pre_process(mode : ProcessMode) -> bool:
if mode in [ 'output', 'preview' ] and not is_image(state_manager.get_item('target_path')) and not is_video(state_manager.get_item('target_path')): if mode in [ 'output', 'preview' ] and not is_image(state_manager.get_item('target_path')) and not is_video(state_manager.get_item('target_path')):
logger.error(translator.get('choose_image_or_video_target') + translator.get('exclamation_mark'), __name__) logger.error(translator.get('choose_image_or_video_target') + translator.get('exclamation_mark'), __name__)
return False return False
if state_manager.get_item('workflow') in [ 'audio-to-image:video', 'image-to-image', 'image-to-video' ]: if state_manager.get_item('workflow_mode') in [ 'audio-to-image:video', 'image-to-image', 'image-to-video' ]:
if mode == 'output' and not in_directory(state_manager.get_item('output_path')): if mode == 'output' and not in_directory(state_manager.get_item('output_path')):
logger.error(translator.get('specify_image_or_video_output') + translator.get('exclamation_mark'), __name__) logger.error(translator.get('specify_image_or_video_output') + translator.get('exclamation_mark'), __name__)
return False return False
@@ -151,8 +151,7 @@ def register_args(program : ArgumentParser) -> None:
metavar = create_float_metavar(lip_syncer_choices.lip_syncer_weight_range) metavar = create_float_metavar(lip_syncer_choices.lip_syncer_weight_range)
) )
], ],
scopes = [ 'api', 'cli' ], scopes = [ 'api', 'cli' ]
groups = [ 'lip_syncer' ]
) )
+65 -125
View File
@@ -32,8 +32,7 @@ def create_config_path_program() -> ArgumentParser:
default = 'facefusion.ini' default = 'facefusion.ini'
) )
], ],
scopes = [ 'cli' ], scopes = [ 'cli' ]
groups = [ 'paths' ]
) )
apply_config_path(program) apply_config_path(program)
@@ -47,14 +46,13 @@ def create_workflow_program() -> ArgumentParser:
capability_store.register_capability_set( capability_store.register_capability_set(
[ [
group_paths.add_argument( group_paths.add_argument(
'--workflow', '--workflow-mode',
help = translator.get('help.workflow'), help = translator.get('help.workflow_mode'),
default = config.get_str_value('workflow', 'workflow', 'auto'), default = config.get_str_value('workflow', 'workflow_mode', 'auto'),
choices = facefusion.choices.workflows choices = facefusion.choices.workflow_modes
) )
], ],
scopes = [ 'api', 'cli' ], scopes = [ 'api', 'cli' ]
groups = [ 'paths' ]
) )
return program return program
@@ -72,8 +70,7 @@ def create_temp_path_program() -> ArgumentParser:
default = config.get_str_value('paths', 'temp_path', tempfile.gettempdir()) default = config.get_str_value('paths', 'temp_path', tempfile.gettempdir())
) )
], ],
scopes = [ 'cli' ], scopes = [ 'cli' ]
groups = [ 'paths' ]
) )
return program return program
@@ -91,8 +88,7 @@ def create_jobs_path_program() -> ArgumentParser:
default = config.get_str_value('paths', 'jobs_path', '.jobs') default = config.get_str_value('paths', 'jobs_path', '.jobs')
) )
], ],
scopes = [ 'cli' ], scopes = [ 'cli' ]
groups = [ 'paths' ]
) )
return program return program
@@ -111,8 +107,7 @@ def create_source_paths_program() -> ArgumentParser:
nargs = '+' nargs = '+'
) )
], ],
scopes = [ 'cli' ], scopes = [ 'cli' ]
groups = [ 'paths' ]
) )
return program return program
@@ -130,8 +125,7 @@ def create_target_path_program() -> ArgumentParser:
default = config.get_str_value('paths', 'target_path') default = config.get_str_value('paths', 'target_path')
) )
], ],
scopes = [ 'cli' ], scopes = [ 'cli' ]
groups = [ 'paths' ]
) )
return program return program
@@ -149,8 +143,7 @@ def create_output_path_program() -> ArgumentParser:
default = config.get_str_value('paths', 'output_path') default = config.get_str_value('paths', 'output_path')
) )
], ],
scopes = [ 'cli' ], scopes = [ 'cli' ]
groups = [ 'paths' ]
) )
return program return program
@@ -168,8 +161,7 @@ def create_source_pattern_program() -> ArgumentParser:
default = config.get_str_value('patterns', 'source_pattern') default = config.get_str_value('patterns', 'source_pattern')
) )
], ],
scopes = [ 'cli' ], scopes = [ 'cli' ]
groups = [ 'patterns' ]
) )
return program return program
@@ -187,8 +179,7 @@ def create_target_pattern_program() -> ArgumentParser:
default = config.get_str_value('patterns', 'target_pattern') default = config.get_str_value('patterns', 'target_pattern')
) )
], ],
scopes = [ 'cli' ], scopes = [ 'cli' ]
groups = [ 'patterns' ]
) )
return program return program
@@ -206,8 +197,7 @@ def create_output_pattern_program() -> ArgumentParser:
default = config.get_str_value('patterns', 'output_pattern') default = config.get_str_value('patterns', 'output_pattern')
) )
], ],
scopes = [ 'cli' ], scopes = [ 'cli' ]
groups = [ 'patterns' ]
) )
return program return program
@@ -226,8 +216,7 @@ def create_face_detector_program() -> ArgumentParser:
choices = facefusion.choices.face_detector_models choices = facefusion.choices.face_detector_models
) )
], ],
scopes = [ 'api', 'cli' ], scopes = [ 'api', 'cli' ]
groups = [ 'face_detector' ]
) )
known_args, _ = program.parse_known_args() known_args, _ = program.parse_known_args()
@@ -242,8 +231,7 @@ def create_face_detector_program() -> ArgumentParser:
choices = face_detector_size_choices choices = face_detector_size_choices
) )
], ],
scopes = [ 'api', 'cli' ], scopes = [ 'api', 'cli' ]
groups = [ 'face_detector' ]
) )
capability_store.register_capability_set( capability_store.register_capability_set(
[ [
@@ -255,8 +243,7 @@ def create_face_detector_program() -> ArgumentParser:
nargs = '+' nargs = '+'
) )
], ],
scopes = [ 'api', 'cli' ], scopes = [ 'api', 'cli' ]
groups = [ 'face_detector' ]
) )
capability_store.register_capability_set( capability_store.register_capability_set(
[ [
@@ -270,8 +257,7 @@ def create_face_detector_program() -> ArgumentParser:
metavar = 'FACE_DETECTOR_ANGLES' metavar = 'FACE_DETECTOR_ANGLES'
) )
], ],
scopes = [ 'api', 'cli' ], scopes = [ 'api', 'cli' ]
groups = [ 'face_detector' ]
) )
capability_store.register_capability_set( capability_store.register_capability_set(
[ [
@@ -284,8 +270,7 @@ def create_face_detector_program() -> ArgumentParser:
metavar = create_float_metavar(facefusion.choices.face_detector_score_range) metavar = create_float_metavar(facefusion.choices.face_detector_score_range)
) )
], ],
scopes = [ 'api', 'cli' ], scopes = [ 'api', 'cli' ]
groups = [ 'face_detector' ]
) )
return program return program
@@ -304,8 +289,7 @@ def create_face_landmarker_program() -> ArgumentParser:
choices = facefusion.choices.face_landmarker_models choices = facefusion.choices.face_landmarker_models
) )
], ],
scopes = [ 'api', 'cli' ], scopes = [ 'api', 'cli' ]
groups = [ 'face_landmarker' ]
) )
capability_store.register_capability_set( capability_store.register_capability_set(
[ [
@@ -318,8 +302,7 @@ def create_face_landmarker_program() -> ArgumentParser:
metavar = create_float_metavar(facefusion.choices.face_landmarker_score_range) metavar = create_float_metavar(facefusion.choices.face_landmarker_score_range)
) )
], ],
scopes = [ 'api', 'cli' ], scopes = [ 'api', 'cli' ]
groups = [ 'face_landmarker' ]
) )
return program return program
@@ -338,8 +321,7 @@ def create_face_selector_program() -> ArgumentParser:
choices = facefusion.choices.face_selector_modes choices = facefusion.choices.face_selector_modes
) )
], ],
scopes = [ 'api', 'cli' ], scopes = [ 'api', 'cli' ]
groups = [ 'face_selector' ]
) )
capability_store.register_capability_set( capability_store.register_capability_set(
[ [
@@ -350,8 +332,7 @@ def create_face_selector_program() -> ArgumentParser:
choices = facefusion.choices.face_selector_orders choices = facefusion.choices.face_selector_orders
) )
], ],
scopes = [ 'api', 'cli' ], scopes = [ 'api', 'cli' ]
groups = [ 'face_selector' ]
) )
capability_store.register_capability_set( capability_store.register_capability_set(
[ [
@@ -364,8 +345,7 @@ def create_face_selector_program() -> ArgumentParser:
metavar = create_int_metavar(facefusion.choices.face_selector_age_range) metavar = create_int_metavar(facefusion.choices.face_selector_age_range)
) )
], ],
scopes = [ 'api', 'cli' ], scopes = [ 'api', 'cli' ]
groups = [ 'face_selector' ]
) )
capability_store.register_capability_set( capability_store.register_capability_set(
[ [
@@ -378,8 +358,7 @@ def create_face_selector_program() -> ArgumentParser:
metavar = create_int_metavar(facefusion.choices.face_selector_age_range) metavar = create_int_metavar(facefusion.choices.face_selector_age_range)
) )
], ],
scopes = [ 'api', 'cli' ], scopes = [ 'api', 'cli' ]
groups = [ 'face_selector' ]
) )
capability_store.register_capability_set( capability_store.register_capability_set(
[ [
@@ -390,8 +369,7 @@ def create_face_selector_program() -> ArgumentParser:
choices = facefusion.choices.face_selector_genders choices = facefusion.choices.face_selector_genders
) )
], ],
scopes = [ 'api', 'cli' ], scopes = [ 'api', 'cli' ]
groups = [ 'face_selector' ]
) )
capability_store.register_capability_set( capability_store.register_capability_set(
[ [
@@ -402,8 +380,7 @@ def create_face_selector_program() -> ArgumentParser:
choices = facefusion.choices.face_selector_races choices = facefusion.choices.face_selector_races
) )
], ],
scopes = [ 'api', 'cli' ], scopes = [ 'api', 'cli' ]
groups = [ 'face_selector' ]
) )
capability_store.register_capability_set( capability_store.register_capability_set(
[ [
@@ -414,8 +391,7 @@ def create_face_selector_program() -> ArgumentParser:
default = config.get_int_value('face_selector', 'reference_face_position', '0') default = config.get_int_value('face_selector', 'reference_face_position', '0')
) )
], ],
scopes = [ 'api', 'cli' ], scopes = [ 'api', 'cli' ]
groups = [ 'face_selector' ]
) )
capability_store.register_capability_set( capability_store.register_capability_set(
[ [
@@ -428,8 +404,7 @@ def create_face_selector_program() -> ArgumentParser:
metavar = create_float_metavar(facefusion.choices.reference_face_distance_range) metavar = create_float_metavar(facefusion.choices.reference_face_distance_range)
) )
], ],
scopes = [ 'api', 'cli' ], scopes = [ 'api', 'cli' ]
groups = [ 'face_selector' ]
) )
capability_store.register_capability_set( capability_store.register_capability_set(
[ [
@@ -440,8 +415,7 @@ def create_face_selector_program() -> ArgumentParser:
default = config.get_int_value('face_selector', 'reference_frame_number', '0') default = config.get_int_value('face_selector', 'reference_frame_number', '0')
) )
], ],
scopes = [ 'api', 'cli' ], scopes = [ 'api', 'cli' ]
groups = [ 'face_selector' ]
) )
return program return program
@@ -462,8 +436,7 @@ def create_face_tracker_program() -> ArgumentParser:
metavar = create_float_metavar(facefusion.choices.face_tracker_score_range) metavar = create_float_metavar(facefusion.choices.face_tracker_score_range)
) )
], ],
scopes = [ 'api', 'cli' ], scopes = [ 'api', 'cli' ]
groups = [ 'face_tracker' ]
) )
return program return program
@@ -482,8 +455,7 @@ def create_face_masker_program() -> ArgumentParser:
choices = facefusion.choices.face_occluder_models choices = facefusion.choices.face_occluder_models
) )
], ],
scopes = [ 'api', 'cli' ], scopes = [ 'api', 'cli' ]
groups = [ 'face_masker' ]
) )
capability_store.register_capability_set( capability_store.register_capability_set(
[ [
@@ -494,8 +466,7 @@ def create_face_masker_program() -> ArgumentParser:
choices = facefusion.choices.face_parser_models choices = facefusion.choices.face_parser_models
) )
], ],
scopes = [ 'api', 'cli' ], scopes = [ 'api', 'cli' ]
groups = [ 'face_masker' ]
) )
capability_store.register_capability_set( capability_store.register_capability_set(
[ [
@@ -508,8 +479,7 @@ def create_face_masker_program() -> ArgumentParser:
metavar = 'FACE_MASK_TYPES' metavar = 'FACE_MASK_TYPES'
) )
], ],
scopes = [ 'api', 'cli' ], scopes = [ 'api', 'cli' ]
groups = [ 'face_masker' ]
) )
capability_store.register_capability_set( capability_store.register_capability_set(
[ [
@@ -522,8 +492,7 @@ def create_face_masker_program() -> ArgumentParser:
metavar = 'FACE_MASK_AREAS' metavar = 'FACE_MASK_AREAS'
) )
], ],
scopes = [ 'api', 'cli' ], scopes = [ 'api', 'cli' ]
groups = [ 'face_masker' ]
) )
capability_store.register_capability_set( capability_store.register_capability_set(
[ [
@@ -536,8 +505,7 @@ def create_face_masker_program() -> ArgumentParser:
metavar = 'FACE_MASK_REGIONS' metavar = 'FACE_MASK_REGIONS'
) )
], ],
scopes = [ 'api', 'cli' ], scopes = [ 'api', 'cli' ]
groups = [ 'face_masker' ]
) )
capability_store.register_capability_set( capability_store.register_capability_set(
[ [
@@ -550,8 +518,7 @@ def create_face_masker_program() -> ArgumentParser:
metavar = create_float_metavar(facefusion.choices.face_mask_blur_range) metavar = create_float_metavar(facefusion.choices.face_mask_blur_range)
) )
], ],
scopes = [ 'api', 'cli' ], scopes = [ 'api', 'cli' ]
groups = [ 'face_masker' ]
) )
capability_store.register_capability_set( capability_store.register_capability_set(
[ [
@@ -563,8 +530,7 @@ def create_face_masker_program() -> ArgumentParser:
nargs = '+' nargs = '+'
) )
], ],
scopes = [ 'api', 'cli' ], scopes = [ 'api', 'cli' ]
groups = [ 'face_masker' ]
) )
return program return program
@@ -583,8 +549,7 @@ def create_voice_extractor_program() -> ArgumentParser:
choices = facefusion.choices.voice_extractor_models choices = facefusion.choices.voice_extractor_models
) )
], ],
scopes = [ 'api', 'cli' ], scopes = [ 'api', 'cli' ]
groups = [ 'voice_extractor' ]
) )
return program return program
@@ -603,8 +568,7 @@ def create_frame_extraction_program() -> ArgumentParser:
default = facefusion.config.get_int_value('frame_extraction', 'trim_frame_start') default = facefusion.config.get_int_value('frame_extraction', 'trim_frame_start')
) )
], ],
scopes = [ 'api', 'cli' ], scopes = [ 'api', 'cli' ]
groups = [ 'frame_extraction' ]
) )
capability_store.register_capability_set( capability_store.register_capability_set(
[ [
@@ -615,8 +579,7 @@ def create_frame_extraction_program() -> ArgumentParser:
default = facefusion.config.get_int_value('frame_extraction', 'trim_frame_end') default = facefusion.config.get_int_value('frame_extraction', 'trim_frame_end')
) )
], ],
scopes = [ 'api', 'cli' ], scopes = [ 'api', 'cli' ]
groups = [ 'frame_extraction' ]
) )
capability_store.register_capability_set( capability_store.register_capability_set(
[ [
@@ -627,8 +590,7 @@ def create_frame_extraction_program() -> ArgumentParser:
choices = facefusion.choices.temp_frame_formats choices = facefusion.choices.temp_frame_formats
) )
], ],
scopes = [ 'api', 'cli' ], scopes = [ 'api', 'cli' ]
groups = [ 'frame_extraction' ]
) )
return program return program
@@ -644,13 +606,12 @@ def create_frame_distribution_program() -> ArgumentParser:
'--target-frame-amount', '--target-frame-amount',
help = translator.get('help.target_frame_amount'), help = translator.get('help.target_frame_amount'),
type = int, type = int,
default = config.get_int_value('frame_distribution', 'target_frame_amount', '5'), default = config.get_int_value('frame_distribution', 'target_frame_amount', '2'),
choices = facefusion.choices.target_frame_amount_range, choices = facefusion.choices.target_frame_amount_range,
metavar = create_int_metavar(facefusion.choices.target_frame_amount_range) metavar = create_int_metavar(facefusion.choices.target_frame_amount_range)
) )
], ],
scopes = [ 'api', 'cli' ], scopes = [ 'api', 'cli' ]
groups = [ 'frame_distribution' ]
) )
return program return program
@@ -672,8 +633,7 @@ def create_output_creation_program() -> ArgumentParser:
metavar = create_int_metavar(facefusion.choices.output_image_quality_range) metavar = create_int_metavar(facefusion.choices.output_image_quality_range)
) )
], ],
scopes = [ 'api', 'cli' ], scopes = [ 'api', 'cli' ]
groups = [ 'output_creation' ]
) )
capability_store.register_capability_set( capability_store.register_capability_set(
[ [
@@ -685,8 +645,7 @@ def create_output_creation_program() -> ArgumentParser:
choices = facefusion.choices.output_image_scale_range choices = facefusion.choices.output_image_scale_range
) )
], ],
scopes = [ 'api', 'cli' ], scopes = [ 'api', 'cli' ]
groups = [ 'output_creation' ]
) )
capability_store.register_capability_set( capability_store.register_capability_set(
[ [
@@ -697,8 +656,7 @@ def create_output_creation_program() -> ArgumentParser:
choices = available_encoder_set.get('audio') choices = available_encoder_set.get('audio')
) )
], ],
scopes = [ 'api', 'cli' ], scopes = [ 'api', 'cli' ]
groups = [ 'output_creation' ]
) )
capability_store.register_capability_set( capability_store.register_capability_set(
[ [
@@ -711,8 +669,7 @@ def create_output_creation_program() -> ArgumentParser:
metavar = create_int_metavar(facefusion.choices.output_audio_quality_range) metavar = create_int_metavar(facefusion.choices.output_audio_quality_range)
) )
], ],
scopes = [ 'api', 'cli' ], scopes = [ 'api', 'cli' ]
groups = [ 'output_creation' ]
) )
capability_store.register_capability_set( capability_store.register_capability_set(
[ [
@@ -725,8 +682,7 @@ def create_output_creation_program() -> ArgumentParser:
metavar = create_int_metavar(facefusion.choices.output_audio_volume_range) metavar = create_int_metavar(facefusion.choices.output_audio_volume_range)
) )
], ],
scopes = [ 'api', 'cli' ], scopes = [ 'api', 'cli' ]
groups = [ 'output_creation' ]
) )
capability_store.register_capability_set( capability_store.register_capability_set(
[ [
@@ -737,8 +693,7 @@ def create_output_creation_program() -> ArgumentParser:
choices = available_encoder_set.get('video') choices = available_encoder_set.get('video')
) )
], ],
scopes = [ 'api', 'cli' ], scopes = [ 'api', 'cli' ]
groups = [ 'output_creation' ]
) )
capability_store.register_capability_set( capability_store.register_capability_set(
[ [
@@ -749,8 +704,7 @@ def create_output_creation_program() -> ArgumentParser:
choices = facefusion.choices.video_presets choices = facefusion.choices.video_presets
) )
], ],
scopes = [ 'api', 'cli' ], scopes = [ 'api', 'cli' ]
groups = [ 'output_creation' ]
) )
capability_store.register_capability_set( capability_store.register_capability_set(
[ [
@@ -763,8 +717,7 @@ def create_output_creation_program() -> ArgumentParser:
metavar = create_int_metavar(facefusion.choices.output_video_quality_range) metavar = create_int_metavar(facefusion.choices.output_video_quality_range)
) )
], ],
scopes = [ 'api', 'cli' ], scopes = [ 'api', 'cli' ]
groups = [ 'output_creation' ]
) )
capability_store.register_capability_set( capability_store.register_capability_set(
[ [
@@ -776,8 +729,7 @@ def create_output_creation_program() -> ArgumentParser:
choices = facefusion.choices.output_video_scale_range choices = facefusion.choices.output_video_scale_range
) )
], ],
scopes = [ 'api', 'cli' ], scopes = [ 'api', 'cli' ]
groups = [ 'output_creation' ]
) )
capability_store.register_capability_set( capability_store.register_capability_set(
[ [
@@ -788,8 +740,7 @@ def create_output_creation_program() -> ArgumentParser:
default = config.get_float_value('output_creation', 'output_video_fps') default = config.get_float_value('output_creation', 'output_video_fps')
) )
], ],
scopes = [ 'api', 'cli' ], scopes = [ 'api', 'cli' ]
groups = [ 'output_creation' ]
) )
capability_store.register_capability_set( capability_store.register_capability_set(
[ [
@@ -800,8 +751,7 @@ def create_output_creation_program() -> ArgumentParser:
default = config.get_float_value('output_creation', 'output_audio_fps', '25.0') default = config.get_float_value('output_creation', 'output_audio_fps', '25.0')
) )
], ],
scopes = [ 'api', 'cli' ], scopes = [ 'api', 'cli' ]
groups = [ 'output_creation' ]
) )
return program return program
@@ -822,8 +772,7 @@ def create_processors_program() -> ArgumentParser:
nargs = '+' nargs = '+'
) )
], ],
scopes = [ 'api', 'cli' ], scopes = [ 'api', 'cli' ]
groups = [ 'processors' ]
) )
for processor_module in get_processors_modules(available_processors): for processor_module in get_processors_modules(available_processors):
@@ -847,8 +796,7 @@ def create_download_providers_program() -> ArgumentParser:
metavar = 'DOWNLOAD_PROVIDERS' metavar = 'DOWNLOAD_PROVIDERS'
) )
], ],
scopes = [ 'cli', 'sys' ], scopes = [ 'cli', 'sys' ]
groups = [ 'download' ]
) )
return program return program
@@ -867,8 +815,7 @@ def create_download_scope_program() -> ArgumentParser:
choices = facefusion.choices.download_scopes choices = facefusion.choices.download_scopes
) )
], ],
scopes = [ 'cli', 'sys' ], scopes = [ 'cli', 'sys' ]
groups = [ 'download' ]
) )
return program return program
@@ -926,8 +873,7 @@ def create_api_program() -> ArgumentParser:
choices = facefusion.choices.api_security_strategies choices = facefusion.choices.api_security_strategies
) )
], ],
scopes = [ 'api' ], scopes = [ 'api' ]
groups = [ 'api' ]
) )
return program return program
@@ -949,8 +895,7 @@ def create_execution_program() -> ArgumentParser:
metavar = 'EXECUTION_DEVICE_IDS' metavar = 'EXECUTION_DEVICE_IDS'
) )
], ],
scopes = [ 'cli', 'sys' ], scopes = [ 'cli', 'sys' ]
groups = [ 'execution' ]
) )
capability_store.register_capability_set( capability_store.register_capability_set(
[ [
@@ -963,8 +908,7 @@ def create_execution_program() -> ArgumentParser:
metavar = 'EXECUTION_PROVIDERS' metavar = 'EXECUTION_PROVIDERS'
) )
], ],
scopes = [ 'cli', 'sys' ], scopes = [ 'cli', 'sys' ]
groups = [ 'execution' ]
) )
capability_store.register_capability_set( capability_store.register_capability_set(
[ [
@@ -977,8 +921,7 @@ def create_execution_program() -> ArgumentParser:
metavar = create_int_metavar(facefusion.choices.execution_thread_count_range) metavar = create_int_metavar(facefusion.choices.execution_thread_count_range)
) )
], ],
scopes = [ 'cli', 'sys' ], scopes = [ 'cli', 'sys' ]
groups = [ 'execution' ]
) )
return program return program
@@ -997,8 +940,7 @@ def create_memory_program() -> ArgumentParser:
choices = facefusion.choices.video_memory_strategies choices = facefusion.choices.video_memory_strategies
) )
], ],
scopes = [ 'cli', 'sys' ], scopes = [ 'cli', 'sys' ]
groups = [ 'memory' ]
) )
return program return program
@@ -1017,8 +959,7 @@ def create_log_level_program() -> ArgumentParser:
choices = facefusion.choices.log_levels choices = facefusion.choices.log_levels
) )
], ],
scopes = [ 'cli' ], scopes = [ 'cli' ]
groups = [ 'misc' ]
) )
return program return program
@@ -1037,8 +978,7 @@ def create_halt_on_error_program() -> ArgumentParser:
default = config.get_bool_value('misc', 'halt_on_error') default = config.get_bool_value('misc', 'halt_on_error')
) )
], ],
scopes = [ 'cli' ], scopes = [ 'cli' ]
groups = [ 'misc' ]
) )
return program return program
+4 -7
View File
@@ -65,7 +65,7 @@ Language = Literal['en']
Locales : TypeAlias = Dict[Language, Dict[str, Any]] Locales : TypeAlias = Dict[Language, Dict[str, Any]]
LocalePoolSet : TypeAlias = Dict[str, Locales] LocalePoolSet : TypeAlias = Dict[str, Locales]
WorkFlow = Literal['auto', 'audio-to-image:frames', 'audio-to-image:video', 'image-to-image', 'image-to-video', 'image-to-video:frames'] WorkflowMode = Literal['auto', 'audio-to-image:frames', 'audio-to-image:video', 'image-to-image', 'image-to-video', 'image-to-video:frames']
VideoCaptureSet : TypeAlias = Dict[str, cv2.VideoCapture] VideoCaptureSet : TypeAlias = Dict[str, cv2.VideoCapture]
VideoWriterSet : TypeAlias = Dict[str, cv2.VideoWriter] VideoWriterSet : TypeAlias = Dict[str, cv2.VideoWriter]
@@ -135,13 +135,11 @@ Args : TypeAlias = Dict[str, Any]
Choice : TypeAlias = Union[int | str] Choice : TypeAlias = Union[int | str]
Scope : TypeAlias = Literal['api', 'cli', 'sys'] Scope : TypeAlias = Literal['api', 'cli', 'sys']
Group : TypeAlias = str
CapabilitySet = TypedDict('CapabilitySet', CapabilitySet = TypedDict('CapabilitySet',
{ {
'default' : Any, 'default' : Any,
'choices' : NotRequired[List[Choice]], 'choices' : NotRequired[List[Choice]]
'groups' : NotRequired[List[Group]]
}) })
CapabilityStore = TypedDict('CapabilityStore', CapabilityStore = TypedDict('CapabilityStore',
{ {
@@ -149,7 +147,6 @@ CapabilityStore = TypedDict('CapabilityStore',
'cli' : Dict[str, CapabilitySet], 'cli' : Dict[str, CapabilitySet],
'sys' : Dict[str, CapabilitySet] 'sys' : Dict[str, CapabilitySet]
}) })
CapabilityGroup : TypeAlias = Dict[Group, Dict[str, CapabilitySet]]
ProcessState = Literal['checking', 'processing', 'stopping', 'pending'] ProcessState = Literal['checking', 'processing', 'stopping', 'pending']
UpdateProgress : TypeAlias = Callable[[int], None] UpdateProgress : TypeAlias = Callable[[int], None]
@@ -478,7 +475,7 @@ StateValue : TypeAlias = Any
StateKey = Literal\ StateKey = Literal\
[ [
'command', 'command',
'workflow', 'workflow_mode',
'config_path', 'config_path',
'temp_path', 'temp_path',
'jobs_path', 'jobs_path',
@@ -552,7 +549,7 @@ StateKey = Literal\
State = TypedDict('State', State = TypedDict('State',
{ {
'command' : str, 'command' : str,
'workflow' : WorkFlow, 'workflow_mode' : WorkflowMode,
'config_path' : str, 'config_path' : str,
'temp_path' : str, 'temp_path' : str,
'jobs_path' : str, 'jobs_path' : str,
+6
View File
@@ -19,6 +19,12 @@ def get_video_capture(video_path : str) -> cv2.VideoCapture:
return VIDEO_POOL_SET.get('capture').get(video_path) return VIDEO_POOL_SET.get('capture').get(video_path)
def conditional_set_video_frame_position(video_capture : cv2.VideoCapture, frame_position : int) -> bool:
if not video_capture.get(cv2.CAP_PROP_POS_FRAMES) == frame_position:
return video_capture.set(cv2.CAP_PROP_POS_FRAMES, frame_position)
return True
def get_video_writer(video_path : str) -> cv2.VideoWriter: def get_video_writer(video_path : str) -> cv2.VideoWriter:
if video_path not in VIDEO_POOL_SET.get('writer'): if video_path not in VIDEO_POOL_SET.get('writer'):
video_writer = cv2.VideoWriter() video_writer = cv2.VideoWriter()
+10 -10
View File
@@ -11,7 +11,7 @@ from facefusion.filesystem import get_file_extension, is_image, is_video
from facefusion.media_helper import restrict_trim_frame from facefusion.media_helper import restrict_trim_frame
from facefusion.thread_helper import thread_lock, thread_semaphore from facefusion.thread_helper import thread_lock, thread_semaphore
from facefusion.types import ColorMode, Duration, Fps, Mask, Orientation, Resolution, Scale, VisionFrame from facefusion.types import ColorMode, Duration, Fps, Mask, Orientation, Resolution, Scale, VisionFrame
from facefusion.video_manager import get_video_capture from facefusion.video_manager import conditional_set_video_frame_position, get_video_capture
def read_static_images(image_paths : List[str], color_mode : ColorMode = 'rgb') -> List[VisionFrame]: def read_static_images(image_paths : List[str], color_mode : ColorMode = 'rgb') -> List[VisionFrame]:
@@ -81,11 +81,11 @@ def read_video_frame(video_path : str, frame_number : int = 0) -> Optional[Visio
video_capture = get_video_capture(video_path) video_capture = get_video_capture(video_path)
if video_capture and video_capture.isOpened(): if video_capture and video_capture.isOpened():
frame_total = video_capture.get(cv2.CAP_PROP_FRAME_COUNT) video_frame_total = int(video_capture.get(cv2.CAP_PROP_FRAME_COUNT))
frame_position = min(frame_total, frame_number) video_frame_position = min(video_frame_total, frame_number)
with thread_semaphore(): with thread_semaphore():
video_capture.set(cv2.CAP_PROP_POS_FRAMES, frame_position) conditional_set_video_frame_position(video_capture, video_frame_position)
has_vision_frame, vision_frame = video_capture.read() has_vision_frame, vision_frame = video_capture.read()
if has_vision_frame: if has_vision_frame:
@@ -106,13 +106,13 @@ def read_video_chunk(video_path : str, chunk_number : int, chunk_size : int) ->
video_capture = get_video_capture(video_path) video_capture = get_video_capture(video_path)
if video_capture and video_capture.isOpened(): if video_capture and video_capture.isOpened():
frame_total = int(video_capture.get(cv2.CAP_PROP_FRAME_COUNT)) video_frame_total = int(video_capture.get(cv2.CAP_PROP_FRAME_COUNT))
frame_position = chunk_number * chunk_size video_frame_position = chunk_number * chunk_size
with thread_semaphore(): with thread_semaphore():
video_capture.set(cv2.CAP_PROP_POS_FRAMES, frame_position) conditional_set_video_frame_position(video_capture, video_frame_position)
for frame_number in range(frame_position, min(frame_position + chunk_size, frame_total)): for frame_number in range(video_frame_position, min(video_frame_position + chunk_size, video_frame_total)):
has_vision_frame, vision_frame = video_capture.read() has_vision_frame, vision_frame = video_capture.read()
if has_vision_frame: if has_vision_frame:
@@ -121,9 +121,9 @@ def read_video_chunk(video_path : str, chunk_number : int, chunk_size : int) ->
return video_frame_chunk return video_frame_chunk
def select_video_frames(video_path : str, frame_number : int = 0, frame_offset : int = 5) -> List[VisionFrame]: def select_video_frames(video_path : str, frame_number : int = 0, frame_offset : int = 2) -> List[VisionFrame]:
vision_frames = [] vision_frames = []
chunk_size = (frame_offset * 2 + 1) * 4 chunk_size = frame_offset * 2 + 1
if is_video(video_path): if is_video(video_path):
with thread_lock(): with thread_lock():
+2 -1
View File
@@ -3,7 +3,8 @@ from functools import partial
from facefusion import process_manager from facefusion import process_manager
from facefusion.types import ErrorCode from facefusion.types import ErrorCode
from facefusion.workflows.as_frames import create_temp_frames from facefusion.workflows.as_frames import create_temp_frames
from facefusion.workflows.core import analyse_image, clear, process_frames, setup from facefusion.workflows.core import clear, process_frames, setup
from facefusion.workflows.to_image import analyse_image
from facefusion.workflows.to_video import finalize_video, merge_frames, restore_audio from facefusion.workflows.to_video import finalize_video, merge_frames, restore_audio
@@ -3,7 +3,8 @@ from functools import partial
from facefusion import process_manager from facefusion import process_manager
from facefusion.types import ErrorCode from facefusion.types import ErrorCode
from facefusion.workflows.as_frames import copy_temp_frames, create_temp_frames, finalize_frames from facefusion.workflows.as_frames import copy_temp_frames, create_temp_frames, finalize_frames
from facefusion.workflows.core import analyse_image, clear, process_frames, setup from facefusion.workflows.core import clear, process_frames, setup
from facefusion.workflows.to_image import analyse_image
def process(start_time : float) -> ErrorCode: def process(start_time : float) -> ErrorCode:
+10 -16
View File
@@ -4,7 +4,7 @@ from typing import List
import numpy import numpy
from tqdm import tqdm from tqdm import tqdm
from facefusion import content_analyser, logger, process_manager, state_manager, translator from facefusion import logger, process_manager, state_manager, translator
from facefusion.audio import create_empty_audio_frame, get_audio_frame, get_voice_frame from facefusion.audio import create_empty_audio_frame, get_audio_frame, get_voice_frame
from facefusion.common_helper import get_first from facefusion.common_helper import get_first
from facefusion.filesystem import filter_audio_paths from facefusion.filesystem import filter_audio_paths
@@ -33,18 +33,12 @@ def clear() -> ErrorCode:
return 0 return 0
def analyse_image() -> ErrorCode:
if content_analyser.analyse_image(state_manager.get_item('target_path')):
return 3
return 0
def conditional_get_source_audio_frame(frame_number : int) -> AudioFrame: def conditional_get_source_audio_frame(frame_number : int) -> AudioFrame:
if state_manager.get_item('workflow') in [ 'audio-to-image:frames', 'audio-to-image:video', 'image-to-video' ]: if state_manager.get_item('workflow_mode') in [ 'audio-to-image:frames', 'audio-to-image:video', 'image-to-video' ]:
source_audio_path = get_first(filter_audio_paths(state_manager.get_item('source_paths'))) source_audio_path = get_first(filter_audio_paths(state_manager.get_item('source_paths')))
fps = state_manager.get_item('output_audio_fps') fps = state_manager.get_item('output_audio_fps')
if state_manager.get_item('workflow') == 'image-to-video': if state_manager.get_item('workflow_mode') == 'image-to-video':
fps = restrict_video_fps(state_manager.get_item('target_path'), state_manager.get_item('output_video_fps')) fps = restrict_video_fps(state_manager.get_item('target_path'), state_manager.get_item('output_video_fps'))
source_audio_frame = get_audio_frame(source_audio_path, fps, frame_number) source_audio_frame = get_audio_frame(source_audio_path, fps, frame_number)
@@ -56,11 +50,11 @@ def conditional_get_source_audio_frame(frame_number : int) -> AudioFrame:
def conditional_get_source_voice_frame(frame_number : int) -> AudioFrame: def conditional_get_source_voice_frame(frame_number : int) -> AudioFrame:
if state_manager.get_item('workflow') in [ 'audio-to-image:frames', 'audio-to-image:video', 'image-to-video' ]: if state_manager.get_item('workflow_mode') in [ 'audio-to-image:frames', 'audio-to-image:video', 'image-to-video' ]:
source_audio_path = get_first(filter_audio_paths(state_manager.get_item('source_paths'))) source_audio_path = get_first(filter_audio_paths(state_manager.get_item('source_paths')))
temp_fps = state_manager.get_item('output_audio_fps') temp_fps = state_manager.get_item('output_audio_fps')
if state_manager.get_item('workflow') == 'image-to-video': if state_manager.get_item('workflow_mode') == 'image-to-video':
temp_fps = restrict_video_fps(state_manager.get_item('target_path'), state_manager.get_item('output_video_fps')) temp_fps = restrict_video_fps(state_manager.get_item('target_path'), state_manager.get_item('output_video_fps'))
source_voice_frame = get_voice_frame(source_audio_path, temp_fps, frame_number) source_voice_frame = get_voice_frame(source_audio_path, temp_fps, frame_number)
@@ -72,15 +66,15 @@ def conditional_get_source_voice_frame(frame_number : int) -> AudioFrame:
def conditional_get_reference_vision_frame() -> VisionFrame: def conditional_get_reference_vision_frame() -> VisionFrame:
if state_manager.get_item('workflow') in [ 'image-to-video', 'image-to-video:frames' ]: if state_manager.get_item('workflow_mode') in [ 'image-to-video', 'image-to-video:frames' ]:
return read_static_video_frame(state_manager.get_item('target_path'), state_manager.get_item('reference_frame_number')) return read_static_video_frame(state_manager.get_item('target_path'), state_manager.get_item('reference_frame_number'))
return read_static_image(state_manager.get_item('target_path')) return read_static_image(state_manager.get_item('target_path'))
def conditional_get_target_vision_frames(temp_frame_path : str, frame_number : int) -> List[VisionFrame]: def conditional_get_target_vision_frames(frame_number : int) -> List[VisionFrame]:
if state_manager.get_item('workflow') in [ 'image-to-video', 'image-to-video:frames' ]: if state_manager.get_item('workflow_mode') in [ 'image-to-video', 'image-to-video:frames' ]:
return select_video_frames(state_manager.get_item('target_path'), frame_number, state_manager.get_item('target_frame_amount')) return select_video_frames(state_manager.get_item('target_path'), frame_number, state_manager.get_item('target_frame_amount'))
return [ read_static_image(temp_frame_path) ] return [ read_static_image(state_manager.get_item('target_path')) ]
def process_temp_frame(temp_frame_path : str, frame_number : int) -> bool: def process_temp_frame(temp_frame_path : str, frame_number : int) -> bool:
@@ -88,7 +82,7 @@ def process_temp_frame(temp_frame_path : str, frame_number : int) -> bool:
source_vision_frames = read_static_images(state_manager.get_item('source_paths')) source_vision_frames = read_static_images(state_manager.get_item('source_paths'))
source_audio_frame = conditional_get_source_audio_frame(frame_number) source_audio_frame = conditional_get_source_audio_frame(frame_number)
source_voice_frame = conditional_get_source_voice_frame(frame_number) source_voice_frame = conditional_get_source_voice_frame(frame_number)
target_vision_frames = conditional_get_target_vision_frames(temp_frame_path, frame_number) target_vision_frames = conditional_get_target_vision_frames(frame_number)
temp_vision_frame = read_static_image(temp_frame_path, 'rgba').copy() temp_vision_frame = read_static_image(temp_frame_path, 'rgba').copy()
temp_vision_mask = extract_vision_mask(temp_vision_frame) temp_vision_mask = extract_vision_mask(temp_vision_frame)
+2 -2
View File
@@ -2,8 +2,8 @@ from functools import partial
from facefusion import process_manager from facefusion import process_manager
from facefusion.types import ErrorCode from facefusion.types import ErrorCode
from facefusion.workflows.core import analyse_image, clear, setup from facefusion.workflows.core import clear, setup
from facefusion.workflows.to_image import finalize_image, prepare_image, process_image from facefusion.workflows.to_image import analyse_image, finalize_image, prepare_image, process_image
def process(start_time : float) -> ErrorCode: def process(start_time : float) -> ErrorCode:
+7 -1
View File
@@ -1,4 +1,4 @@
from facefusion import ffmpeg, logger, process_manager, state_manager, translator from facefusion import content_analyser, ffmpeg, logger, process_manager, state_manager, translator
from facefusion.filesystem import is_image from facefusion.filesystem import is_image
from facefusion.temp_helper import get_temp_file_path from facefusion.temp_helper import get_temp_file_path
from facefusion.time_helper import calculate_end_time from facefusion.time_helper import calculate_end_time
@@ -7,6 +7,12 @@ from facefusion.vision import detect_image_resolution, pack_resolution, restrict
from facefusion.workflows.core import is_process_stopping, process_temp_frame from facefusion.workflows.core import is_process_stopping, process_temp_frame
def analyse_image() -> ErrorCode:
if content_analyser.analyse_image(state_manager.get_item('target_path')):
return 3
return 0
def prepare_image() -> ErrorCode: def prepare_image() -> ErrorCode:
output_image_resolution = scale_resolution(detect_image_resolution(state_manager.get_item('target_path')), state_manager.get_item('output_image_scale')) output_image_resolution = scale_resolution(detect_image_resolution(state_manager.get_item('target_path')), state_manager.get_item('output_image_scale'))
temp_image_resolution = restrict_image_resolution(state_manager.get_item('target_path'), output_image_resolution) temp_image_resolution = restrict_image_resolution(state_manager.get_item('target_path'), output_image_resolution)
+4 -4
View File
@@ -94,23 +94,23 @@ def finalize_video(start_time : float) -> ErrorCode:
def conditional_clear_video_pool() -> None: def conditional_clear_video_pool() -> None:
if state_manager.get_item('workflow') == 'image-to-video': if state_manager.get_item('workflow_mode') == 'image-to-video':
video_manager.clear_video_pool() video_manager.clear_video_pool()
def conditional_restrict_video_fps() -> Fps: def conditional_restrict_video_fps() -> Fps:
if state_manager.get_item('workflow') == 'image-to-video': if state_manager.get_item('workflow_mode') == 'image-to-video':
return restrict_video_fps(state_manager.get_item('target_path'), state_manager.get_item('output_video_fps')) return restrict_video_fps(state_manager.get_item('target_path'), state_manager.get_item('output_video_fps'))
return conditional_get_output_fps() return conditional_get_output_fps()
def conditional_get_output_fps() -> Fps: def conditional_get_output_fps() -> Fps:
if state_manager.get_item('workflow') in [ 'audio-to-image:frames', 'audio-to-image:video' ]: if state_manager.get_item('workflow_mode') in [ 'audio-to-image:frames', 'audio-to-image:video' ]:
return state_manager.get_item('output_audio_fps') return state_manager.get_item('output_audio_fps')
return state_manager.get_item('output_video_fps') return state_manager.get_item('output_video_fps')
def conditional_scale_resolution() -> Resolution: def conditional_scale_resolution() -> Resolution:
if state_manager.get_item('workflow') == 'image-to-video': if state_manager.get_item('workflow_mode') == 'image-to-video':
return scale_resolution(detect_video_resolution(state_manager.get_item('target_path')), state_manager.get_item('output_video_scale')) return scale_resolution(detect_video_resolution(state_manager.get_item('target_path')), state_manager.get_item('output_video_scale'))
return scale_resolution(detect_image_resolution(state_manager.get_item('target_path')), state_manager.get_item('output_video_scale')) return scale_resolution(detect_image_resolution(state_manager.get_item('target_path')), state_manager.get_item('output_video_scale'))
+12 -3
View File
@@ -1,11 +1,10 @@
import subprocess
import tempfile import tempfile
from typing import Iterator from typing import Iterator
import pytest import pytest
from starlette.testclient import TestClient from starlette.testclient import TestClient
from facefusion import metadata, session_manager, state_manager from facefusion import ffmpeg, ffmpeg_builder, metadata, process_manager, session_manager, state_manager
from facefusion.apis import asset_store from facefusion.apis import asset_store
from facefusion.apis.core import create_api from facefusion.apis.core import create_api
from facefusion.download import conditional_download from facefusion.download import conditional_download
@@ -14,6 +13,7 @@ from .assert_helper import get_test_example_file, get_test_examples_directory
@pytest.fixture(scope = 'module', autouse = True) @pytest.fixture(scope = 'module', autouse = True)
def before_all() -> None: def before_all() -> None:
process_manager.start()
conditional_download(get_test_examples_directory(), conditional_download(get_test_examples_directory(),
[ [
'https://github.com/facefusion/facefusion-assets/releases/download/examples-3.0.0/source.jpg', 'https://github.com/facefusion/facefusion-assets/releases/download/examples-3.0.0/source.jpg',
@@ -21,7 +21,16 @@ def before_all() -> None:
'https://github.com/facefusion/facefusion-assets/releases/download/examples-3.0.0/target-240p.mp4' 'https://github.com/facefusion/facefusion-assets/releases/download/examples-3.0.0/target-240p.mp4'
]) ])
subprocess.run([ 'ffmpeg', '-i', get_test_example_file('target-240p.mp4'), '-vframes', '1', get_test_example_file('target-240p.jpg') ]) ffmpeg.run_ffmpeg(
ffmpeg_builder.chain(
ffmpeg_builder.set_input(get_test_example_file('target-240p.mp4')),
[
'-vframes',
'1'
],
ffmpeg_builder.set_output(get_test_example_file('target-240p.jpg'))
)
)
@pytest.fixture(scope = 'function', autouse = True) @pytest.fixture(scope = 'function', autouse = True)
+4 -6
View File
@@ -18,8 +18,7 @@ def before_all() -> None:
nargs = '+' nargs = '+'
) )
], ],
scopes = [ 'api' ], scopes = [ 'api' ]
groups = [ 'paths' ]
) )
capability_store.register_capability_set( capability_store.register_capability_set(
[ [
@@ -29,8 +28,7 @@ def before_all() -> None:
choices = [ 'mp4', 'mkv', 'webm' ] choices = [ 'mp4', 'mkv', 'webm' ]
) )
], ],
scopes = [ 'api' ], scopes = [ 'api' ]
groups = [ 'paths' ]
) )
@@ -57,5 +55,5 @@ def test_get_capabilities(test_client : TestClient) -> None:
assert 'mp4' in capabilities_body.get('formats').get('video') assert 'mp4' in capabilities_body.get('formats').get('video')
assert capabilities_body.get('arguments').get('paths').get('source_paths').get('default') is None assert capabilities_body.get('arguments').get('source_paths').get('default') is None
assert capabilities_body.get('arguments').get('paths').get('output_format').get('choices') == [ 'mp4', 'mkv', 'webm' ] assert capabilities_body.get('arguments').get('output_format').get('choices') == [ 'mp4', 'mkv', 'webm' ]
+15 -9
View File
@@ -1,11 +1,10 @@
import subprocess
from argparse import ArgumentParser from argparse import ArgumentParser
from typing import Iterator from typing import Iterator
import pytest import pytest
from starlette.testclient import TestClient from starlette.testclient import TestClient
from facefusion import capability_store, metadata, session_manager, state_manager from facefusion import capability_store, ffmpeg, ffmpeg_builder, metadata, process_manager, session_manager, state_manager
from facefusion.apis import asset_store from facefusion.apis import asset_store
from facefusion.apis.core import create_api from facefusion.apis.core import create_api
from facefusion.download import conditional_download from facefusion.download import conditional_download
@@ -14,6 +13,7 @@ from .assert_helper import get_test_example_file, get_test_examples_directory
@pytest.fixture(scope = 'module', autouse = True) @pytest.fixture(scope = 'module', autouse = True)
def before_all() -> None: def before_all() -> None:
process_manager.start()
program = ArgumentParser() program = ArgumentParser()
capability_store.register_capability_set( capability_store.register_capability_set(
[ [
@@ -22,8 +22,7 @@ def before_all() -> None:
nargs = '+' nargs = '+'
) )
], ],
scopes = [ 'api' ], scopes = [ 'api' ]
groups = [ 'paths' ]
) )
capability_store.register_capability_set( capability_store.register_capability_set(
[ [
@@ -31,8 +30,7 @@ def before_all() -> None:
'--target-path' '--target-path'
) )
], ],
scopes = [ 'api' ], scopes = [ 'api' ]
groups = [ 'paths' ]
) )
capability_store.register_capability_set( capability_store.register_capability_set(
[ [
@@ -41,8 +39,7 @@ def before_all() -> None:
nargs = '+' nargs = '+'
) )
], ],
scopes = [ 'api' ], scopes = [ 'api' ]
groups = [ 'paths' ]
) )
state_manager.init_item('execution_providers', [ 'cpu' ]) state_manager.init_item('execution_providers', [ 'cpu' ])
@@ -53,7 +50,16 @@ def before_all() -> None:
'https://github.com/facefusion/facefusion-assets/releases/download/examples-3.0.0/target-240p.mp4' 'https://github.com/facefusion/facefusion-assets/releases/download/examples-3.0.0/target-240p.mp4'
]) ])
subprocess.run([ 'ffmpeg', '-i', get_test_example_file('target-240p.mp4'), '-vframes', '1', get_test_example_file('target-240p.jpg') ]) ffmpeg.run_ffmpeg(
ffmpeg_builder.chain(
ffmpeg_builder.set_input(get_test_example_file('target-240p.mp4')),
[
'-vframes',
'1'
],
ffmpeg_builder.set_output(get_test_example_file('target-240p.jpg'))
)
)
@pytest.fixture(scope = 'function', autouse = True) @pytest.fixture(scope = 'function', autouse = True)
+10 -4
View File
@@ -1,8 +1,8 @@
import subprocess
import pytest import pytest
from pytest import approx from pytest import approx
from facefusion import ffmpeg, ffmpeg_builder, process_manager
from facefusion.audio import detect_audio_duration, get_audio_frame, read_static_audio, restrict_trim_audio_frame from facefusion.audio import detect_audio_duration, get_audio_frame, read_static_audio, restrict_trim_audio_frame
from facefusion.download import conditional_download from facefusion.download import conditional_download
from .assert_helper import get_test_example_file, get_test_examples_directory from .assert_helper import get_test_example_file, get_test_examples_directory
@@ -10,17 +10,23 @@ from .assert_helper import get_test_example_file, get_test_examples_directory
@pytest.fixture(scope = 'module', autouse = True) @pytest.fixture(scope = 'module', autouse = True)
def before_all() -> None: def before_all() -> None:
process_manager.start()
conditional_download(get_test_examples_directory(), conditional_download(get_test_examples_directory(),
[ [
'https://github.com/facefusion/facefusion-assets/releases/download/examples-3.0.0/source.mp3' 'https://github.com/facefusion/facefusion-assets/releases/download/examples-3.0.0/source.mp3'
]) ])
subprocess.run([ 'ffmpeg', '-i', get_test_example_file('source.mp3'), get_test_example_file('source.wav') ]) ffmpeg.run_ffmpeg(
ffmpeg_builder.chain(
ffmpeg_builder.set_input(get_test_example_file('source.mp3')),
ffmpeg_builder.set_output(get_test_example_file('source.wav'))
)
)
def test_get_audio_frame() -> None: def test_get_audio_frame() -> None:
assert hasattr(get_audio_frame(get_test_example_file('source.mp3'), 25), '__array_interface__') assert get_audio_frame(get_test_example_file('source.mp3'), 25).shape == (80, 16)
assert hasattr(get_audio_frame(get_test_example_file('source.wav'), 25), '__array_interface__') assert get_audio_frame(get_test_example_file('source.wav'), 25).shape == (80, 16)
assert get_audio_frame('invalid', 25) is None assert get_audio_frame('invalid', 25) is None
+15 -4
View File
@@ -3,6 +3,7 @@ import sys
import pytest import pytest
from facefusion import ffmpeg, ffmpeg_builder, process_manager
from facefusion.download import conditional_download from facefusion.download import conditional_download
from facefusion.jobs.job_manager import clear_jobs, init_jobs from facefusion.jobs.job_manager import clear_jobs, init_jobs
from .assert_helper import get_test_example_file, get_test_examples_directory, get_test_jobs_directory, get_test_output_path, is_test_output_file, is_test_output_sequence, prepare_test_output_directory from .assert_helper import get_test_example_file, get_test_examples_directory, get_test_jobs_directory, get_test_output_path, is_test_output_file, is_test_output_sequence, prepare_test_output_directory
@@ -10,12 +11,22 @@ from .assert_helper import get_test_example_file, get_test_examples_directory, g
@pytest.fixture(scope = 'module', autouse = True) @pytest.fixture(scope = 'module', autouse = True)
def before_all() -> None: def before_all() -> None:
process_manager.start()
conditional_download(get_test_examples_directory(), conditional_download(get_test_examples_directory(),
[ [
'https://github.com/facefusion/facefusion-assets/releases/download/examples-3.0.0/target-240p.mp4' 'https://github.com/facefusion/facefusion-assets/releases/download/examples-3.0.0/target-240p.mp4'
]) ])
subprocess.run([ 'ffmpeg', '-i', get_test_example_file('target-240p.mp4'), '-vframes', '1', get_test_example_file('target-240p.jpg') ]) ffmpeg.run_ffmpeg(
ffmpeg_builder.chain(
ffmpeg_builder.set_input(get_test_example_file('target-240p.mp4')),
[
'-vframes',
'1'
],
ffmpeg_builder.set_output(get_test_example_file('target-240p.jpg'))
)
)
@pytest.fixture(scope = 'function', autouse = True) @pytest.fixture(scope = 'function', autouse = True)
@@ -26,21 +37,21 @@ def before_each() -> None:
def test_modify_age_to_image() -> None: def test_modify_age_to_image() -> None:
commands = [ sys.executable, 'facefusion.py', 'run', '--workflow', 'image-to-image', '--jobs-path', get_test_jobs_directory(), '--processors', 'age_modifier', '--age-modifier-direction', '100', '-t', get_test_example_file('target-240p.jpg'), '-o', get_test_output_path('test-age-face-to-image.jpg') ] commands = [ sys.executable, 'facefusion.py', 'run', '--workflow-mode', 'image-to-image', '--jobs-path', get_test_jobs_directory(), '--processors', 'age_modifier', '--age-modifier-direction', '100', '-t', get_test_example_file('target-240p.jpg'), '-o', get_test_output_path('test-age-face-to-image.jpg') ]
assert subprocess.run(commands).returncode == 0 assert subprocess.run(commands).returncode == 0
assert is_test_output_file('test-age-face-to-image.jpg') is True assert is_test_output_file('test-age-face-to-image.jpg') is True
def test_modify_age_to_video() -> None: def test_modify_age_to_video() -> None:
commands = [ sys.executable, 'facefusion.py', 'run', '--workflow', 'image-to-video', '--jobs-path', get_test_jobs_directory(), '--processors', 'age_modifier', '--age-modifier-direction', '100', '-t', get_test_example_file('target-240p.mp4'), '-o', get_test_output_path('test-age-face-to-video.mp4'), '--trim-frame-end', '1' ] commands = [ sys.executable, 'facefusion.py', 'run', '--workflow-mode', 'image-to-video', '--jobs-path', get_test_jobs_directory(), '--processors', 'age_modifier', '--age-modifier-direction', '100', '-t', get_test_example_file('target-240p.mp4'), '-o', get_test_output_path('test-age-face-to-video.mp4'), '--trim-frame-end', '1' ]
assert subprocess.run(commands).returncode == 0 assert subprocess.run(commands).returncode == 0
assert is_test_output_file('test-age-face-to-video.mp4') is True assert is_test_output_file('test-age-face-to-video.mp4') is True
def test_modify_age_to_video_as_frames() -> None: def test_modify_age_to_video_as_frames() -> None:
commands = [ sys.executable, 'facefusion.py', 'run', '--workflow', 'image-to-video:frames', '--jobs-path', get_test_jobs_directory(), '--processors', 'age_modifier', '--age-modifier-direction', '100', '-t', get_test_example_file('target-240p.mp4'), '-o', get_test_output_path('test-age-face-to-video-as-frames'), '--trim-frame-end', '1' ] commands = [ sys.executable, 'facefusion.py', 'run', '--workflow-mode', 'image-to-video:frames', '--jobs-path', get_test_jobs_directory(), '--processors', 'age_modifier', '--age-modifier-direction', '100', '-t', get_test_example_file('target-240p.mp4'), '-o', get_test_output_path('test-age-face-to-video-as-frames'), '--trim-frame-end', '1' ]
assert subprocess.run(commands).returncode == 0 assert subprocess.run(commands).returncode == 0
assert is_test_output_sequence(get_test_output_path('test-age-face-to-video-as-frames')) is True assert is_test_output_sequence(get_test_output_path('test-age-face-to-video-as-frames')) is True
+15 -4
View File
@@ -3,6 +3,7 @@ import sys
import pytest import pytest
from facefusion import ffmpeg, ffmpeg_builder, process_manager
from facefusion.download import conditional_download from facefusion.download import conditional_download
from facefusion.jobs.job_manager import clear_jobs, init_jobs from facefusion.jobs.job_manager import clear_jobs, init_jobs
from .assert_helper import get_test_example_file, get_test_examples_directory, get_test_jobs_directory, get_test_output_path, is_test_output_file, is_test_output_sequence, prepare_test_output_directory from .assert_helper import get_test_example_file, get_test_examples_directory, get_test_jobs_directory, get_test_output_path, is_test_output_file, is_test_output_sequence, prepare_test_output_directory
@@ -10,13 +11,23 @@ from .assert_helper import get_test_example_file, get_test_examples_directory, g
@pytest.fixture(scope = 'module', autouse = True) @pytest.fixture(scope = 'module', autouse = True)
def before_all() -> None: def before_all() -> None:
process_manager.start()
conditional_download(get_test_examples_directory(), conditional_download(get_test_examples_directory(),
[ [
'https://github.com/facefusion/facefusion-assets/releases/download/examples-3.0.0/source.jpg', 'https://github.com/facefusion/facefusion-assets/releases/download/examples-3.0.0/source.jpg',
'https://github.com/facefusion/facefusion-assets/releases/download/examples-3.0.0/target-240p.mp4' 'https://github.com/facefusion/facefusion-assets/releases/download/examples-3.0.0/target-240p.mp4'
]) ])
subprocess.run([ 'ffmpeg', '-i', get_test_example_file('target-240p.mp4'), '-vframes', '1', get_test_example_file('target-240p.jpg') ]) ffmpeg.run_ffmpeg(
ffmpeg_builder.chain(
ffmpeg_builder.set_input(get_test_example_file('target-240p.mp4')),
[
'-vframes',
'1'
],
ffmpeg_builder.set_output(get_test_example_file('target-240p.jpg'))
)
)
@pytest.fixture(scope = 'function', autouse = True) @pytest.fixture(scope = 'function', autouse = True)
@@ -27,21 +38,21 @@ def before_each() -> None:
def test_remove_background_to_image() -> None: def test_remove_background_to_image() -> None:
commands = [ sys.executable, 'facefusion.py', 'run', '--workflow', 'image-to-image', '--jobs-path', get_test_jobs_directory(), '--processors', 'background_remover', '-t', get_test_example_file('target-240p.jpg'), '-o', get_test_output_path('test-remove-background-to-image.jpg') ] commands = [ sys.executable, 'facefusion.py', 'run', '--workflow-mode', 'image-to-image', '--jobs-path', get_test_jobs_directory(), '--processors', 'background_remover', '-t', get_test_example_file('target-240p.jpg'), '-o', get_test_output_path('test-remove-background-to-image.jpg') ]
assert subprocess.run(commands).returncode == 0 assert subprocess.run(commands).returncode == 0
assert is_test_output_file('test-remove-background-to-image.jpg') is True assert is_test_output_file('test-remove-background-to-image.jpg') is True
def test_remove_background_to_video() -> None: def test_remove_background_to_video() -> None:
commands = [ sys.executable, 'facefusion.py', 'run', '--workflow', 'image-to-video', '--jobs-path', get_test_jobs_directory(), '--processors', 'background_remover', '-t', get_test_example_file('target-240p.mp4'), '-o', get_test_output_path('test-remove-background-to-video.mp4'), '--trim-frame-end', '1' ] commands = [ sys.executable, 'facefusion.py', 'run', '--workflow-mode', 'image-to-video', '--jobs-path', get_test_jobs_directory(), '--processors', 'background_remover', '-t', get_test_example_file('target-240p.mp4'), '-o', get_test_output_path('test-remove-background-to-video.mp4'), '--trim-frame-end', '1' ]
assert subprocess.run(commands).returncode == 0 assert subprocess.run(commands).returncode == 0
assert is_test_output_file('test-remove-background-to-video.mp4') is True assert is_test_output_file('test-remove-background-to-video.mp4') is True
def test_remove_background_to_video_as_frames() -> None: def test_remove_background_to_video_as_frames() -> None:
commands = [ sys.executable, 'facefusion.py', 'run', '--workflow', 'image-to-video:frames', '--jobs-path', get_test_jobs_directory(), '--processors', 'background_remover', '-t', get_test_example_file('target-240p.mp4'), '-o', get_test_output_path('test-remove-background-to-video-as-frames'), '--trim-frame-end', '1' ] commands = [ sys.executable, 'facefusion.py', 'run', '--workflow-mode', 'image-to-video:frames', '--jobs-path', get_test_jobs_directory(), '--processors', 'background_remover', '-t', get_test_example_file('target-240p.mp4'), '-o', get_test_output_path('test-remove-background-to-video-as-frames'), '--trim-frame-end', '1' ]
assert subprocess.run(commands).returncode == 0 assert subprocess.run(commands).returncode == 0
assert is_test_output_sequence(get_test_output_path('test-remove-background-to-video-as-frames')) is True assert is_test_output_sequence(get_test_output_path('test-remove-background-to-video-as-frames')) is True
+15 -4
View File
@@ -3,6 +3,7 @@ import sys
import pytest import pytest
from facefusion import ffmpeg, ffmpeg_builder, process_manager
from facefusion.download import conditional_download from facefusion.download import conditional_download
from facefusion.jobs.job_manager import clear_jobs, init_jobs from facefusion.jobs.job_manager import clear_jobs, init_jobs
from .assert_helper import get_test_example_file, get_test_examples_directory, get_test_jobs_directory, get_test_output_path, is_test_output_file, prepare_test_output_directory from .assert_helper import get_test_example_file, get_test_examples_directory, get_test_jobs_directory, get_test_output_path, is_test_output_file, prepare_test_output_directory
@@ -10,13 +11,23 @@ from .assert_helper import get_test_example_file, get_test_examples_directory, g
@pytest.fixture(scope = 'module', autouse = True) @pytest.fixture(scope = 'module', autouse = True)
def before_all() -> None: def before_all() -> None:
process_manager.start()
conditional_download(get_test_examples_directory(), conditional_download(get_test_examples_directory(),
[ [
'https://github.com/facefusion/facefusion-assets/releases/download/examples-3.0.0/target-240p.mp4' 'https://github.com/facefusion/facefusion-assets/releases/download/examples-3.0.0/target-240p.mp4'
]) ])
subprocess.run([ 'ffmpeg', '-i', get_test_example_file('target-240p.mp4'), '-vframes', '1', get_test_example_file('target-240p-batch-1.jpg') ]) for frame_number in [ 1, 2 ]:
subprocess.run([ 'ffmpeg', '-i', get_test_example_file('target-240p.mp4'), '-vframes', '2', get_test_example_file('target-240p-batch-2.jpg') ]) ffmpeg.run_ffmpeg(
ffmpeg_builder.chain(
ffmpeg_builder.set_input(get_test_example_file('target-240p.mp4')),
[
'-vframes',
str(frame_number)
],
ffmpeg_builder.set_output(get_test_example_file('target-240p-batch-' + str(frame_number) + '.jpg'))
)
)
@pytest.fixture(scope = 'function', autouse = True) @pytest.fixture(scope = 'function', autouse = True)
@@ -27,7 +38,7 @@ def before_each() -> None:
def test_batch_run_targets() -> None: def test_batch_run_targets() -> None:
commands = [ sys.executable, 'facefusion.py', 'batch-run', '--workflow', 'image-to-image', '--jobs-path', get_test_jobs_directory(), '--processors', 'face_debugger', '-t', get_test_example_file('target-240p-batch-*.jpg'), '-o', get_test_output_path('test-batch-run-targets-{index}.jpg') ] commands = [ sys.executable, 'facefusion.py', 'batch-run', '--workflow-mode', 'image-to-image', '--jobs-path', get_test_jobs_directory(), '--processors', 'face_debugger', '-t', get_test_example_file('target-240p-batch-*.jpg'), '-o', get_test_output_path('test-batch-run-targets-{index}.jpg') ]
assert subprocess.run(commands).returncode == 0 assert subprocess.run(commands).returncode == 0
assert is_test_output_file('test-batch-run-targets-0.jpg') is True assert is_test_output_file('test-batch-run-targets-0.jpg') is True
@@ -36,7 +47,7 @@ def test_batch_run_targets() -> None:
def test_batch_run_sources_to_targets() -> None: def test_batch_run_sources_to_targets() -> None:
commands = [ sys.executable, 'facefusion.py', 'batch-run', '--workflow', 'image-to-image', '--jobs-path', get_test_jobs_directory(), '-s', get_test_example_file('target-240p-batch-*.jpg'), '-t', get_test_example_file('target-240p-batch-*.jpg'), '-o', get_test_output_path('test-batch-run-sources-to-targets-{index}.jpg') ] commands = [ sys.executable, 'facefusion.py', 'batch-run', '--workflow-mode', 'image-to-image', '--jobs-path', get_test_jobs_directory(), '-s', get_test_example_file('target-240p-batch-*.jpg'), '-t', get_test_example_file('target-240p-batch-*.jpg'), '-o', get_test_output_path('test-batch-run-sources-to-targets-{index}.jpg') ]
assert subprocess.run(commands).returncode == 0 assert subprocess.run(commands).returncode == 0
assert is_test_output_file('test-batch-run-sources-to-targets-0.jpg') is True assert is_test_output_file('test-batch-run-sources-to-targets-0.jpg') is True
+15 -4
View File
@@ -3,6 +3,7 @@ import sys
import pytest import pytest
from facefusion import ffmpeg, ffmpeg_builder, process_manager
from facefusion.download import conditional_download from facefusion.download import conditional_download
from facefusion.jobs.job_manager import clear_jobs, init_jobs from facefusion.jobs.job_manager import clear_jobs, init_jobs
from .assert_helper import get_test_example_file, get_test_examples_directory, get_test_jobs_directory, get_test_output_path, is_test_output_file, is_test_output_sequence, prepare_test_output_directory from .assert_helper import get_test_example_file, get_test_examples_directory, get_test_jobs_directory, get_test_output_path, is_test_output_file, is_test_output_sequence, prepare_test_output_directory
@@ -10,12 +11,22 @@ from .assert_helper import get_test_example_file, get_test_examples_directory, g
@pytest.fixture(scope = 'module', autouse = True) @pytest.fixture(scope = 'module', autouse = True)
def before_all() -> None: def before_all() -> None:
process_manager.start()
conditional_download(get_test_examples_directory(), conditional_download(get_test_examples_directory(),
[ [
'https://github.com/facefusion/facefusion-assets/releases/download/examples-3.0.0/target-240p.mp4' 'https://github.com/facefusion/facefusion-assets/releases/download/examples-3.0.0/target-240p.mp4'
]) ])
subprocess.run([ 'ffmpeg', '-i', get_test_example_file('target-240p.mp4'), '-vframes', '1', get_test_example_file('target-240p.jpg') ]) ffmpeg.run_ffmpeg(
ffmpeg_builder.chain(
ffmpeg_builder.set_input(get_test_example_file('target-240p.mp4')),
[
'-vframes',
'1'
],
ffmpeg_builder.set_output(get_test_example_file('target-240p.jpg'))
)
)
@pytest.fixture(scope = 'function', autouse = True) @pytest.fixture(scope = 'function', autouse = True)
@@ -26,21 +37,21 @@ def before_each() -> None:
def test_restore_expression_to_image() -> None: def test_restore_expression_to_image() -> None:
commands = [ sys.executable, 'facefusion.py', 'run', '--workflow', 'image-to-image', '--jobs-path', get_test_jobs_directory(), '--processors', 'expression_restorer', '-t', get_test_example_file('target-240p.jpg'), '-o', get_test_output_path('test-restore-expression-to-image.jpg') ] commands = [ sys.executable, 'facefusion.py', 'run', '--workflow-mode', 'image-to-image', '--jobs-path', get_test_jobs_directory(), '--processors', 'expression_restorer', '-t', get_test_example_file('target-240p.jpg'), '-o', get_test_output_path('test-restore-expression-to-image.jpg') ]
assert subprocess.run(commands).returncode == 0 assert subprocess.run(commands).returncode == 0
assert is_test_output_file('test-restore-expression-to-image.jpg') is True assert is_test_output_file('test-restore-expression-to-image.jpg') is True
def test_restore_expression_to_video() -> None: def test_restore_expression_to_video() -> None:
commands = [ sys.executable, 'facefusion.py', 'run', '--workflow', 'image-to-video', '--jobs-path', get_test_jobs_directory(), '--processors', 'expression_restorer', '-t', get_test_example_file('target-240p.mp4'), '-o', get_test_output_path('test-restore-expression-to-video.mp4'), '--trim-frame-end', '1' ] commands = [ sys.executable, 'facefusion.py', 'run', '--workflow-mode', 'image-to-video', '--jobs-path', get_test_jobs_directory(), '--processors', 'expression_restorer', '-t', get_test_example_file('target-240p.mp4'), '-o', get_test_output_path('test-restore-expression-to-video.mp4'), '--trim-frame-end', '1' ]
assert subprocess.run(commands).returncode == 0 assert subprocess.run(commands).returncode == 0
assert is_test_output_file('test-restore-expression-to-video.mp4') is True assert is_test_output_file('test-restore-expression-to-video.mp4') is True
def test_restore_expression_to_video_as_frames() -> None: def test_restore_expression_to_video_as_frames() -> None:
commands = [ sys.executable, 'facefusion.py', 'run', '--workflow', 'image-to-video:frames', '--jobs-path', get_test_jobs_directory(), '--processors', 'expression_restorer', '-t', get_test_example_file('target-240p.mp4'), '-o', get_test_output_path('test-restore-expression-to-video-as-frames'), '--trim-frame-end', '1' ] commands = [ sys.executable, 'facefusion.py', 'run', '--workflow-mode', 'image-to-video:frames', '--jobs-path', get_test_jobs_directory(), '--processors', 'expression_restorer', '-t', get_test_example_file('target-240p.mp4'), '-o', get_test_output_path('test-restore-expression-to-video-as-frames'), '--trim-frame-end', '1' ]
assert subprocess.run(commands).returncode == 0 assert subprocess.run(commands).returncode == 0
assert is_test_output_sequence(get_test_output_path('test-restore-expression-to-video-as-frames')) is True assert is_test_output_sequence(get_test_output_path('test-restore-expression-to-video-as-frames')) is True
+15 -4
View File
@@ -3,6 +3,7 @@ import sys
import pytest import pytest
from facefusion import ffmpeg, ffmpeg_builder, process_manager
from facefusion.download import conditional_download from facefusion.download import conditional_download
from facefusion.jobs.job_manager import clear_jobs, init_jobs from facefusion.jobs.job_manager import clear_jobs, init_jobs
from .assert_helper import get_test_example_file, get_test_examples_directory, get_test_jobs_directory, get_test_output_path, is_test_output_file, is_test_output_sequence, prepare_test_output_directory from .assert_helper import get_test_example_file, get_test_examples_directory, get_test_jobs_directory, get_test_output_path, is_test_output_file, is_test_output_sequence, prepare_test_output_directory
@@ -10,13 +11,23 @@ from .assert_helper import get_test_example_file, get_test_examples_directory, g
@pytest.fixture(scope = 'module', autouse = True) @pytest.fixture(scope = 'module', autouse = True)
def before_all() -> None: def before_all() -> None:
process_manager.start()
conditional_download(get_test_examples_directory(), conditional_download(get_test_examples_directory(),
[ [
'https://github.com/facefusion/facefusion-assets/releases/download/examples-3.0.0/source.jpg', 'https://github.com/facefusion/facefusion-assets/releases/download/examples-3.0.0/source.jpg',
'https://github.com/facefusion/facefusion-assets/releases/download/examples-3.0.0/target-240p.mp4' 'https://github.com/facefusion/facefusion-assets/releases/download/examples-3.0.0/target-240p.mp4'
]) ])
subprocess.run([ 'ffmpeg', '-i', get_test_example_file('target-240p.mp4'), '-vframes', '1', get_test_example_file('target-240p.jpg') ]) ffmpeg.run_ffmpeg(
ffmpeg_builder.chain(
ffmpeg_builder.set_input(get_test_example_file('target-240p.mp4')),
[
'-vframes',
'1'
],
ffmpeg_builder.set_output(get_test_example_file('target-240p.jpg'))
)
)
@pytest.fixture(scope = 'function', autouse = True) @pytest.fixture(scope = 'function', autouse = True)
@@ -27,21 +38,21 @@ def before_each() -> None:
def test_debug_face_to_image() -> None: def test_debug_face_to_image() -> None:
commands = [ sys.executable, 'facefusion.py', 'run', '--workflow', 'image-to-image', '--jobs-path', get_test_jobs_directory(), '--processors', 'face_debugger', '-t', get_test_example_file('target-240p.jpg'), '-o', get_test_output_path('test-debug-face-to-image.jpg') ] commands = [ sys.executable, 'facefusion.py', 'run', '--workflow-mode', 'image-to-image', '--jobs-path', get_test_jobs_directory(), '--processors', 'face_debugger', '-t', get_test_example_file('target-240p.jpg'), '-o', get_test_output_path('test-debug-face-to-image.jpg') ]
assert subprocess.run(commands).returncode == 0 assert subprocess.run(commands).returncode == 0
assert is_test_output_file('test-debug-face-to-image.jpg') is True assert is_test_output_file('test-debug-face-to-image.jpg') is True
def test_debug_face_to_video() -> None: def test_debug_face_to_video() -> None:
commands = [ sys.executable, 'facefusion.py', 'run', '--workflow', 'image-to-video', '--jobs-path', get_test_jobs_directory(), '--processors', 'face_debugger', '-t', get_test_example_file('target-240p.mp4'), '-o', get_test_output_path('test-debug-face-to-video.mp4'), '--trim-frame-end', '1' ] commands = [ sys.executable, 'facefusion.py', 'run', '--workflow-mode', 'image-to-video', '--jobs-path', get_test_jobs_directory(), '--processors', 'face_debugger', '-t', get_test_example_file('target-240p.mp4'), '-o', get_test_output_path('test-debug-face-to-video.mp4'), '--trim-frame-end', '1' ]
assert subprocess.run(commands).returncode == 0 assert subprocess.run(commands).returncode == 0
assert is_test_output_file('test-debug-face-to-video.mp4') is True assert is_test_output_file('test-debug-face-to-video.mp4') is True
def test_debug_face_to_video_as_frames() -> None: def test_debug_face_to_video_as_frames() -> None:
commands = [ sys.executable, 'facefusion.py', 'run', '--workflow', 'image-to-video:frames', '--jobs-path', get_test_jobs_directory(), '--processors', 'face_debugger', '-t', get_test_example_file('target-240p.mp4'), '-o', get_test_output_path('test-debug-face-to-video-as-frames'), '--trim-frame-end', '1' ] commands = [ sys.executable, 'facefusion.py', 'run', '--workflow-mode', 'image-to-video:frames', '--jobs-path', get_test_jobs_directory(), '--processors', 'face_debugger', '-t', get_test_example_file('target-240p.mp4'), '-o', get_test_output_path('test-debug-face-to-video-as-frames'), '--trim-frame-end', '1' ]
assert subprocess.run(commands).returncode == 0 assert subprocess.run(commands).returncode == 0
assert is_test_output_sequence(get_test_output_path('test-debug-face-to-video-as-frames')) is True assert is_test_output_sequence(get_test_output_path('test-debug-face-to-video-as-frames')) is True
+15 -4
View File
@@ -3,6 +3,7 @@ import sys
import pytest import pytest
from facefusion import ffmpeg, ffmpeg_builder, process_manager
from facefusion.download import conditional_download from facefusion.download import conditional_download
from facefusion.jobs.job_manager import clear_jobs, init_jobs from facefusion.jobs.job_manager import clear_jobs, init_jobs
from .assert_helper import get_test_example_file, get_test_examples_directory, get_test_jobs_directory, get_test_output_path, is_test_output_file, is_test_output_sequence, prepare_test_output_directory from .assert_helper import get_test_example_file, get_test_examples_directory, get_test_jobs_directory, get_test_output_path, is_test_output_file, is_test_output_sequence, prepare_test_output_directory
@@ -10,13 +11,23 @@ from .assert_helper import get_test_example_file, get_test_examples_directory, g
@pytest.fixture(scope = 'module', autouse = True) @pytest.fixture(scope = 'module', autouse = True)
def before_all() -> None: def before_all() -> None:
process_manager.start()
conditional_download(get_test_examples_directory(), conditional_download(get_test_examples_directory(),
[ [
'https://github.com/facefusion/facefusion-assets/releases/download/examples-3.0.0/source.jpg', 'https://github.com/facefusion/facefusion-assets/releases/download/examples-3.0.0/source.jpg',
'https://github.com/facefusion/facefusion-assets/releases/download/examples-3.0.0/target-240p.mp4' 'https://github.com/facefusion/facefusion-assets/releases/download/examples-3.0.0/target-240p.mp4'
]) ])
subprocess.run([ 'ffmpeg', '-i', get_test_example_file('target-240p.mp4'), '-vframes', '1', get_test_example_file('target-240p.jpg') ]) ffmpeg.run_ffmpeg(
ffmpeg_builder.chain(
ffmpeg_builder.set_input(get_test_example_file('target-240p.mp4')),
[
'-vframes',
'1'
],
ffmpeg_builder.set_output(get_test_example_file('target-240p.jpg'))
)
)
@pytest.fixture(scope = 'function', autouse = True) @pytest.fixture(scope = 'function', autouse = True)
@@ -27,21 +38,21 @@ def before_each() -> None:
def test_edit_face_to_image() -> None: def test_edit_face_to_image() -> None:
commands = [ sys.executable, 'facefusion.py', 'run', '--workflow', 'image-to-image', '--jobs-path', get_test_jobs_directory(), '--processors', 'face_editor', '-t', get_test_example_file('target-240p.jpg'), '-o', get_test_output_path('test-edit-face-to-image.jpg') ] commands = [ sys.executable, 'facefusion.py', 'run', '--workflow-mode', 'image-to-image', '--jobs-path', get_test_jobs_directory(), '--processors', 'face_editor', '-t', get_test_example_file('target-240p.jpg'), '-o', get_test_output_path('test-edit-face-to-image.jpg') ]
assert subprocess.run(commands).returncode == 0 assert subprocess.run(commands).returncode == 0
assert is_test_output_file('test-edit-face-to-image.jpg') is True assert is_test_output_file('test-edit-face-to-image.jpg') is True
def test_edit_face_to_video() -> None: def test_edit_face_to_video() -> None:
commands = [ sys.executable, 'facefusion.py', 'run', '--workflow', 'image-to-video', '--jobs-path', get_test_jobs_directory(), '--processors', 'face_editor', '-t', get_test_example_file('target-240p.mp4'), '-o', get_test_output_path('test-edit-face-to-video.mp4'), '--trim-frame-end', '1' ] commands = [ sys.executable, 'facefusion.py', 'run', '--workflow-mode', 'image-to-video', '--jobs-path', get_test_jobs_directory(), '--processors', 'face_editor', '-t', get_test_example_file('target-240p.mp4'), '-o', get_test_output_path('test-edit-face-to-video.mp4'), '--trim-frame-end', '1' ]
assert subprocess.run(commands).returncode == 0 assert subprocess.run(commands).returncode == 0
assert is_test_output_file('test-edit-face-to-video.mp4') is True assert is_test_output_file('test-edit-face-to-video.mp4') is True
def test_edit_face_to_video_as_frames() -> None: def test_edit_face_to_video_as_frames() -> None:
commands = [ sys.executable, 'facefusion.py', 'run', '--workflow', 'image-to-video:frames', '--jobs-path', get_test_jobs_directory(), '--processors', 'face_editor', '-t', get_test_example_file('target-240p.mp4'), '-o', get_test_output_path('test-edit-face-to-video-as-frames'), '--trim-frame-end', '1' ] commands = [ sys.executable, 'facefusion.py', 'run', '--workflow-mode', 'image-to-video:frames', '--jobs-path', get_test_jobs_directory(), '--processors', 'face_editor', '-t', get_test_example_file('target-240p.mp4'), '-o', get_test_output_path('test-edit-face-to-video-as-frames'), '--trim-frame-end', '1' ]
assert subprocess.run(commands).returncode == 0 assert subprocess.run(commands).returncode == 0
assert is_test_output_sequence(get_test_output_path('test-edit-face-to-video-as-frames')) is True assert is_test_output_sequence(get_test_output_path('test-edit-face-to-video-as-frames')) is True
+15 -4
View File
@@ -3,6 +3,7 @@ import sys
import pytest import pytest
from facefusion import ffmpeg, ffmpeg_builder, process_manager
from facefusion.download import conditional_download from facefusion.download import conditional_download
from facefusion.jobs.job_manager import clear_jobs, init_jobs from facefusion.jobs.job_manager import clear_jobs, init_jobs
from .assert_helper import get_test_example_file, get_test_examples_directory, get_test_jobs_directory, get_test_output_path, is_test_output_file, is_test_output_sequence, prepare_test_output_directory from .assert_helper import get_test_example_file, get_test_examples_directory, get_test_jobs_directory, get_test_output_path, is_test_output_file, is_test_output_sequence, prepare_test_output_directory
@@ -10,13 +11,23 @@ from .assert_helper import get_test_example_file, get_test_examples_directory, g
@pytest.fixture(scope = 'module', autouse = True) @pytest.fixture(scope = 'module', autouse = True)
def before_all() -> None: def before_all() -> None:
process_manager.start()
conditional_download(get_test_examples_directory(), conditional_download(get_test_examples_directory(),
[ [
'https://github.com/facefusion/facefusion-assets/releases/download/examples-3.0.0/source.jpg', 'https://github.com/facefusion/facefusion-assets/releases/download/examples-3.0.0/source.jpg',
'https://github.com/facefusion/facefusion-assets/releases/download/examples-3.0.0/target-240p.mp4' 'https://github.com/facefusion/facefusion-assets/releases/download/examples-3.0.0/target-240p.mp4'
]) ])
subprocess.run([ 'ffmpeg', '-i', get_test_example_file('target-240p.mp4'), '-vframes', '1', get_test_example_file('target-240p.jpg') ]) ffmpeg.run_ffmpeg(
ffmpeg_builder.chain(
ffmpeg_builder.set_input(get_test_example_file('target-240p.mp4')),
[
'-vframes',
'1'
],
ffmpeg_builder.set_output(get_test_example_file('target-240p.jpg'))
)
)
@pytest.fixture(scope = 'function', autouse = True) @pytest.fixture(scope = 'function', autouse = True)
@@ -27,21 +38,21 @@ def before_each() -> None:
def test_enhance_face_to_image() -> None: def test_enhance_face_to_image() -> None:
commands = [ sys.executable, 'facefusion.py', 'run', '--workflow', 'image-to-image', '--jobs-path', get_test_jobs_directory(), '--processors', 'face_enhancer', '-t', get_test_example_file('target-240p.jpg'), '-o', get_test_output_path('test-enhance-face-to-image.jpg') ] commands = [ sys.executable, 'facefusion.py', 'run', '--workflow-mode', 'image-to-image', '--jobs-path', get_test_jobs_directory(), '--processors', 'face_enhancer', '-t', get_test_example_file('target-240p.jpg'), '-o', get_test_output_path('test-enhance-face-to-image.jpg') ]
assert subprocess.run(commands).returncode == 0 assert subprocess.run(commands).returncode == 0
assert is_test_output_file('test-enhance-face-to-image.jpg') is True assert is_test_output_file('test-enhance-face-to-image.jpg') is True
def test_enhance_face_to_video() -> None: def test_enhance_face_to_video() -> None:
commands = [ sys.executable, 'facefusion.py', 'run', '--workflow', 'image-to-video', '--jobs-path', get_test_jobs_directory(), '--processors', 'face_enhancer', '-t', get_test_example_file('target-240p.mp4'), '-o', get_test_output_path('test-enhance-face-to-video.mp4'), '--trim-frame-end', '1' ] commands = [ sys.executable, 'facefusion.py', 'run', '--workflow-mode', 'image-to-video', '--jobs-path', get_test_jobs_directory(), '--processors', 'face_enhancer', '-t', get_test_example_file('target-240p.mp4'), '-o', get_test_output_path('test-enhance-face-to-video.mp4'), '--trim-frame-end', '1' ]
assert subprocess.run(commands).returncode == 0 assert subprocess.run(commands).returncode == 0
assert is_test_output_file('test-enhance-face-to-video.mp4') is True assert is_test_output_file('test-enhance-face-to-video.mp4') is True
def test_enhance_face_to_video_as_frames() -> None: def test_enhance_face_to_video_as_frames() -> None:
commands = [ sys.executable, 'facefusion.py', 'run', '--workflow', 'image-to-video:frames', '--jobs-path', get_test_jobs_directory(), '--processors', 'face_enhancer', '-t', get_test_example_file('target-240p.mp4'), '-o', get_test_output_path('test-enhance-face-to-video-as-frames'), '--trim-frame-end', '1' ] commands = [ sys.executable, 'facefusion.py', 'run', '--workflow-mode', 'image-to-video:frames', '--jobs-path', get_test_jobs_directory(), '--processors', 'face_enhancer', '-t', get_test_example_file('target-240p.mp4'), '-o', get_test_output_path('test-enhance-face-to-video-as-frames'), '--trim-frame-end', '1' ]
assert subprocess.run(commands).returncode == 0 assert subprocess.run(commands).returncode == 0
assert is_test_output_sequence(get_test_output_path('test-enhance-face-to-video-as-frames')) is True assert is_test_output_sequence(get_test_output_path('test-enhance-face-to-video-as-frames')) is True
+15 -4
View File
@@ -3,6 +3,7 @@ import sys
import pytest import pytest
from facefusion import ffmpeg, ffmpeg_builder, process_manager
from facefusion.download import conditional_download from facefusion.download import conditional_download
from facefusion.jobs.job_manager import clear_jobs, init_jobs from facefusion.jobs.job_manager import clear_jobs, init_jobs
from .assert_helper import get_test_example_file, get_test_examples_directory, get_test_jobs_directory, get_test_output_path, is_test_output_file, is_test_output_sequence, prepare_test_output_directory from .assert_helper import get_test_example_file, get_test_examples_directory, get_test_jobs_directory, get_test_output_path, is_test_output_file, is_test_output_sequence, prepare_test_output_directory
@@ -10,13 +11,23 @@ from .assert_helper import get_test_example_file, get_test_examples_directory, g
@pytest.fixture(scope = 'module', autouse = True) @pytest.fixture(scope = 'module', autouse = True)
def before_all() -> None: def before_all() -> None:
process_manager.start()
conditional_download(get_test_examples_directory(), conditional_download(get_test_examples_directory(),
[ [
'https://github.com/facefusion/facefusion-assets/releases/download/examples-3.0.0/source.jpg', 'https://github.com/facefusion/facefusion-assets/releases/download/examples-3.0.0/source.jpg',
'https://github.com/facefusion/facefusion-assets/releases/download/examples-3.0.0/target-240p.mp4' 'https://github.com/facefusion/facefusion-assets/releases/download/examples-3.0.0/target-240p.mp4'
]) ])
subprocess.run([ 'ffmpeg', '-i', get_test_example_file('target-240p.mp4'), '-vframes', '1', get_test_example_file('target-240p.jpg') ]) ffmpeg.run_ffmpeg(
ffmpeg_builder.chain(
ffmpeg_builder.set_input(get_test_example_file('target-240p.mp4')),
[
'-vframes',
'1'
],
ffmpeg_builder.set_output(get_test_example_file('target-240p.jpg'))
)
)
@pytest.fixture(scope = 'function', autouse = True) @pytest.fixture(scope = 'function', autouse = True)
@@ -27,21 +38,21 @@ def before_each() -> None:
def test_swap_face_to_image() -> None: def test_swap_face_to_image() -> None:
commands = [ sys.executable, 'facefusion.py', 'run', '--workflow', 'image-to-image', '--jobs-path', get_test_jobs_directory(), '--processors', 'face_swapper', '-s', get_test_example_file('source.jpg'), '-t', get_test_example_file('target-240p.jpg'), '-o', get_test_output_path('test-swap-face-to-image.jpg') ] commands = [ sys.executable, 'facefusion.py', 'run', '--workflow-mode', 'image-to-image', '--jobs-path', get_test_jobs_directory(), '--processors', 'face_swapper', '-s', get_test_example_file('source.jpg'), '-t', get_test_example_file('target-240p.jpg'), '-o', get_test_output_path('test-swap-face-to-image.jpg') ]
assert subprocess.run(commands).returncode == 0 assert subprocess.run(commands).returncode == 0
assert is_test_output_file('test-swap-face-to-image.jpg') is True assert is_test_output_file('test-swap-face-to-image.jpg') is True
def test_swap_face_to_video() -> None: def test_swap_face_to_video() -> None:
commands = [ sys.executable, 'facefusion.py', 'run', '--workflow', 'image-to-video', '--jobs-path', get_test_jobs_directory(), '--processors', 'face_swapper', '-s', get_test_example_file('source.jpg'), '-t', get_test_example_file('target-240p.mp4'), '-o', get_test_output_path('test-swap-face-to-video.mp4'), '--trim-frame-end', '1' ] commands = [ sys.executable, 'facefusion.py', 'run', '--workflow-mode', 'image-to-video', '--jobs-path', get_test_jobs_directory(), '--processors', 'face_swapper', '-s', get_test_example_file('source.jpg'), '-t', get_test_example_file('target-240p.mp4'), '-o', get_test_output_path('test-swap-face-to-video.mp4'), '--trim-frame-end', '1' ]
assert subprocess.run(commands).returncode == 0 assert subprocess.run(commands).returncode == 0
assert is_test_output_file('test-swap-face-to-video.mp4') is True assert is_test_output_file('test-swap-face-to-video.mp4') is True
def test_swap_face_to_video_as_frames() -> None: def test_swap_face_to_video_as_frames() -> None:
commands = [ sys.executable, 'facefusion.py', 'run', '--workflow', 'image-to-video:frames', '--jobs-path', get_test_jobs_directory(), '--processors', 'face_swapper', '-s', get_test_example_file('source.jpg'), '-t', get_test_example_file('target-240p.mp4'), '-o', get_test_output_path('test-swap-face-to-video-as-frames'), '--trim-frame-end', '1' ] commands = [ sys.executable, 'facefusion.py', 'run', '--workflow-mode', 'image-to-video:frames', '--jobs-path', get_test_jobs_directory(), '--processors', 'face_swapper', '-s', get_test_example_file('source.jpg'), '-t', get_test_example_file('target-240p.mp4'), '-o', get_test_output_path('test-swap-face-to-video-as-frames'), '--trim-frame-end', '1' ]
assert subprocess.run(commands).returncode == 0 assert subprocess.run(commands).returncode == 0
assert is_test_output_sequence(get_test_output_path('test-swap-face-to-video-as-frames')) is True assert is_test_output_sequence(get_test_output_path('test-swap-face-to-video-as-frames')) is True
+29 -5
View File
@@ -3,6 +3,7 @@ import sys
import pytest import pytest
from facefusion import ffmpeg, ffmpeg_builder, process_manager
from facefusion.download import conditional_download from facefusion.download import conditional_download
from facefusion.jobs.job_manager import clear_jobs, init_jobs from facefusion.jobs.job_manager import clear_jobs, init_jobs
from .assert_helper import get_test_example_file, get_test_examples_directory, get_test_jobs_directory, get_test_output_path, is_test_output_file, is_test_output_sequence, prepare_test_output_directory from .assert_helper import get_test_example_file, get_test_examples_directory, get_test_jobs_directory, get_test_output_path, is_test_output_file, is_test_output_sequence, prepare_test_output_directory
@@ -10,14 +11,37 @@ from .assert_helper import get_test_example_file, get_test_examples_directory, g
@pytest.fixture(scope = 'module', autouse = True) @pytest.fixture(scope = 'module', autouse = True)
def before_all() -> None: def before_all() -> None:
process_manager.start()
conditional_download(get_test_examples_directory(), conditional_download(get_test_examples_directory(),
[ [
'https://github.com/facefusion/facefusion-assets/releases/download/examples-3.0.0/source.jpg', 'https://github.com/facefusion/facefusion-assets/releases/download/examples-3.0.0/source.jpg',
'https://github.com/facefusion/facefusion-assets/releases/download/examples-3.0.0/target-240p.mp4' 'https://github.com/facefusion/facefusion-assets/releases/download/examples-3.0.0/target-240p.mp4'
]) ])
subprocess.run([ 'ffmpeg', '-i', get_test_example_file('target-240p.mp4'), '-vframes', '1', '-vf', 'hue=s=0', get_test_example_file('target-240p-0sat.jpg') ]) ffmpeg.run_ffmpeg(
subprocess.run([ 'ffmpeg', '-i', get_test_example_file('target-240p.mp4'), '-vf', 'hue=s=0', get_test_example_file('target-240p-0sat.mp4') ]) ffmpeg_builder.chain(
ffmpeg_builder.set_input(get_test_example_file('target-240p.mp4')),
[
'-vframes',
'1'
],
[
'-vf',
'hue=s=0'
],
ffmpeg_builder.set_output(get_test_example_file('target-240p-0sat.jpg'))
)
)
ffmpeg.run_ffmpeg(
ffmpeg_builder.chain(
ffmpeg_builder.set_input(get_test_example_file('target-240p.mp4')),
[
'-vf',
'hue=s=0'
],
ffmpeg_builder.set_output(get_test_example_file('target-240p-0sat.mp4'))
)
)
@pytest.fixture(scope = 'function', autouse = True) @pytest.fixture(scope = 'function', autouse = True)
@@ -28,21 +52,21 @@ def before_each() -> None:
def test_colorize_frame_to_image() -> None: def test_colorize_frame_to_image() -> None:
commands = [ sys.executable, 'facefusion.py', 'run', '--workflow', 'image-to-image', '--jobs-path', get_test_jobs_directory(), '--processors', 'frame_colorizer', '-t', get_test_example_file('target-240p-0sat.jpg'), '-o', get_test_output_path('test_colorize-frame-to-image.jpg') ] commands = [ sys.executable, 'facefusion.py', 'run', '--workflow-mode', 'image-to-image', '--jobs-path', get_test_jobs_directory(), '--processors', 'frame_colorizer', '-t', get_test_example_file('target-240p-0sat.jpg'), '-o', get_test_output_path('test_colorize-frame-to-image.jpg') ]
assert subprocess.run(commands).returncode == 0 assert subprocess.run(commands).returncode == 0
assert is_test_output_file('test_colorize-frame-to-image.jpg') is True assert is_test_output_file('test_colorize-frame-to-image.jpg') is True
def test_colorize_frame_to_video() -> None: def test_colorize_frame_to_video() -> None:
commands = [ sys.executable, 'facefusion.py', 'run', '--workflow', 'image-to-video', '--jobs-path', get_test_jobs_directory(), '--processors', 'frame_colorizer', '-t', get_test_example_file('target-240p-0sat.mp4'), '-o', get_test_output_path('test-colorize-frame-to-video.mp4'), '--trim-frame-end', '1' ] commands = [ sys.executable, 'facefusion.py', 'run', '--workflow-mode', 'image-to-video', '--jobs-path', get_test_jobs_directory(), '--processors', 'frame_colorizer', '-t', get_test_example_file('target-240p-0sat.mp4'), '-o', get_test_output_path('test-colorize-frame-to-video.mp4'), '--trim-frame-end', '1' ]
assert subprocess.run(commands).returncode == 0 assert subprocess.run(commands).returncode == 0
assert is_test_output_file('test-colorize-frame-to-video.mp4') is True assert is_test_output_file('test-colorize-frame-to-video.mp4') is True
def test_colorize_frame_to_video_as_frames() -> None: def test_colorize_frame_to_video_as_frames() -> None:
commands = [ sys.executable, 'facefusion.py', 'run', '--workflow', 'image-to-video:frames', '--jobs-path', get_test_jobs_directory(), '--processors', 'frame_colorizer', '-t', get_test_example_file('target-240p-0sat.mp4'), '-o', get_test_output_path('test-colorize-frame-to-video-as-frames'), '--trim-frame-end', '1' ] commands = [ sys.executable, 'facefusion.py', 'run', '--workflow-mode', 'image-to-video:frames', '--jobs-path', get_test_jobs_directory(), '--processors', 'frame_colorizer', '-t', get_test_example_file('target-240p-0sat.mp4'), '-o', get_test_output_path('test-colorize-frame-to-video-as-frames'), '--trim-frame-end', '1' ]
assert subprocess.run(commands).returncode == 0 assert subprocess.run(commands).returncode == 0
assert is_test_output_sequence(get_test_output_path('test-colorize-frame-to-video-as-frames')) is True assert is_test_output_sequence(get_test_output_path('test-colorize-frame-to-video-as-frames')) is True
+15 -4
View File
@@ -3,6 +3,7 @@ import sys
import pytest import pytest
from facefusion import ffmpeg, ffmpeg_builder, process_manager
from facefusion.download import conditional_download from facefusion.download import conditional_download
from facefusion.jobs.job_manager import clear_jobs, init_jobs from facefusion.jobs.job_manager import clear_jobs, init_jobs
from .assert_helper import get_test_example_file, get_test_examples_directory, get_test_jobs_directory, get_test_output_path, is_test_output_file, is_test_output_sequence, prepare_test_output_directory from .assert_helper import get_test_example_file, get_test_examples_directory, get_test_jobs_directory, get_test_output_path, is_test_output_file, is_test_output_sequence, prepare_test_output_directory
@@ -10,13 +11,23 @@ from .assert_helper import get_test_example_file, get_test_examples_directory, g
@pytest.fixture(scope = 'module', autouse = True) @pytest.fixture(scope = 'module', autouse = True)
def before_all() -> None: def before_all() -> None:
process_manager.start()
conditional_download(get_test_examples_directory(), conditional_download(get_test_examples_directory(),
[ [
'https://github.com/facefusion/facefusion-assets/releases/download/examples-3.0.0/source.jpg', 'https://github.com/facefusion/facefusion-assets/releases/download/examples-3.0.0/source.jpg',
'https://github.com/facefusion/facefusion-assets/releases/download/examples-3.0.0/target-240p.mp4' 'https://github.com/facefusion/facefusion-assets/releases/download/examples-3.0.0/target-240p.mp4'
]) ])
subprocess.run([ 'ffmpeg', '-i', get_test_example_file('target-240p.mp4'), '-vframes', '1', get_test_example_file('target-240p.jpg') ]) ffmpeg.run_ffmpeg(
ffmpeg_builder.chain(
ffmpeg_builder.set_input(get_test_example_file('target-240p.mp4')),
[
'-vframes',
'1'
],
ffmpeg_builder.set_output(get_test_example_file('target-240p.jpg'))
)
)
@pytest.fixture(scope = 'function', autouse = True) @pytest.fixture(scope = 'function', autouse = True)
@@ -27,21 +38,21 @@ def before_each() -> None:
def test_enhance_frame_to_image() -> None: def test_enhance_frame_to_image() -> None:
commands = [ sys.executable, 'facefusion.py', 'run', '--workflow', 'image-to-image', '--jobs-path', get_test_jobs_directory(), '--processors', 'frame_enhancer', '-t', get_test_example_file('target-240p.jpg'), '-o', get_test_output_path('test-enhance-frame-to-image.jpg') ] commands = [ sys.executable, 'facefusion.py', 'run', '--workflow-mode', 'image-to-image', '--jobs-path', get_test_jobs_directory(), '--processors', 'frame_enhancer', '-t', get_test_example_file('target-240p.jpg'), '-o', get_test_output_path('test-enhance-frame-to-image.jpg') ]
assert subprocess.run(commands).returncode == 0 assert subprocess.run(commands).returncode == 0
assert is_test_output_file('test-enhance-frame-to-image.jpg') is True assert is_test_output_file('test-enhance-frame-to-image.jpg') is True
def test_enhance_frame_to_video() -> None: def test_enhance_frame_to_video() -> None:
commands = [ sys.executable, 'facefusion.py', 'run', '--workflow', 'image-to-video', '--jobs-path', get_test_jobs_directory(), '--processors', 'frame_enhancer', '-t', get_test_example_file('target-240p.mp4'), '-o', get_test_output_path('test-enhance-frame-to-video.mp4'), '--trim-frame-end', '1' ] commands = [ sys.executable, 'facefusion.py', 'run', '--workflow-mode', 'image-to-video', '--jobs-path', get_test_jobs_directory(), '--processors', 'frame_enhancer', '-t', get_test_example_file('target-240p.mp4'), '-o', get_test_output_path('test-enhance-frame-to-video.mp4'), '--trim-frame-end', '1' ]
assert subprocess.run(commands).returncode == 0 assert subprocess.run(commands).returncode == 0
assert is_test_output_file('test-enhance-frame-to-video.mp4') is True assert is_test_output_file('test-enhance-frame-to-video.mp4') is True
def test_enhance_frame_to_video_as_frames() -> None: def test_enhance_frame_to_video_as_frames() -> None:
commands = [ sys.executable, 'facefusion.py', 'run', '--workflow', 'image-to-video:frames', '--jobs-path', get_test_jobs_directory(), '--processors', 'frame_enhancer', '-t', get_test_example_file('target-240p.mp4'), '-o', get_test_output_path('test-enhance-frame-to-video-as-frames'), '--trim-frame-end', '1' ] commands = [ sys.executable, 'facefusion.py', 'run', '--workflow-mode', 'image-to-video:frames', '--jobs-path', get_test_jobs_directory(), '--processors', 'frame_enhancer', '-t', get_test_example_file('target-240p.mp4'), '-o', get_test_output_path('test-enhance-frame-to-video-as-frames'), '--trim-frame-end', '1' ]
assert subprocess.run(commands).returncode == 0 assert subprocess.run(commands).returncode == 0
assert is_test_output_sequence(get_test_output_path('test-enhance-frame-to-video-as-frames')) is True assert is_test_output_sequence(get_test_output_path('test-enhance-frame-to-video-as-frames')) is True
+26 -15
View File
@@ -3,6 +3,7 @@ import sys
import pytest import pytest
from facefusion import ffmpeg, ffmpeg_builder, process_manager
from facefusion.download import conditional_download from facefusion.download import conditional_download
from facefusion.jobs.job_manager import clear_jobs, count_step_total, init_jobs from facefusion.jobs.job_manager import clear_jobs, count_step_total, init_jobs
from .assert_helper import get_test_example_file, get_test_examples_directory, get_test_jobs_directory, get_test_output_path, is_test_job_file from .assert_helper import get_test_example_file, get_test_examples_directory, get_test_jobs_directory, get_test_output_path, is_test_job_file
@@ -10,13 +11,23 @@ from .assert_helper import get_test_example_file, get_test_examples_directory, g
@pytest.fixture(scope = 'module', autouse = True) @pytest.fixture(scope = 'module', autouse = True)
def before_all() -> None: def before_all() -> None:
process_manager.start()
conditional_download(get_test_examples_directory(), conditional_download(get_test_examples_directory(),
[ [
'https://github.com/facefusion/facefusion-assets/releases/download/examples-3.0.0/source.jpg', 'https://github.com/facefusion/facefusion-assets/releases/download/examples-3.0.0/source.jpg',
'https://github.com/facefusion/facefusion-assets/releases/download/examples-3.0.0/target-240p.mp4' 'https://github.com/facefusion/facefusion-assets/releases/download/examples-3.0.0/target-240p.mp4'
]) ])
subprocess.run([ 'ffmpeg', '-i', get_test_example_file('target-240p.mp4'), '-vframes', '1', get_test_example_file('target-240p.jpg') ]) ffmpeg.run_ffmpeg(
ffmpeg_builder.chain(
ffmpeg_builder.set_input(get_test_example_file('target-240p.mp4')),
[
'-vframes',
'1'
],
ffmpeg_builder.set_output(get_test_example_file('target-240p.jpg'))
)
)
@pytest.fixture(scope = 'function', autouse = True) @pytest.fixture(scope = 'function', autouse = True)
@@ -51,7 +62,7 @@ def test_job_submit() -> None:
assert subprocess.run(commands).returncode == 1 assert subprocess.run(commands).returncode == 1
commands = [ sys.executable, 'facefusion.py', 'job-add-step', 'test-job-submit', '--workflow', 'image-to-image', '--jobs-path', get_test_jobs_directory(), '-s', get_test_example_file('source.jpg'), '-t', get_test_example_file('target-240p.jpg'), '-o', get_test_output_path('test-job-remix-step.jpg') ] commands = [ sys.executable, 'facefusion.py', 'job-add-step', 'test-job-submit', '--workflow-mode', 'image-to-image', '--jobs-path', get_test_jobs_directory(), '-s', get_test_example_file('source.jpg'), '-t', get_test_example_file('target-240p.jpg'), '-o', get_test_output_path('test-job-remix-step.jpg') ]
subprocess.run(commands) subprocess.run(commands)
commands = [ sys.executable, 'facefusion.py', 'job-submit', 'test-job-submit', '--jobs-path', get_test_jobs_directory() ] commands = [ sys.executable, 'facefusion.py', 'job-submit', 'test-job-submit', '--jobs-path', get_test_jobs_directory() ]
@@ -74,10 +85,10 @@ def test_submit_all() -> None:
assert subprocess.run(commands).returncode == 1 assert subprocess.run(commands).returncode == 1
commands = [ sys.executable, 'facefusion.py', 'job-add-step', 'test-job-submit-all-1', '--workflow', 'image-to-image', '--jobs-path', get_test_jobs_directory(), '-s', get_test_example_file('source.jpg'), '-t', get_test_example_file('target-240p.jpg'), '-o', get_test_output_path('test-job-remix-step.jpg') ] commands = [ sys.executable, 'facefusion.py', 'job-add-step', 'test-job-submit-all-1', '--workflow-mode', 'image-to-image', '--jobs-path', get_test_jobs_directory(), '-s', get_test_example_file('source.jpg'), '-t', get_test_example_file('target-240p.jpg'), '-o', get_test_output_path('test-job-remix-step.jpg') ]
subprocess.run(commands) subprocess.run(commands)
commands = [ sys.executable, 'facefusion.py', 'job-add-step', 'test-job-submit-all-2', '--workflow', 'image-to-image', '--jobs-path', get_test_jobs_directory(), '-s', get_test_example_file('source.jpg'), '-t', get_test_example_file('target-240p.jpg'), '-o', get_test_output_path('test-job-remix-step.jpg') ] commands = [ sys.executable, 'facefusion.py', 'job-add-step', 'test-job-submit-all-2', '--workflow-mode', 'image-to-image', '--jobs-path', get_test_jobs_directory(), '-s', get_test_example_file('source.jpg'), '-t', get_test_example_file('target-240p.jpg'), '-o', get_test_output_path('test-job-remix-step.jpg') ]
subprocess.run(commands) subprocess.run(commands)
commands = [ sys.executable, 'facefusion.py', 'job-submit-all', '--jobs-path', get_test_jobs_directory(), '--halt-on-error' ] commands = [ sys.executable, 'facefusion.py', 'job-submit-all', '--jobs-path', get_test_jobs_directory(), '--halt-on-error' ]
@@ -123,7 +134,7 @@ def test_job_delete_all() -> None:
def test_job_add_step() -> None: def test_job_add_step() -> None:
commands = [ sys.executable, 'facefusion.py', 'job-add-step', 'test-job-add-step', '--workflow', 'image-to-image', '--jobs-path', get_test_jobs_directory(), '-s', get_test_example_file('source.jpg'), '-t', get_test_example_file('target-240p.jpg'), '-o', get_test_output_path('test-job-remix-step.jpg') ] commands = [ sys.executable, 'facefusion.py', 'job-add-step', 'test-job-add-step', '--workflow-mode', 'image-to-image', '--jobs-path', get_test_jobs_directory(), '-s', get_test_example_file('source.jpg'), '-t', get_test_example_file('target-240p.jpg'), '-o', get_test_output_path('test-job-remix-step.jpg') ]
assert subprocess.run(commands).returncode == 1 assert subprocess.run(commands).returncode == 1
assert count_step_total('test-job-add-step') == 0 assert count_step_total('test-job-add-step') == 0
@@ -131,14 +142,14 @@ def test_job_add_step() -> None:
commands = [ sys.executable, 'facefusion.py', 'job-create', 'test-job-add-step', '--jobs-path', get_test_jobs_directory() ] commands = [ sys.executable, 'facefusion.py', 'job-create', 'test-job-add-step', '--jobs-path', get_test_jobs_directory() ]
subprocess.run(commands) subprocess.run(commands)
commands = [ sys.executable, 'facefusion.py', 'job-add-step', 'test-job-add-step', '--workflow', 'image-to-image', '--jobs-path', get_test_jobs_directory(), '-s', get_test_example_file('source.jpg'), '-t', get_test_example_file('target-240p.jpg'), '-o', get_test_output_path('test-job-remix-step.jpg') ] commands = [ sys.executable, 'facefusion.py', 'job-add-step', 'test-job-add-step', '--workflow-mode', 'image-to-image', '--jobs-path', get_test_jobs_directory(), '-s', get_test_example_file('source.jpg'), '-t', get_test_example_file('target-240p.jpg'), '-o', get_test_output_path('test-job-remix-step.jpg') ]
assert subprocess.run(commands).returncode == 0 assert subprocess.run(commands).returncode == 0
assert count_step_total('test-job-add-step') == 1 assert count_step_total('test-job-add-step') == 1
def test_job_remix() -> None: def test_job_remix() -> None:
commands = [ sys.executable, 'facefusion.py', 'job-remix-step', 'test-job-remix-step', '0', '--workflow', 'image-to-image', '--jobs-path', get_test_jobs_directory(), '-s', get_test_example_file('source.jpg'), '-o', get_test_output_path('test-job-remix-step.jpg') ] commands = [ sys.executable, 'facefusion.py', 'job-remix-step', 'test-job-remix-step', '0', '--workflow-mode', 'image-to-image', '--jobs-path', get_test_jobs_directory(), '-s', get_test_example_file('source.jpg'), '-o', get_test_output_path('test-job-remix-step.jpg') ]
assert subprocess.run(commands).returncode == 1 assert subprocess.run(commands).returncode == 1
assert count_step_total('test-job-remix-step') == 0 assert count_step_total('test-job-remix-step') == 0
@@ -146,23 +157,23 @@ def test_job_remix() -> None:
commands = [ sys.executable, 'facefusion.py', 'job-create', 'test-job-remix-step', '--jobs-path', get_test_jobs_directory() ] commands = [ sys.executable, 'facefusion.py', 'job-create', 'test-job-remix-step', '--jobs-path', get_test_jobs_directory() ]
subprocess.run(commands) subprocess.run(commands)
commands = [ sys.executable, 'facefusion.py', 'job-add-step', 'test-job-remix-step', '--workflow', 'image-to-image', '--jobs-path', get_test_jobs_directory(), '-s', get_test_example_file('source.jpg'), '-t', get_test_example_file('target-240p.jpg'), '-o', get_test_output_path('test-job-remix-step.jpg') ] commands = [ sys.executable, 'facefusion.py', 'job-add-step', 'test-job-remix-step', '--workflow-mode', 'image-to-image', '--jobs-path', get_test_jobs_directory(), '-s', get_test_example_file('source.jpg'), '-t', get_test_example_file('target-240p.jpg'), '-o', get_test_output_path('test-job-remix-step.jpg') ]
subprocess.run(commands) subprocess.run(commands)
commands = [ sys.executable, 'facefusion.py', 'job-remix-step', 'test-job-remix-step', '0', '--workflow', 'image-to-image', '--jobs-path', get_test_jobs_directory(), '-s', get_test_example_file('source.jpg'), '-o', get_test_output_path('test-job-remix-step.jpg') ] commands = [ sys.executable, 'facefusion.py', 'job-remix-step', 'test-job-remix-step', '0', '--workflow-mode', 'image-to-image', '--jobs-path', get_test_jobs_directory(), '-s', get_test_example_file('source.jpg'), '-o', get_test_output_path('test-job-remix-step.jpg') ]
assert count_step_total('test-job-remix-step') == 1 assert count_step_total('test-job-remix-step') == 1
assert subprocess.run(commands).returncode == 0 assert subprocess.run(commands).returncode == 0
assert count_step_total('test-job-remix-step') == 2 assert count_step_total('test-job-remix-step') == 2
commands = [ sys.executable, 'facefusion.py', 'job-remix-step', 'test-job-remix-step', '-1', '--workflow', 'image-to-image', '--jobs-path', get_test_jobs_directory(), '-s', get_test_example_file('source.jpg'), '-o', get_test_output_path('test-job-remix-step.jpg') ] commands = [ sys.executable, 'facefusion.py', 'job-remix-step', 'test-job-remix-step', '-1', '--workflow-mode', 'image-to-image', '--jobs-path', get_test_jobs_directory(), '-s', get_test_example_file('source.jpg'), '-o', get_test_output_path('test-job-remix-step.jpg') ]
assert subprocess.run(commands).returncode == 0 assert subprocess.run(commands).returncode == 0
assert count_step_total('test-job-remix-step') == 3 assert count_step_total('test-job-remix-step') == 3
def test_job_insert_step() -> None: def test_job_insert_step() -> None:
commands = [ sys.executable, 'facefusion.py', 'job-insert-step', 'test-job-insert-step', '0', '--workflow', 'image-to-image', '--jobs-path', get_test_jobs_directory(), '-s', get_test_example_file('source.jpg'), '-t', get_test_example_file('target-240p.jpg'), '-o', get_test_output_path('test-job-remix-step.jpg') ] commands = [ sys.executable, 'facefusion.py', 'job-insert-step', 'test-job-insert-step', '0', '--workflow-mode', 'image-to-image', '--jobs-path', get_test_jobs_directory(), '-s', get_test_example_file('source.jpg'), '-t', get_test_example_file('target-240p.jpg'), '-o', get_test_output_path('test-job-remix-step.jpg') ]
assert subprocess.run(commands).returncode == 1 assert subprocess.run(commands).returncode == 1
assert count_step_total('test-job-insert-step') == 0 assert count_step_total('test-job-insert-step') == 0
@@ -170,16 +181,16 @@ def test_job_insert_step() -> None:
commands = [ sys.executable, 'facefusion.py', 'job-create', 'test-job-insert-step', '--jobs-path', get_test_jobs_directory() ] commands = [ sys.executable, 'facefusion.py', 'job-create', 'test-job-insert-step', '--jobs-path', get_test_jobs_directory() ]
subprocess.run(commands) subprocess.run(commands)
commands = [ sys.executable, 'facefusion.py', 'job-add-step', 'test-job-insert-step', '--workflow', 'image-to-image', '--jobs-path', get_test_jobs_directory(), '-s', get_test_example_file('source.jpg'), '-t', get_test_example_file('target-240p.jpg'), '-o', get_test_output_path('test-job-remix-step.jpg') ] commands = [ sys.executable, 'facefusion.py', 'job-add-step', 'test-job-insert-step', '--workflow-mode', 'image-to-image', '--jobs-path', get_test_jobs_directory(), '-s', get_test_example_file('source.jpg'), '-t', get_test_example_file('target-240p.jpg'), '-o', get_test_output_path('test-job-remix-step.jpg') ]
subprocess.run(commands) subprocess.run(commands)
commands = [ sys.executable, 'facefusion.py', 'job-insert-step', 'test-job-insert-step', '0', '--workflow', 'image-to-image', '--jobs-path', get_test_jobs_directory(), '-s', get_test_example_file('source.jpg'), '-t', get_test_example_file('target-240p.jpg'), '-o', get_test_output_path('test-job-remix-step.jpg') ] commands = [ sys.executable, 'facefusion.py', 'job-insert-step', 'test-job-insert-step', '0', '--workflow-mode', 'image-to-image', '--jobs-path', get_test_jobs_directory(), '-s', get_test_example_file('source.jpg'), '-t', get_test_example_file('target-240p.jpg'), '-o', get_test_output_path('test-job-remix-step.jpg') ]
assert count_step_total('test-job-insert-step') == 1 assert count_step_total('test-job-insert-step') == 1
assert subprocess.run(commands).returncode == 0 assert subprocess.run(commands).returncode == 0
assert count_step_total('test-job-insert-step') == 2 assert count_step_total('test-job-insert-step') == 2
commands = [ sys.executable, 'facefusion.py', 'job-insert-step', 'test-job-insert-step', '-1', '--workflow', 'image-to-image', '--jobs-path', get_test_jobs_directory(), '-s', get_test_example_file('source.jpg'), '-t', get_test_example_file('target-240p.jpg'), '-o', get_test_output_path('test-job-remix-step.jpg') ] commands = [ sys.executable, 'facefusion.py', 'job-insert-step', 'test-job-insert-step', '-1', '--workflow-mode', 'image-to-image', '--jobs-path', get_test_jobs_directory(), '-s', get_test_example_file('source.jpg'), '-t', get_test_example_file('target-240p.jpg'), '-o', get_test_output_path('test-job-remix-step.jpg') ]
assert subprocess.run(commands).returncode == 0 assert subprocess.run(commands).returncode == 0
assert count_step_total('test-job-insert-step') == 3 assert count_step_total('test-job-insert-step') == 3
@@ -193,7 +204,7 @@ def test_job_remove_step() -> None:
commands = [ sys.executable, 'facefusion.py', 'job-create', 'test-job-remove-step', '--jobs-path', get_test_jobs_directory() ] commands = [ sys.executable, 'facefusion.py', 'job-create', 'test-job-remove-step', '--jobs-path', get_test_jobs_directory() ]
subprocess.run(commands) subprocess.run(commands)
commands = [ sys.executable, 'facefusion.py', 'job-add-step', 'test-job-remove-step', '--workflow', 'image-to-image', '--jobs-path', get_test_jobs_directory(), '-s', get_test_example_file('source.jpg'), '-t', get_test_example_file('target-240p.jpg'), '-o', get_test_output_path('test-job-remix-step.jpg') ] commands = [ sys.executable, 'facefusion.py', 'job-add-step', 'test-job-remove-step', '--workflow-mode', 'image-to-image', '--jobs-path', get_test_jobs_directory(), '-s', get_test_example_file('source.jpg'), '-t', get_test_example_file('target-240p.jpg'), '-o', get_test_output_path('test-job-remix-step.jpg') ]
subprocess.run(commands) subprocess.run(commands)
subprocess.run(commands) subprocess.run(commands)
+20 -9
View File
@@ -3,6 +3,7 @@ import sys
import pytest import pytest
from facefusion import ffmpeg, ffmpeg_builder, process_manager
from facefusion.download import conditional_download from facefusion.download import conditional_download
from facefusion.jobs.job_manager import clear_jobs, init_jobs, move_job_file, set_steps_status from facefusion.jobs.job_manager import clear_jobs, init_jobs, move_job_file, set_steps_status
from .assert_helper import get_test_example_file, get_test_examples_directory, get_test_jobs_directory, get_test_output_path, is_test_output_file, prepare_test_output_directory from .assert_helper import get_test_example_file, get_test_examples_directory, get_test_jobs_directory, get_test_output_path, is_test_output_file, prepare_test_output_directory
@@ -10,13 +11,23 @@ from .assert_helper import get_test_example_file, get_test_examples_directory, g
@pytest.fixture(scope = 'module', autouse = True) @pytest.fixture(scope = 'module', autouse = True)
def before_all() -> None: def before_all() -> None:
process_manager.start()
conditional_download(get_test_examples_directory(), conditional_download(get_test_examples_directory(),
[ [
'https://github.com/facefusion/facefusion-assets/releases/download/examples-3.0.0/source.jpg', 'https://github.com/facefusion/facefusion-assets/releases/download/examples-3.0.0/source.jpg',
'https://github.com/facefusion/facefusion-assets/releases/download/examples-3.0.0/target-240p.mp4' 'https://github.com/facefusion/facefusion-assets/releases/download/examples-3.0.0/target-240p.mp4'
]) ])
subprocess.run([ 'ffmpeg', '-i', get_test_example_file('target-240p.mp4'), '-vframes', '1', get_test_example_file('target-240p.jpg') ]) ffmpeg.run_ffmpeg(
ffmpeg_builder.chain(
ffmpeg_builder.set_input(get_test_example_file('target-240p.mp4')),
[
'-vframes',
'1'
],
ffmpeg_builder.set_output(get_test_example_file('target-240p.jpg'))
)
)
@pytest.fixture(scope = 'function', autouse = True) @pytest.fixture(scope = 'function', autouse = True)
@@ -34,7 +45,7 @@ def test_job_run() -> None:
commands = [ sys.executable, 'facefusion.py', 'job-create', 'test-job-run', '--jobs-path', get_test_jobs_directory() ] commands = [ sys.executable, 'facefusion.py', 'job-create', 'test-job-run', '--jobs-path', get_test_jobs_directory() ]
subprocess.run(commands) subprocess.run(commands)
commands = [ sys.executable, 'facefusion.py', 'job-add-step', 'test-job-run', '--workflow', 'image-to-image', '--jobs-path', get_test_jobs_directory(), '--processors', 'face_debugger', '-t', get_test_example_file('target-240p.jpg'), '-o', get_test_output_path('test-job-run.jpg') ] commands = [ sys.executable, 'facefusion.py', 'job-add-step', 'test-job-run', '--workflow-mode', 'image-to-image', '--jobs-path', get_test_jobs_directory(), '--processors', 'face_debugger', '-t', get_test_example_file('target-240p.jpg'), '-o', get_test_output_path('test-job-run.jpg') ]
subprocess.run(commands) subprocess.run(commands)
commands = [ sys.executable, 'facefusion.py', 'job-run', 'test-job-run', '--jobs-path', get_test_jobs_directory() ] commands = [ sys.executable, 'facefusion.py', 'job-run', 'test-job-run', '--jobs-path', get_test_jobs_directory() ]
@@ -62,13 +73,13 @@ def test_job_run_all() -> None:
commands = [ sys.executable, 'facefusion.py', 'job-create', 'test-job-run-all-2', '--jobs-path', get_test_jobs_directory() ] commands = [ sys.executable, 'facefusion.py', 'job-create', 'test-job-run-all-2', '--jobs-path', get_test_jobs_directory() ]
subprocess.run(commands) subprocess.run(commands)
commands = [ sys.executable, 'facefusion.py', 'job-add-step', 'test-job-run-all-1', '--workflow', 'image-to-image', '--jobs-path', get_test_jobs_directory(), '--processors', 'face_debugger', '-t', get_test_example_file('target-240p.jpg'), '-o', get_test_output_path('test-job-run-all-1.jpg') ] commands = [ sys.executable, 'facefusion.py', 'job-add-step', 'test-job-run-all-1', '--workflow-mode', 'image-to-image', '--jobs-path', get_test_jobs_directory(), '--processors', 'face_debugger', '-t', get_test_example_file('target-240p.jpg'), '-o', get_test_output_path('test-job-run-all-1.jpg') ]
subprocess.run(commands) subprocess.run(commands)
commands = [ sys.executable, 'facefusion.py', 'job-add-step', 'test-job-run-all-2', '--workflow', 'image-to-video', '--jobs-path', get_test_jobs_directory(), '--processors', 'face_debugger', '-t', get_test_example_file('target-240p.mp4'), '-o', get_test_output_path('test-job-run-all-2.mp4'), '--trim-frame-end', '1' ] commands = [ sys.executable, 'facefusion.py', 'job-add-step', 'test-job-run-all-2', '--workflow-mode', 'image-to-video', '--jobs-path', get_test_jobs_directory(), '--processors', 'face_debugger', '-t', get_test_example_file('target-240p.mp4'), '-o', get_test_output_path('test-job-run-all-2.mp4'), '--trim-frame-end', '1' ]
subprocess.run(commands) subprocess.run(commands)
commands = [ sys.executable, 'facefusion.py', 'job-add-step', 'test-job-run-all-2', '--workflow', 'image-to-video', '--jobs-path', get_test_jobs_directory(), '--processors', 'face_debugger', '-t', get_test_example_file('target-240p.mp4'), '-o', get_test_output_path('test-job-run-all-2.mp4'), '--trim-frame-start', '0', '--trim-frame-end', '1' ] commands = [ sys.executable, 'facefusion.py', 'job-add-step', 'test-job-run-all-2', '--workflow-mode', 'image-to-video', '--jobs-path', get_test_jobs_directory(), '--processors', 'face_debugger', '-t', get_test_example_file('target-240p.mp4'), '-o', get_test_output_path('test-job-run-all-2.mp4'), '--trim-frame-start', '0', '--trim-frame-end', '1' ]
subprocess.run(commands) subprocess.run(commands)
commands = [ sys.executable, 'facefusion.py', 'job-run-all', '--jobs-path', get_test_jobs_directory(), '--halt-on-error' ] commands = [ sys.executable, 'facefusion.py', 'job-run-all', '--jobs-path', get_test_jobs_directory(), '--halt-on-error' ]
@@ -94,7 +105,7 @@ def test_job_retry() -> None:
commands = [ sys.executable, 'facefusion.py', 'job-create', 'test-job-retry', '--jobs-path', get_test_jobs_directory() ] commands = [ sys.executable, 'facefusion.py', 'job-create', 'test-job-retry', '--jobs-path', get_test_jobs_directory() ]
subprocess.run(commands) subprocess.run(commands)
commands = [sys.executable, 'facefusion.py', 'job-add-step', 'test-job-retry', '--workflow', 'image-to-image', '--jobs-path', get_test_jobs_directory(), '--processors', 'face_debugger', '-t', get_test_example_file('target-240p.jpg'), '-o', get_test_output_path('test-job-retry.jpg') ] commands = [sys.executable, 'facefusion.py', 'job-add-step', 'test-job-retry', '--workflow-mode', 'image-to-image', '--jobs-path', get_test_jobs_directory(), '--processors', 'face_debugger', '-t', get_test_example_file('target-240p.jpg'), '-o', get_test_output_path('test-job-retry.jpg') ]
subprocess.run(commands) subprocess.run(commands)
commands = [ sys.executable, 'facefusion.py', 'job-retry', 'test-job-retry', '--jobs-path', get_test_jobs_directory() ] commands = [ sys.executable, 'facefusion.py', 'job-retry', 'test-job-retry', '--jobs-path', get_test_jobs_directory() ]
@@ -122,13 +133,13 @@ def test_job_retry_all() -> None:
commands = [ sys.executable, 'facefusion.py', 'job-create', 'test-job-retry-all-2', '--jobs-path', get_test_jobs_directory() ] commands = [ sys.executable, 'facefusion.py', 'job-create', 'test-job-retry-all-2', '--jobs-path', get_test_jobs_directory() ]
subprocess.run(commands) subprocess.run(commands)
commands = [ sys.executable, 'facefusion.py', 'job-add-step', 'test-job-retry-all-1', '--workflow', 'image-to-image', '--jobs-path', get_test_jobs_directory(), '--processors', 'face_debugger', '-t', get_test_example_file('target-240p.jpg'), '-o', get_test_output_path('test-job-retry-all-1.jpg') ] commands = [ sys.executable, 'facefusion.py', 'job-add-step', 'test-job-retry-all-1', '--workflow-mode', 'image-to-image', '--jobs-path', get_test_jobs_directory(), '--processors', 'face_debugger', '-t', get_test_example_file('target-240p.jpg'), '-o', get_test_output_path('test-job-retry-all-1.jpg') ]
subprocess.run(commands) subprocess.run(commands)
commands = [ sys.executable, 'facefusion.py', 'job-add-step', 'test-job-retry-all-2', '--workflow', 'image-to-video', '--jobs-path', get_test_jobs_directory(), '--processors', 'face_debugger', '-t', get_test_example_file('target-240p.mp4'), '-o', get_test_output_path('test-job-retry-all-2.mp4'), '--trim-frame-end', '1' ] commands = [ sys.executable, 'facefusion.py', 'job-add-step', 'test-job-retry-all-2', '--workflow-mode', 'image-to-video', '--jobs-path', get_test_jobs_directory(), '--processors', 'face_debugger', '-t', get_test_example_file('target-240p.mp4'), '-o', get_test_output_path('test-job-retry-all-2.mp4'), '--trim-frame-end', '1' ]
subprocess.run(commands) subprocess.run(commands)
commands = [ sys.executable, 'facefusion.py', 'job-add-step', 'test-job-retry-all-2', '--workflow', 'image-to-video', '--jobs-path', get_test_jobs_directory(), '--processors', 'face_debugger', '-t', get_test_example_file('target-240p.mp4'), '-o', get_test_output_path('test-job-retry-all-2.mp4'), '--trim-frame-start', '0', '--trim-frame-end', '1' ] commands = [ sys.executable, 'facefusion.py', 'job-add-step', 'test-job-retry-all-2', '--workflow-mode', 'image-to-video', '--jobs-path', get_test_jobs_directory(), '--processors', 'face_debugger', '-t', get_test_example_file('target-240p.mp4'), '-o', get_test_output_path('test-job-retry-all-2.mp4'), '--trim-frame-start', '0', '--trim-frame-end', '1' ]
subprocess.run(commands) subprocess.run(commands)
commands = [ sys.executable, 'facefusion.py', 'job-retry-all', '--jobs-path', get_test_jobs_directory(), '--halt-on-error' ] commands = [ sys.executable, 'facefusion.py', 'job-retry-all', '--jobs-path', get_test_jobs_directory(), '--halt-on-error' ]
+16 -5
View File
@@ -3,6 +3,7 @@ import sys
import pytest import pytest
from facefusion import ffmpeg, ffmpeg_builder, process_manager
from facefusion.download import conditional_download from facefusion.download import conditional_download
from facefusion.jobs.job_manager import clear_jobs, init_jobs from facefusion.jobs.job_manager import clear_jobs, init_jobs
from .assert_helper import get_test_example_file, get_test_examples_directory, get_test_jobs_directory, get_test_output_path, is_test_output_file, is_test_output_sequence, prepare_test_output_directory from .assert_helper import get_test_example_file, get_test_examples_directory, get_test_jobs_directory, get_test_output_path, is_test_output_file, is_test_output_sequence, prepare_test_output_directory
@@ -10,6 +11,7 @@ from .assert_helper import get_test_example_file, get_test_examples_directory, g
@pytest.fixture(scope = 'module', autouse = True) @pytest.fixture(scope = 'module', autouse = True)
def before_all() -> None: def before_all() -> None:
process_manager.start()
conditional_download(get_test_examples_directory(), conditional_download(get_test_examples_directory(),
[ [
'https://github.com/facefusion/facefusion-assets/releases/download/examples-3.0.0/source.jpg', 'https://github.com/facefusion/facefusion-assets/releases/download/examples-3.0.0/source.jpg',
@@ -17,7 +19,16 @@ def before_all() -> None:
'https://github.com/facefusion/facefusion-assets/releases/download/examples-3.0.0/target-240p.mp4' 'https://github.com/facefusion/facefusion-assets/releases/download/examples-3.0.0/target-240p.mp4'
]) ])
subprocess.run([ 'ffmpeg', '-i', get_test_example_file('target-240p.mp4'), '-vframes', '1', get_test_example_file('target-240p.jpg') ]) ffmpeg.run_ffmpeg(
ffmpeg_builder.chain(
ffmpeg_builder.set_input(get_test_example_file('target-240p.mp4')),
[
'-vframes',
'1'
],
ffmpeg_builder.set_output(get_test_example_file('target-240p.jpg'))
)
)
@pytest.fixture(scope = 'function', autouse = True) @pytest.fixture(scope = 'function', autouse = True)
@@ -28,28 +39,28 @@ def before_each() -> None:
def test_sync_lip_to_image() -> None: def test_sync_lip_to_image() -> None:
commands = [ sys.executable, 'facefusion.py', 'run', '--workflow', 'audio-to-image:video', '--jobs-path', get_test_jobs_directory(), '--processors', 'lip_syncer', '-s', get_test_example_file('source.mp3'), '-t', get_test_example_file('target-240p.jpg'), '-o', get_test_output_path('test_sync_lip_to_image.mp4') ] commands = [ sys.executable, 'facefusion.py', 'run', '--workflow-mode', 'audio-to-image:video', '--jobs-path', get_test_jobs_directory(), '--processors', 'lip_syncer', '-s', get_test_example_file('source.mp3'), '-t', get_test_example_file('target-240p.jpg'), '-o', get_test_output_path('test_sync_lip_to_image.mp4') ]
assert subprocess.run(commands).returncode == 0 assert subprocess.run(commands).returncode == 0
assert is_test_output_file('test_sync_lip_to_image.mp4') is True assert is_test_output_file('test_sync_lip_to_image.mp4') is True
def test_sync_lip_to_image_as_frames() -> None: def test_sync_lip_to_image_as_frames() -> None:
commands = [ sys.executable, 'facefusion.py', 'run', '--workflow', 'audio-to-image:frames', '--jobs-path', get_test_jobs_directory(), '--processors', 'lip_syncer', '-s', get_test_example_file('source.mp3'), '-t', get_test_example_file('target-240p.jpg'), '-o', get_test_output_path('test_sync_lip_to_image_as_frames') ] commands = [ sys.executable, 'facefusion.py', 'run', '--workflow-mode', 'audio-to-image:frames', '--jobs-path', get_test_jobs_directory(), '--processors', 'lip_syncer', '-s', get_test_example_file('source.mp3'), '-t', get_test_example_file('target-240p.jpg'), '-o', get_test_output_path('test_sync_lip_to_image_as_frames') ]
assert subprocess.run(commands).returncode == 0 assert subprocess.run(commands).returncode == 0
assert is_test_output_sequence(get_test_output_path('test_sync_lip_to_image_as_frames')) is True assert is_test_output_sequence(get_test_output_path('test_sync_lip_to_image_as_frames')) is True
def test_sync_lip_to_video() -> None: def test_sync_lip_to_video() -> None:
commands = [ sys.executable, 'facefusion.py', 'run', '--workflow', 'image-to-video', '--jobs-path', get_test_jobs_directory(), '--processors', 'lip_syncer', '-s', get_test_example_file('source.mp3'), '-t', get_test_example_file('target-240p.mp4'), '-o', get_test_output_path('test_sync_lip_to_video.mp4'), '--trim-frame-end', '1' ] commands = [ sys.executable, 'facefusion.py', 'run', '--workflow-mode', 'image-to-video', '--jobs-path', get_test_jobs_directory(), '--processors', 'lip_syncer', '-s', get_test_example_file('source.mp3'), '-t', get_test_example_file('target-240p.mp4'), '-o', get_test_output_path('test_sync_lip_to_video.mp4'), '--trim-frame-end', '1' ]
assert subprocess.run(commands).returncode == 0 assert subprocess.run(commands).returncode == 0
assert is_test_output_file('test_sync_lip_to_video.mp4') is True assert is_test_output_file('test_sync_lip_to_video.mp4') is True
def test_sync_lip_to_video_as_frames() -> None: def test_sync_lip_to_video_as_frames() -> None:
commands = [ sys.executable, 'facefusion.py', 'run', '--workflow', 'image-to-video:frames', '--jobs-path', get_test_jobs_directory(), '--processors', 'lip_syncer', '-s', get_test_example_file('source.mp3'), '-t', get_test_example_file('target-240p.mp4'), '-o', get_test_output_path('test_sync_lip_to_video_as_frames'), '--trim-frame-end', '1' ] commands = [ sys.executable, 'facefusion.py', 'run', '--workflow-mode', 'image-to-video:frames', '--jobs-path', get_test_jobs_directory(), '--processors', 'lip_syncer', '-s', get_test_example_file('source.mp3'), '-t', get_test_example_file('target-240p.mp4'), '-o', get_test_output_path('test_sync_lip_to_video_as_frames'), '--trim-frame-end', '1' ]
assert subprocess.run(commands).returncode == 0 assert subprocess.run(commands).returncode == 0
assert is_test_output_sequence(get_test_output_path('test_sync_lip_to_video_as_frames')) is True assert is_test_output_sequence(get_test_output_path('test_sync_lip_to_video_as_frames')) is True
+14 -3
View File
@@ -3,6 +3,7 @@ import sys
import pytest import pytest
from facefusion import ffmpeg, ffmpeg_builder, process_manager
from facefusion.download import conditional_download from facefusion.download import conditional_download
from facefusion.jobs.job_manager import clear_jobs, init_jobs from facefusion.jobs.job_manager import clear_jobs, init_jobs
from facefusion.types import Resolution, Scale from facefusion.types import Resolution, Scale
@@ -12,13 +13,23 @@ from .assert_helper import get_test_example_file, get_test_examples_directory, g
@pytest.fixture(scope = 'module', autouse = True) @pytest.fixture(scope = 'module', autouse = True)
def before_all() -> None: def before_all() -> None:
process_manager.start()
conditional_download(get_test_examples_directory(), conditional_download(get_test_examples_directory(),
[ [
'https://github.com/facefusion/facefusion-assets/releases/download/examples-3.0.0/source.jpg', 'https://github.com/facefusion/facefusion-assets/releases/download/examples-3.0.0/source.jpg',
'https://github.com/facefusion/facefusion-assets/releases/download/examples-3.0.0/target-240p.mp4' 'https://github.com/facefusion/facefusion-assets/releases/download/examples-3.0.0/target-240p.mp4'
]) ])
subprocess.run([ 'ffmpeg', '-i', get_test_example_file('target-240p.mp4'), '-vframes', '1', get_test_example_file('target-240p.jpg') ]) ffmpeg.run_ffmpeg(
ffmpeg_builder.chain(
ffmpeg_builder.set_input(get_test_example_file('target-240p.mp4')),
[
'-vframes',
'1'
],
ffmpeg_builder.set_output(get_test_example_file('target-240p.jpg'))
)
)
@pytest.fixture(scope = 'function', autouse = True) @pytest.fixture(scope = 'function', autouse = True)
@@ -37,7 +48,7 @@ def before_each() -> None:
]) ])
def test_output_image_scale(output_image_scale : Scale, output_image_resolution : Resolution) -> None: def test_output_image_scale(output_image_scale : Scale, output_image_resolution : Resolution) -> None:
output_file_path = get_test_output_path('test-output-image-scale-' + str(output_image_scale) + '.jpg') output_file_path = get_test_output_path('test-output-image-scale-' + str(output_image_scale) + '.jpg')
commands = [ sys.executable, 'facefusion.py', 'run', '--workflow', 'image-to-image', '--jobs-path', get_test_jobs_directory(), '--processors', 'frame_enhancer', '-t', get_test_example_file('target-240p.jpg'), '-o', output_file_path, '--output-image-scale', str(output_image_scale) ] commands = [ sys.executable, 'facefusion.py', 'run', '--workflow-mode', 'image-to-image', '--jobs-path', get_test_jobs_directory(), '--processors', 'frame_enhancer', '-t', get_test_example_file('target-240p.jpg'), '-o', output_file_path, '--output-image-scale', str(output_image_scale) ]
assert subprocess.run(commands).returncode == 0 assert subprocess.run(commands).returncode == 0
assert detect_image_resolution(output_file_path) == output_image_resolution assert detect_image_resolution(output_file_path) == output_image_resolution
@@ -52,7 +63,7 @@ def test_output_image_scale(output_image_scale : Scale, output_image_resolution
]) ])
def test_output_video_scale(output_video_scale : Scale, output_video_resolution : Resolution) -> None: def test_output_video_scale(output_video_scale : Scale, output_video_resolution : Resolution) -> None:
output_file_path = get_test_output_path('test-output-video-scale-' + str(output_video_scale) + '.mp4') output_file_path = get_test_output_path('test-output-video-scale-' + str(output_video_scale) + '.mp4')
commands = [ sys.executable, 'facefusion.py', 'run', '--workflow', 'image-to-video', '--jobs-path', get_test_jobs_directory(), '--processors', 'frame_enhancer', '-t', get_test_example_file('target-240p.mp4'), '-o', output_file_path, '--trim-frame-end', '1', '--output-video-scale', str(output_video_scale) ] commands = [ sys.executable, 'facefusion.py', 'run', '--workflow-mode', 'image-to-video', '--jobs-path', get_test_jobs_directory(), '--processors', 'frame_enhancer', '-t', get_test_example_file('target-240p.mp4'), '-o', output_file_path, '--trim-frame-end', '1', '--output-video-scale', str(output_video_scale) ]
assert subprocess.run(commands).returncode == 0 assert subprocess.run(commands).returncode == 0
assert detect_video_resolution(output_file_path) == output_video_resolution assert detect_video_resolution(output_file_path) == output_video_resolution
+1 -1
View File
@@ -16,7 +16,7 @@ def test_create_int_range() -> None:
def test_create_float_range() -> None: def test_create_float_range() -> None:
assert create_float_range(0.0, 1.0, 0.5) == [ 0.0, 0.5, 1.0 ] assert create_float_range(0.0, 1.0, 0.5) == [ 0.0, 0.5, 1.0 ]
assert create_float_range(0.0, 1.0, 0.05) == [ 0.0, 0.05, 0.10, 0.15, 0.20, 0.25, 0.30, 0.35, 0.40, 0.45, 0.50, 0.55, 0.60, 0.65, 0.70, 0.75, 0.80, 0.85, 0.90, 0.95, 1.0 ] assert create_float_range(0.0, 0.5, 0.05) == [ 0.0, 0.05, 0.10, 0.15, 0.20, 0.25, 0.30, 0.35, 0.40, 0.45, 0.50 ]
def test_calc_int_step() -> None: def test_calc_int_step() -> None:
+14 -5
View File
@@ -1,9 +1,8 @@
import subprocess
import numpy import numpy
import pytest import pytest
from facefusion import face_classifier, face_detector, face_landmarker, face_recognizer, state_manager from facefusion import face_classifier, face_detector, face_landmarker, face_recognizer, ffmpeg, ffmpeg_builder, process_manager, state_manager
from facefusion.download import conditional_download from facefusion.download import conditional_download
from facefusion.face_creator import average_face_geometry, get_many_faces, get_one_face, refill_faces from facefusion.face_creator import average_face_geometry, get_many_faces, get_one_face, refill_faces
from facefusion.face_store import clear_faces from facefusion.face_store import clear_faces
@@ -13,13 +12,23 @@ from .assert_helper import get_test_example_file, get_test_examples_directory
@pytest.fixture(scope = 'module', autouse = True) @pytest.fixture(scope = 'module', autouse = True)
def before_all() -> None: def before_all() -> None:
process_manager.start()
conditional_download(get_test_examples_directory(), conditional_download(get_test_examples_directory(),
[ [
'https://github.com/facefusion/facefusion-assets/releases/download/examples-3.0.0/source.jpg' 'https://github.com/facefusion/facefusion-assets/releases/download/examples-3.0.0/source.jpg'
]) ])
subprocess.run([ 'ffmpeg', '-i', get_test_example_file('source.jpg'), '-vf', 'crop=iw*0.8:ih*0.8', get_test_example_file('source-80crop.jpg') ])
subprocess.run([ 'ffmpeg', '-i', get_test_example_file('source.jpg'), '-vf', 'crop=iw*0.7:ih*0.7', get_test_example_file('source-70crop.jpg') ]) for crop_scale in [ 80, 70, 60 ]:
subprocess.run([ 'ffmpeg', '-i', get_test_example_file('source.jpg'), '-vf', 'crop=iw*0.6:ih*0.6', get_test_example_file('source-60crop.jpg') ]) ffmpeg.run_ffmpeg(
ffmpeg_builder.chain(
ffmpeg_builder.set_input(get_test_example_file('source.jpg')),
[
'-vf',
'crop=iw*0.' + str(crop_scale) + ':ih*0.' + str(crop_scale)
],
ffmpeg_builder.set_output(get_test_example_file('source-' + str(crop_scale) + 'crop.jpg'))
)
)
state_manager.init_item('execution_device_ids', [ 0 ]) state_manager.init_item('execution_device_ids', [ 0 ])
state_manager.init_item('execution_providers', [ 'cpu' ]) state_manager.init_item('execution_providers', [ 'cpu' ])
+25 -8
View File
@@ -1,8 +1,7 @@
import subprocess
import pytest import pytest
from facefusion import face_detector, state_manager from facefusion import face_detector, ffmpeg, ffmpeg_builder, process_manager, state_manager
from facefusion.download import conditional_download from facefusion.download import conditional_download
from facefusion.face_detector import detect_with_retinaface, detect_with_scrfd, detect_with_yolo_face, detect_with_yunet from facefusion.face_detector import detect_with_retinaface, detect_with_scrfd, detect_with_yolo_face, detect_with_yunet
from facefusion.face_helper import apply_nms, get_nms_threshold from facefusion.face_helper import apply_nms, get_nms_threshold
@@ -12,13 +11,23 @@ from .assert_helper import get_test_example_file, get_test_examples_directory
@pytest.fixture(scope = 'module', autouse = True) @pytest.fixture(scope = 'module', autouse = True)
def before_all() -> None: def before_all() -> None:
process_manager.start()
conditional_download(get_test_examples_directory(), conditional_download(get_test_examples_directory(),
[ [
'https://github.com/facefusion/facefusion-assets/releases/download/examples-3.0.0/source.jpg' 'https://github.com/facefusion/facefusion-assets/releases/download/examples-3.0.0/source.jpg'
]) ])
subprocess.run([ 'ffmpeg', '-i', get_test_example_file('source.jpg'), '-vf', 'crop=iw*0.8:ih*0.8', get_test_example_file('source-80crop.jpg') ])
subprocess.run([ 'ffmpeg', '-i', get_test_example_file('source.jpg'), '-vf', 'crop=iw*0.7:ih*0.7', get_test_example_file('source-70crop.jpg') ]) for crop_scale in [ 80, 70, 60 ]:
subprocess.run([ 'ffmpeg', '-i', get_test_example_file('source.jpg'), '-vf', 'crop=iw*0.6:ih*0.6', get_test_example_file('source-60crop.jpg') ]) ffmpeg.run_ffmpeg(
ffmpeg_builder.chain(
ffmpeg_builder.set_input(get_test_example_file('source.jpg')),
[
'-vf',
'crop=iw*0.' + str(crop_scale) + ':ih*0.' + str(crop_scale)
],
ffmpeg_builder.set_output(get_test_example_file('source-' + str(crop_scale) + 'crop.jpg'))
)
)
state_manager.init_item('execution_device_ids', [ 0 ]) state_manager.init_item('execution_device_ids', [ 0 ])
state_manager.init_item('execution_providers', [ 'cpu' ]) state_manager.init_item('execution_providers', [ 'cpu' ])
@@ -34,9 +43,17 @@ def before_all() -> None:
'https://github.com/facefusion/facefusion-assets/releases/download/examples-3.0.0/source.jpg' 'https://github.com/facefusion/facefusion-assets/releases/download/examples-3.0.0/source.jpg'
]) ])
subprocess.run([ 'ffmpeg', '-i', get_test_example_file('source.jpg'), '-vf', 'crop=iw*0.8:ih*0.8', get_test_example_file('source-80crop.jpg') ]) for crop_scale in [ 80, 70, 60 ]:
subprocess.run([ 'ffmpeg', '-i', get_test_example_file('source.jpg'), '-vf', 'crop=iw*0.7:ih*0.7', get_test_example_file('source-70crop.jpg') ]) ffmpeg.run_ffmpeg(
subprocess.run([ 'ffmpeg', '-i', get_test_example_file('source.jpg'), '-vf', 'crop=iw*0.6:ih*0.6', get_test_example_file('source-60crop.jpg') ]) ffmpeg_builder.chain(
ffmpeg_builder.set_input(get_test_example_file('source.jpg')),
[
'-vf',
'crop=iw*0.' + str(crop_scale) + ':ih*0.' + str(crop_scale)
],
ffmpeg_builder.set_output(get_test_example_file('source-' + str(crop_scale) + 'crop.jpg'))
)
)
@pytest.fixture(autouse = True) @pytest.fixture(autouse = True)
+36 -9
View File
@@ -1,11 +1,10 @@
import os import os
import subprocess
import tempfile import tempfile
import pytest import pytest
import facefusion.ffmpeg import facefusion.ffmpeg
from facefusion import process_manager, state_manager from facefusion import ffmpeg, ffmpeg_builder, process_manager, state_manager
from facefusion.download import conditional_download from facefusion.download import conditional_download
from facefusion.ffmpeg import concat_video, extract_frames, merge_video, read_audio_buffer, replace_audio, restore_audio, sanitize_audio, sanitize_image, sanitize_video, spawn_frames from facefusion.ffmpeg import concat_video, extract_frames, merge_video, read_audio_buffer, replace_audio, restore_audio, sanitize_audio, sanitize_image, sanitize_video, spawn_frames
from facefusion.ffprobe import probe_entries from facefusion.ffprobe import probe_entries
@@ -34,16 +33,44 @@ def before_all() -> None:
'https://github.com/facefusion/facefusion-assets/releases/download/examples-3.0.0/target-240p.mp4' 'https://github.com/facefusion/facefusion-assets/releases/download/examples-3.0.0/target-240p.mp4'
]) ])
subprocess.run([ 'ffmpeg', '-i', get_test_example_file('source.mp3'), get_test_example_file('source.wav') ]) for video_fps in [ 25, 30, 60 ]:
subprocess.run([ 'ffmpeg', '-i', get_test_example_file('target-240p.mp4'), '-vf', 'fps=25', get_test_example_file('target-240p-25fps.mp4') ]) ffmpeg.run_ffmpeg(
subprocess.run([ 'ffmpeg', '-i', get_test_example_file('target-240p.mp4'), '-vf', 'fps=30', get_test_example_file('target-240p-30fps.mp4') ]) ffmpeg_builder.chain(
subprocess.run([ 'ffmpeg', '-i', get_test_example_file('target-240p.mp4'), '-vf', 'fps=60', get_test_example_file('target-240p-60fps.mp4') ]) ffmpeg_builder.set_input(get_test_example_file('target-240p.mp4')),
ffmpeg_builder.set_video_fps(video_fps),
ffmpeg_builder.set_output(get_test_example_file('target-240p-' + str(video_fps) + 'fps.mp4'))
)
)
for output_video_format in [ 'avi', 'm4v', 'mkv', 'mov', 'mp4', 'webm', 'wmv' ]: for output_video_format in [ 'avi', 'm4v', 'mkv', 'mov', 'mp4', 'webm', 'wmv' ]:
subprocess.run([ 'ffmpeg', '-i', get_test_example_file('source.mp3'), '-i', get_test_example_file('target-240p.mp4'), '-ar', '16000', get_test_example_file('target-240p-16khz.' + output_video_format) ]) ffmpeg.run_ffmpeg(
ffmpeg_builder.chain(
ffmpeg_builder.set_input(get_test_example_file('source.mp3')),
ffmpeg_builder.set_input(get_test_example_file('target-240p.mp4')),
ffmpeg_builder.set_audio_sample_rate(16000),
ffmpeg_builder.set_output(get_test_example_file('target-240p-16khz.' + output_video_format))
)
)
subprocess.run([ 'ffmpeg', '-i', get_test_example_file('source.mp3'), '-i', get_test_example_file('target-240p.mp4'), '-ar', '48000', get_test_example_file('target-240p-48khz.mp4') ]) ffmpeg.run_ffmpeg(
subprocess.run([ 'ffmpeg', '-i', get_test_example_file('target-240p.mp4'), '-c:v', 'libx265', '-an', '-movflags', '+faststart', get_test_example_file('target-240p-h265.mp4') ]) ffmpeg_builder.chain(
ffmpeg_builder.set_input(get_test_example_file('source.mp3')),
ffmpeg_builder.set_input(get_test_example_file('target-240p.mp4')),
ffmpeg_builder.set_audio_sample_rate(48000),
ffmpeg_builder.set_output(get_test_example_file('target-240p-48khz.mp4'))
)
)
ffmpeg.run_ffmpeg(
ffmpeg_builder.chain(
ffmpeg_builder.set_input(get_test_example_file('target-240p.mp4')),
ffmpeg_builder.set_video_encoder('libx265'),
[
'-an'
],
ffmpeg_builder.set_faststart('mp4'),
ffmpeg_builder.set_output(get_test_example_file('target-240p-h265.mp4'))
)
)
@pytest.fixture(scope = 'function', autouse = True) @pytest.fixture(scope = 'function', autouse = True)
+17 -4
View File
@@ -1,8 +1,7 @@
import subprocess
import pytest import pytest
from facefusion import process_manager from facefusion import ffmpeg, ffmpeg_builder, process_manager
from facefusion.download import conditional_download from facefusion.download import conditional_download
from facefusion.ffprobe import extract_audio_metadata, extract_video_metadata from facefusion.ffprobe import extract_audio_metadata, extract_video_metadata
from .assert_helper import get_test_example_file, get_test_examples_directory from .assert_helper import get_test_example_file, get_test_examples_directory
@@ -18,8 +17,22 @@ def before_all() -> None:
'https://github.com/facefusion/facefusion-assets/releases/download/examples-3.0.0/target-240p.mp4' 'https://github.com/facefusion/facefusion-assets/releases/download/examples-3.0.0/target-240p.mp4'
]) ])
subprocess.run([ 'ffmpeg', '-i', get_test_example_file('source.mp3'), '-t', '1.9', '-ar', '48000', '-ac', '2', get_test_example_file('source-48000khz-2ch.wav') ]) ffmpeg.run_ffmpeg(
subprocess.run([ 'ffmpeg', '-i', get_test_example_file('target-240p.mp4'), '-t', '1', get_test_example_file('target-240p-1s.mov') ]) ffmpeg_builder.chain(
ffmpeg_builder.set_input(get_test_example_file('source.mp3')),
ffmpeg_builder.set_video_duration(1.9),
ffmpeg_builder.set_audio_sample_rate(48000),
ffmpeg_builder.set_audio_channel_total(2),
ffmpeg_builder.set_output(get_test_example_file('source-48000khz-2ch.wav'))
)
)
ffmpeg.run_ffmpeg(
ffmpeg_builder.chain(
ffmpeg_builder.set_input(get_test_example_file('target-240p.mp4')),
ffmpeg_builder.set_video_duration(1),
ffmpeg_builder.set_output(get_test_example_file('target-240p-1s.mov'))
)
)
def test_extract_audio_metadata() -> None: def test_extract_audio_metadata() -> None:
+3 -7
View File
@@ -1,7 +1,7 @@
from shutil import which from shutil import which
from facefusion import ffprobe_builder from facefusion import ffprobe_builder
from facefusion.ffprobe_builder import chain, format_to_key_value, format_to_value, run, set_input, show_entries from facefusion.ffprobe_builder import chain, format_to_key_value, run, set_input, show_entries
def test_run() -> None: def test_run() -> None:
@@ -11,9 +11,9 @@ def test_run() -> None:
def test_chain() -> None: def test_chain() -> None:
assert chain( assert chain(
ffprobe_builder.show_entries([ 'sample_rate' ]), ffprobe_builder.show_entries([ 'sample_rate' ]),
ffprobe_builder.format_to_value(), ffprobe_builder.format_to_key_value(),
ffprobe_builder.set_input('audio.mp3') ffprobe_builder.set_input('audio.mp3')
) == [ '-show_entries', 'stream=sample_rate', '-of', 'default=noprint_wrappers=1:nokey=1', '-i', 'audio.mp3' ] ) == [ '-show_entries', 'stream=sample_rate', '-of', 'default=noprint_wrappers=1', '-i', 'audio.mp3' ]
def test_show_entries() -> None: def test_show_entries() -> None:
@@ -21,10 +21,6 @@ def test_show_entries() -> None:
assert show_entries([ 'duration', 'sample_rate']) == [ '-show_entries', 'stream=duration,sample_rate' ] assert show_entries([ 'duration', 'sample_rate']) == [ '-show_entries', 'stream=duration,sample_rate' ]
def test_format_to_value() -> None:
assert format_to_value() == [ '-of', 'default=noprint_wrappers=1:nokey=1' ]
def test_format_to_key_value() -> None: def test_format_to_key_value() -> None:
assert format_to_key_value() == [ '-of', 'default=noprint_wrappers=1' ] assert format_to_key_value() == [ '-of', 'default=noprint_wrappers=1' ]
+12 -2
View File
@@ -1,8 +1,8 @@
import os import os
import subprocess
import pytest import pytest
from facefusion import ffmpeg, ffmpeg_builder, process_manager
from facefusion.download import conditional_download from facefusion.download import conditional_download
from facefusion.filesystem import copy_file, create_directory, get_file_extension from facefusion.filesystem import copy_file, create_directory, get_file_extension
from facefusion.jobs.job_manager import add_step, clear_jobs, create_job, init_jobs, move_job_file, submit_job, submit_jobs from facefusion.jobs.job_manager import add_step, clear_jobs, create_job, init_jobs, move_job_file, submit_job, submit_jobs
@@ -13,13 +13,23 @@ from .assert_helper import get_test_example_file, get_test_examples_directory, g
@pytest.fixture(scope = 'module', autouse = True) @pytest.fixture(scope = 'module', autouse = True)
def before_all() -> None: def before_all() -> None:
process_manager.start()
conditional_download(get_test_examples_directory(), conditional_download(get_test_examples_directory(),
[ [
'https://github.com/facefusion/facefusion-assets/releases/download/examples-3.0.0/source.jpg', 'https://github.com/facefusion/facefusion-assets/releases/download/examples-3.0.0/source.jpg',
'https://github.com/facefusion/facefusion-assets/releases/download/examples-3.0.0/target-240p.mp4' 'https://github.com/facefusion/facefusion-assets/releases/download/examples-3.0.0/target-240p.mp4'
]) ])
subprocess.run([ 'ffmpeg', '-i', get_test_example_file('target-240p.mp4'), '-vframes', '1', get_test_example_file('target-240p.jpg') ]) ffmpeg.run_ffmpeg(
ffmpeg_builder.chain(
ffmpeg_builder.set_input(get_test_example_file('target-240p.mp4')),
[
'-vframes',
'1'
],
ffmpeg_builder.set_output(get_test_example_file('target-240p.jpg'))
)
)
@pytest.fixture(scope = 'function', autouse = True) @pytest.fixture(scope = 'function', autouse = True)
+76 -12
View File
@@ -1,8 +1,8 @@
import subprocess
import numpy import numpy
import pytest import pytest
from facefusion import ffmpeg, ffmpeg_builder, process_manager
from facefusion.download import conditional_download from facefusion.download import conditional_download
from facefusion.vision import calculate_histogram_difference, count_video_frame_total, detect_image_resolution, detect_video_duration, detect_video_fps, detect_video_resolution, match_frame_color, normalize_resolution, pack_resolution, predict_video_frame_total, read_image, read_video_chunk, read_video_frame, restrict_image_resolution, restrict_trim_video_frame, restrict_video_fps, restrict_video_resolution, scale_resolution, select_video_frames, unpack_resolution, write_image from facefusion.vision import calculate_histogram_difference, count_video_frame_total, detect_image_resolution, detect_video_duration, detect_video_fps, detect_video_resolution, match_frame_color, normalize_resolution, pack_resolution, predict_video_frame_total, read_image, read_video_chunk, read_video_frame, restrict_image_resolution, restrict_trim_video_frame, restrict_video_fps, restrict_video_resolution, scale_resolution, select_video_frames, unpack_resolution, write_image
from .assert_helper import get_test_example_file, get_test_examples_directory, get_test_output_path, prepare_test_output_directory from .assert_helper import get_test_example_file, get_test_examples_directory, get_test_output_path, prepare_test_output_directory
@@ -10,6 +10,7 @@ from .assert_helper import get_test_example_file, get_test_examples_directory, g
@pytest.fixture(scope = 'module', autouse = True) @pytest.fixture(scope = 'module', autouse = True)
def before_all() -> None: def before_all() -> None:
process_manager.start()
conditional_download(get_test_examples_directory(), conditional_download(get_test_examples_directory(),
[ [
'https://github.com/facefusion/facefusion-assets/releases/download/examples-3.0.0/source.jpg', 'https://github.com/facefusion/facefusion-assets/releases/download/examples-3.0.0/source.jpg',
@@ -17,17 +18,80 @@ def before_all() -> None:
'https://github.com/facefusion/facefusion-assets/releases/download/examples-3.0.0/target-1080p.mp4' 'https://github.com/facefusion/facefusion-assets/releases/download/examples-3.0.0/target-1080p.mp4'
]) ])
subprocess.run([ 'ffmpeg', '-i', get_test_example_file('target-240p.mp4'), '-vframes', '1', get_test_example_file('target-240p.jpg') ]) for target_name in [ 'target-240p', 'target-1080p' ]:
subprocess.run([ 'ffmpeg', '-i', get_test_example_file('target-240p.mp4'), '-vframes', '1', get_test_example_file('目标-240p.webp') ]) ffmpeg.run_ffmpeg(
subprocess.run([ 'ffmpeg', '-i', get_test_example_file('target-1080p.mp4'), '-vframes', '1', get_test_example_file('target-1080p.jpg') ]) ffmpeg_builder.chain(
subprocess.run([ 'ffmpeg', '-i', get_test_example_file('target-240p.mp4'), '-vframes', '1', '-vf', 'hue=s=0', get_test_example_file('target-240p-0sat.jpg') ]) ffmpeg_builder.set_input(get_test_example_file(target_name + '.mp4')),
subprocess.run([ 'ffmpeg', '-i', get_test_example_file('target-240p.mp4'), '-vframes', '1', '-vf', 'transpose=0', get_test_example_file('target-240p-90deg.jpg') ]) [
subprocess.run([ 'ffmpeg', '-i', get_test_example_file('target-1080p.mp4'), '-vframes', '1', '-vf', 'transpose=0', get_test_example_file('target-1080p-90deg.jpg') ]) '-vframes',
subprocess.run([ 'ffmpeg', '-i', get_test_example_file('target-240p.mp4'), '-vf', 'fps=25', get_test_example_file('target-240p-25fps.mp4') ]) '1'
subprocess.run([ 'ffmpeg', '-i', get_test_example_file('target-240p.mp4'), '-vf', 'fps=30', get_test_example_file('target-240p-30fps.mp4') ]) ],
subprocess.run([ 'ffmpeg', '-i', get_test_example_file('target-240p.mp4'), '-vf', 'fps=60', get_test_example_file('target-240p-60fps.mp4') ]) ffmpeg_builder.set_output(get_test_example_file(target_name + '.jpg'))
subprocess.run([ 'ffmpeg', '-i', get_test_example_file('target-240p.mp4'), '-vf', 'transpose=0', get_test_example_file('target-240p-90deg.mp4') ]) )
subprocess.run([ 'ffmpeg', '-i', get_test_example_file('target-1080p.mp4'), '-vf', 'transpose=0', get_test_example_file('target-1080p-90deg.mp4') ]) )
ffmpeg.run_ffmpeg(
ffmpeg_builder.chain(
ffmpeg_builder.set_input(get_test_example_file('target-240p.mp4')),
[
'-vframes',
'1'
],
ffmpeg_builder.set_output(get_test_example_file('目标-240p.webp'))
)
)
ffmpeg.run_ffmpeg(
ffmpeg_builder.chain(
ffmpeg_builder.set_input(get_test_example_file('target-240p.mp4')),
[
'-vframes',
'1'
],
[
'-vf',
'hue=s=0'
],
ffmpeg_builder.set_output(get_test_example_file('target-240p-0sat.jpg'))
)
)
for target_name in [ 'target-240p', 'target-1080p' ]:
ffmpeg.run_ffmpeg(
ffmpeg_builder.chain(
ffmpeg_builder.set_input(get_test_example_file(target_name + '.mp4')),
[
'-vframes',
'1'
],
[
'-vf',
'transpose=0'
],
ffmpeg_builder.set_output(get_test_example_file(target_name + '-90deg.jpg'))
)
)
for video_fps in [ 25, 30, 60 ]:
ffmpeg.run_ffmpeg(
ffmpeg_builder.chain(
ffmpeg_builder.set_input(get_test_example_file('target-240p.mp4')),
ffmpeg_builder.set_video_fps(video_fps),
ffmpeg_builder.set_output(get_test_example_file('target-240p-' + str(video_fps) + 'fps.mp4'))
)
)
for target_name in [ 'target-240p', 'target-1080p' ]:
ffmpeg.run_ffmpeg(
ffmpeg_builder.chain(
ffmpeg_builder.set_input(get_test_example_file(target_name + '.mp4')),
[
'-vf',
'transpose=0'
],
ffmpeg_builder.set_output(get_test_example_file(target_name + '-90deg.mp4'))
)
)
@pytest.fixture(scope = 'function', autouse = True) @pytest.fixture(scope = 'function', autouse = True)