mirror of
https://github.com/facefusion/facefusion.git
synced 2026-07-31 22:37:24 +02:00
* mark as next * unify the dependency checks in pre_check and add ffprobe (#1181) * drop keep_temp and the common options component (#1180) Claude-Session: https://claude.ai/code/session_01Tbcd6VWCiU4BQP1gywPr2a Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com> * introduce ffprobe and ffprobe_builder (#1182) * introduce ffprobe and ffprobe_builder Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Tbcd6VWCiU4BQP1gywPr2a * introduce ffprobe and ffprobe_builder Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Tbcd6VWCiU4BQP1gywPr2a --------- Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com> * probe video metadata via ffprobe in vision (#1184) * probe video metadata via ffprobe in vision Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Tbcd6VWCiU4BQP1gywPr2a * probe video metadata via ffprobe in vision Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Tbcd6VWCiU4BQP1gywPr2a --------- Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com> * adopt the workflow task vocabulary from next major (#1185) Claude-Session: https://claude.ai/code/session_01Tbcd6VWCiU4BQP1gywPr2a Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com> * introduce workflow-mode and workflow-strategy like next major (#1187) Claude-Session: https://claude.ai/code/session_01Tbcd6VWCiU4BQP1gywPr2a Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com> * restrict hdr color transfer and tag the merge output as bt709 (#1188) * restrict hdr color transfer and tag the merge output as bt709 Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Tbcd6VWCiU4BQP1gywPr2a * restrict hdr color transfer and tag the merge output as bt709 Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Tbcd6VWCiU4BQP1gywPr2a * full video migration * compose the hdr fixture via the builder chain Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Tbcd6VWCiU4BQP1gywPr2a * compose the test fixtures via the builder and run_ffmpeg Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Tbcd6VWCiU4BQP1gywPr2a --------- Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com> * compose every test fixture via the builder and run_ffmpeg (#1189) * compose every test fixture via the builder and run_ffmpeg Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Tbcd6VWCiU4BQP1gywPr2a * use loops in tests for ffmpeg stuff --------- Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com> * New Video Manager (#1191) * tiny adjustment for tests * address the review on the video manager Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Tbcd6VWCiU4BQP1gywPr2a * introduce the stream strategy for the video workflow (#1192) * introduce the stream strategy for the video workflow Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Tbcd6VWCiU4BQP1gywPr2a * address the review on the stream strategy Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Tbcd6VWCiU4BQP1gywPr2a --------- Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com> * annotate the changes for review Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Tbcd6VWCiU4BQP1gywPr2a * annotate the new tests for review Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Tbcd6VWCiU4BQP1gywPr2a * match the temp pixel format help to the locale style Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Tbcd6VWCiU4BQP1gywPr2a * question the set_input_seek naming Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Tbcd6VWCiU4BQP1gywPr2a * question the reader and writer keys Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Tbcd6VWCiU4BQP1gywPr2a * drop the review annotations from the encoder mapping tests Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Tbcd6VWCiU4BQP1gywPr2a * drop the review annotations from the thread count tests Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Tbcd6VWCiU4BQP1gywPr2a * drop the review annotations from the ui files Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Tbcd6VWCiU4BQP1gywPr2a * capture the open review questions as annotations Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Tbcd6VWCiU4BQP1gywPr2a * drop the settled annotations from the types Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Tbcd6VWCiU4BQP1gywPr2a --------- Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com> * switch to ffmpeg.style for audio.py * remove todos that were never needed * fix for ffmpeg7 * Add frame_store module (#1194) * add frame_store module * rename and change tests * rename and update tests * route window read through frame_store (#1196) * route window read through frame_store * update proper id * restore todos * restore todos * go v4 style for workflow (#1197) * go v4 style for workflow * remove some todos * route chunk read through frame_store (#1198) * vision integration * Deleted read_video_chunk + read_static_video_chunk * margin decouple (#1199) * fix windows CI fail (#1200) * Cleanup Part1 (#1201) * remove some todos, improve video manager, simplify ffmpeg commands and more * do more * remove thread count for filters * Cleanup Part 2 (#1202) * tons of renaming * tons of renaming * multi reader approach * bring tests to an okay-ish state * bring drain back * improve read_video_frame speed * rename method * move variables * seek video reader only when trim frame start is larger 0 * make stream the default * Cleanup/part 3 (#1203) * remove todo * sort out workflow, to match upcoming v4 * remove look ahead * remove core namespace again * Revamp execution provider overrides/adjustments (#1206) * Split provider hooks into override/adjust with cached CoreML base Replace the single resolve_inference_providers processor hook with two: override_inference_providers (full replacement) and adjust_inference_providers (merge options onto the base providers built by create_inference_providers). This lets CoreML processors inherit ModelCacheDirectory + SpecializationStrategy from the base while layering ModelFormat/MLComputeUnits on top. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01HTQCZiYjJyUX11bDpbRSiB * fix caching for execution provider by having override and adjust ways * fix caching for execution provider by having override and adjust ways * fix lint * use proper pytest fixtures --------- Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com> * fix update preview bug (#1205) * fix update preview bug * fix update preview bug * remove guard * add is_vision_frame * Restrict the preview frame slider and the reader seek to the last frame index (#1207) * fix index bug * fix rounding bug * avoid tobytes copy (#1208) * beautify tests * hide ffmpeg warnings * simplify process_stream_frame * Use is vision frame everywhere (#1210) * use is_vision_frame everywhere * fix hash * fix lint * fix hash creation in face store * that model does not exist * update workflow ffmpeg * guard workflow (#1211) * bump version and dependencies * Update preview * switch workflow strategy to disk|memory * update preview * update preview * fix wording * last minute change workflow position * adjust wording --------- Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com> Co-authored-by: Harisreedhar <46858047+harisreedhar@users.noreply.github.com> Co-authored-by: harisreedhar <h4harisreedhar.s.s@gmail.com>
288 lines
8.7 KiB
Python
288 lines
8.7 KiB
Python
|
|
import pytest
|
|
|
|
from facefusion import ffmpeg, ffmpeg_builder, process_manager
|
|
from facefusion.download import conditional_download
|
|
from facefusion.filesystem import copy_file
|
|
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_runner import collect_output_set, finalize_steps, retry_job, retry_jobs, run_job, run_jobs, run_steps
|
|
from facefusion.types import Args
|
|
from .helper import get_test_example_file, get_test_examples_directory, get_test_jobs_directory, get_test_output_file, is_test_output_file, prepare_test_output_directory
|
|
|
|
|
|
@pytest.fixture(scope = 'module', autouse = True)
|
|
def before_all() -> None:
|
|
process_manager.start()
|
|
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/target-240p.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('target-240p.jpg'))
|
|
)
|
|
)
|
|
|
|
|
|
@pytest.fixture(scope = 'function', autouse = True)
|
|
def before_each() -> None:
|
|
clear_jobs(get_test_jobs_directory())
|
|
init_jobs(get_test_jobs_directory())
|
|
prepare_test_output_directory()
|
|
|
|
|
|
def process_step(job_id : str, step_index : int, step_args : Args) -> bool:
|
|
return copy_file(step_args.get('target_path'), step_args.get('output_path'))
|
|
|
|
|
|
def test_run_job() -> None:
|
|
args_1 =\
|
|
{
|
|
'source_path': get_test_example_file('source.jpg'),
|
|
'target_path': get_test_example_file('target-240p.mp4'),
|
|
'output_path': get_test_output_file('output-1.mp4')
|
|
}
|
|
args_2 =\
|
|
{
|
|
'source_path': get_test_example_file('source.jpg'),
|
|
'target_path': get_test_example_file('target-240p.mp4'),
|
|
'output_path': get_test_output_file('output-2.mp4')
|
|
}
|
|
args_3 =\
|
|
{
|
|
'source_path': get_test_example_file('source.jpg'),
|
|
'target_path': get_test_example_file('target-240p.jpg'),
|
|
'output_path': get_test_output_file('output-3.jpg')
|
|
}
|
|
|
|
assert run_job('job-invalid', process_step) is False
|
|
|
|
create_job('job-test-run-job')
|
|
add_step('job-test-run-job', args_1)
|
|
add_step('job-test-run-job', args_2)
|
|
add_step('job-test-run-job', args_2)
|
|
add_step('job-test-run-job', args_3)
|
|
|
|
assert run_job('job-test-run-job', process_step) is False
|
|
|
|
submit_job('job-test-run-job')
|
|
|
|
assert run_job('job-test-run-job', process_step) is True
|
|
|
|
|
|
def test_run_jobs() -> None:
|
|
args_1 =\
|
|
{
|
|
'source_path': get_test_example_file('source.jpg'),
|
|
'target_path': get_test_example_file('target-240p.mp4'),
|
|
'output_path': get_test_output_file('output-1.mp4')
|
|
}
|
|
args_2 =\
|
|
{
|
|
'source_path': get_test_example_file('source.jpg'),
|
|
'target_path': get_test_example_file('target-240p.mp4'),
|
|
'output_path': get_test_output_file('output-2.mp4')
|
|
}
|
|
args_3 =\
|
|
{
|
|
'source_path': get_test_example_file('source.jpg'),
|
|
'target_path': get_test_example_file('target-240p.jpg'),
|
|
'output_path': get_test_output_file('output-3.jpg')
|
|
}
|
|
halt_on_error = True
|
|
|
|
assert run_jobs(process_step, halt_on_error) is False
|
|
|
|
create_job('job-test-run-jobs-1')
|
|
create_job('job-test-run-jobs-2')
|
|
add_step('job-test-run-jobs-1', args_1)
|
|
add_step('job-test-run-jobs-1', args_1)
|
|
add_step('job-test-run-jobs-2', args_2)
|
|
add_step('job-test-run-jobs-3', args_3)
|
|
|
|
assert run_jobs(process_step, halt_on_error) is False
|
|
|
|
submit_jobs(halt_on_error)
|
|
|
|
assert run_jobs(process_step, halt_on_error) is True
|
|
|
|
|
|
def test_retry_job() -> None:
|
|
args_1 =\
|
|
{
|
|
'source_path': get_test_example_file('source.jpg'),
|
|
'target_path': get_test_example_file('target-240p.mp4'),
|
|
'output_path': get_test_output_file('output-1.mp4')
|
|
}
|
|
|
|
assert retry_job('job-invalid', process_step) is False
|
|
|
|
create_job('job-test-retry-job')
|
|
add_step('job-test-retry-job', args_1)
|
|
submit_job('job-test-retry-job')
|
|
|
|
assert retry_job('job-test-retry-job', process_step) is False
|
|
|
|
move_job_file('job-test-retry-job', 'failed')
|
|
|
|
assert retry_job('job-test-retry-job', process_step) is True
|
|
|
|
|
|
def test_retry_jobs() -> None:
|
|
args_1 =\
|
|
{
|
|
'source_path': get_test_example_file('source.jpg'),
|
|
'target_path': get_test_example_file('target-240p.mp4'),
|
|
'output_path': get_test_output_file('output-1.mp4')
|
|
}
|
|
args_2 =\
|
|
{
|
|
'source_path': get_test_example_file('source.jpg'),
|
|
'target_path': get_test_example_file('target-240p.mp4'),
|
|
'output_path': get_test_output_file('output-2.mp4')
|
|
}
|
|
args_3 =\
|
|
{
|
|
'source_path': get_test_example_file('source.jpg'),
|
|
'target_path': get_test_example_file('target-240p.jpg'),
|
|
'output_path': get_test_output_file('output-3.jpg')
|
|
}
|
|
halt_on_error = True
|
|
|
|
assert retry_jobs(process_step, halt_on_error) is False
|
|
|
|
create_job('job-test-retry-jobs-1')
|
|
create_job('job-test-retry-jobs-2')
|
|
add_step('job-test-retry-jobs-1', args_1)
|
|
add_step('job-test-retry-jobs-1', args_1)
|
|
add_step('job-test-retry-jobs-2', args_2)
|
|
add_step('job-test-retry-jobs-3', args_3)
|
|
|
|
assert retry_jobs(process_step, halt_on_error) is False
|
|
|
|
move_job_file('job-test-retry-jobs-1', 'failed')
|
|
move_job_file('job-test-retry-jobs-2', 'failed')
|
|
|
|
assert retry_jobs(process_step, halt_on_error) is True
|
|
|
|
|
|
def test_run_steps() -> None:
|
|
args_1 =\
|
|
{
|
|
'source_path': get_test_example_file('source.jpg'),
|
|
'target_path': get_test_example_file('target-240p.mp4'),
|
|
'output_path': get_test_output_file('output-1.mp4')
|
|
}
|
|
args_2 =\
|
|
{
|
|
'source_path': get_test_example_file('source.jpg'),
|
|
'target_path': get_test_example_file('target-240p.mp4'),
|
|
'output_path': get_test_output_file('output-2.mp4')
|
|
}
|
|
args_3 =\
|
|
{
|
|
'source_path': get_test_example_file('source.jpg'),
|
|
'target_path': get_test_example_file('target-240p.jpg'),
|
|
'output_path': get_test_output_file('output-3.jpg')
|
|
}
|
|
|
|
assert run_steps('job-invalid', process_step) is False
|
|
|
|
create_job('job-test-run-steps')
|
|
add_step('job-test-run-steps', args_1)
|
|
add_step('job-test-run-steps', args_1)
|
|
add_step('job-test-run-steps', args_2)
|
|
add_step('job-test-run-steps', args_3)
|
|
|
|
assert run_steps('job-test-run-steps', process_step) is True
|
|
|
|
|
|
def test_finalize_steps() -> None:
|
|
args_1 =\
|
|
{
|
|
'source_path': get_test_example_file('source.jpg'),
|
|
'target_path': get_test_example_file('target-240p.mp4'),
|
|
'output_path': get_test_output_file('output-1.mp4')
|
|
}
|
|
args_2 =\
|
|
{
|
|
'source_path': get_test_example_file('source.jpg'),
|
|
'target_path': get_test_example_file('target-240p.mp4'),
|
|
'output_path': get_test_output_file('output-2.mp4')
|
|
}
|
|
args_3 =\
|
|
{
|
|
'source_path': get_test_example_file('source.jpg'),
|
|
'target_path': get_test_example_file('target-240p.jpg'),
|
|
'output_path': get_test_output_file('output-3.jpg')
|
|
}
|
|
|
|
create_job('job-test-finalize-steps')
|
|
add_step('job-test-finalize-steps', args_1)
|
|
add_step('job-test-finalize-steps', args_1)
|
|
add_step('job-test-finalize-steps', args_2)
|
|
add_step('job-test-finalize-steps', args_3)
|
|
|
|
copy_file(args_1.get('target_path'), get_test_output_file('output-1-job-test-finalize-steps-0.mp4'))
|
|
copy_file(args_1.get('target_path'), get_test_output_file('output-1-job-test-finalize-steps-1.mp4'))
|
|
copy_file(args_2.get('target_path'), get_test_output_file('output-2-job-test-finalize-steps-2.mp4'))
|
|
copy_file(args_3.get('target_path'), get_test_output_file('output-3-job-test-finalize-steps-3.jpg'))
|
|
|
|
assert finalize_steps('job-test-finalize-steps') is True
|
|
assert is_test_output_file('output-1.mp4') is True
|
|
assert is_test_output_file('output-2.mp4') is True
|
|
assert is_test_output_file('output-3.jpg') is True
|
|
|
|
|
|
def test_collect_output_set() -> None:
|
|
args_1 =\
|
|
{
|
|
'source_path': get_test_example_file('source.jpg'),
|
|
'target_path': get_test_example_file('target-240p.mp4'),
|
|
'output_path': get_test_output_file('output-1.mp4')
|
|
}
|
|
args_2 =\
|
|
{
|
|
'source_path': get_test_example_file('source.jpg'),
|
|
'target_path': get_test_example_file('target-240p.mp4'),
|
|
'output_path': get_test_output_file('output-2.mp4')
|
|
}
|
|
args_3 =\
|
|
{
|
|
'source_path': get_test_example_file('source.jpg'),
|
|
'target_path': get_test_example_file('target-240p.jpg'),
|
|
'output_path': get_test_output_file('output-3.jpg')
|
|
}
|
|
|
|
create_job('job-test-collect-output-set')
|
|
add_step('job-test-collect-output-set', args_1)
|
|
add_step('job-test-collect-output-set', args_1)
|
|
add_step('job-test-collect-output-set', args_2)
|
|
add_step('job-test-collect-output-set', args_3)
|
|
|
|
output_set =\
|
|
{
|
|
get_test_output_file('output-1.mp4'):
|
|
[
|
|
get_test_output_file('output-1-job-test-collect-output-set-0.mp4'),
|
|
get_test_output_file('output-1-job-test-collect-output-set-1.mp4')
|
|
],
|
|
get_test_output_file('output-2.mp4'):
|
|
[
|
|
get_test_output_file('output-2-job-test-collect-output-set-2.mp4')
|
|
],
|
|
get_test_output_file('output-3.jpg'):
|
|
[
|
|
get_test_output_file('output-3-job-test-collect-output-set-3.jpg')
|
|
]
|
|
}
|
|
|
|
assert collect_output_set('job-test-collect-output-set') == output_set
|