mirror of
https://github.com/facefusion/facefusion.git
synced 2026-07-31 06:17:27 +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>
102 lines
3.9 KiB
Python
102 lines
3.9 KiB
Python
import numpy
|
|
import pytest
|
|
|
|
from facefusion import face_classifier, face_detector, face_landmarker, face_recognizer, state_manager
|
|
from facefusion.common_helper import get_first, get_last
|
|
from facefusion.download import conditional_download
|
|
from facefusion.face_creator import get_many_faces, get_one_face
|
|
from facefusion.face_store import clear_faces
|
|
from facefusion.face_tracker import create_face_tracks, select_face_track, track_faces
|
|
from facefusion.vision import read_static_video_frame, select_video_frames
|
|
from .helper import get_test_example_file, get_test_examples_directory
|
|
|
|
|
|
@pytest.fixture(scope = 'module', autouse = True)
|
|
def before_all() -> None:
|
|
conditional_download(get_test_examples_directory(),
|
|
[
|
|
'https://github.com/facefusion/facefusion-assets/releases/download/examples-3.0.0/target-240p.mp4'
|
|
])
|
|
|
|
state_manager.init_item('execution_device_ids', [ 0 ])
|
|
state_manager.init_item('execution_providers', [ 'cpu' ])
|
|
state_manager.init_item('download_providers', [ 'github' ])
|
|
state_manager.init_item('face_detector_angles', [ 0 ])
|
|
state_manager.init_item('face_detector_model', 'yolo_face')
|
|
state_manager.init_item('face_detector_size', '640x640')
|
|
state_manager.init_item('face_detector_margin', (0, 0, 0, 0))
|
|
state_manager.init_item('face_detector_score', 0.5)
|
|
state_manager.init_item('face_landmarker_model', 'many')
|
|
state_manager.init_item('face_landmarker_score', 0.5)
|
|
state_manager.init_item('face_tracker_score', 0.3)
|
|
|
|
face_classifier.pre_check()
|
|
face_detector.pre_check()
|
|
face_landmarker.pre_check()
|
|
face_recognizer.pre_check()
|
|
|
|
|
|
@pytest.fixture(autouse = True)
|
|
def before_each() -> None:
|
|
face_classifier.clear_inference_pool()
|
|
face_detector.clear_inference_pool()
|
|
face_landmarker.clear_inference_pool()
|
|
face_recognizer.clear_inference_pool()
|
|
clear_faces()
|
|
|
|
|
|
def test_track_faces() -> None:
|
|
target_path = get_test_example_file('target-240p.mp4')
|
|
target_vision_frames = select_video_frames(target_path, 3, 3)
|
|
empty_vision_frame = numpy.zeros_like(get_first(target_vision_frames))
|
|
|
|
target_vision_frames[2] = empty_vision_frame
|
|
target_vision_frames[3] = empty_vision_frame
|
|
target_vision_frames[4] = empty_vision_frame
|
|
target_vision_frames[5] = empty_vision_frame
|
|
|
|
assert len(track_faces(target_vision_frames, 0.3)) == 1
|
|
|
|
target_vision_frames = select_video_frames(target_path, 3, 3)[:5]
|
|
target_vision_frames[0] = empty_vision_frame
|
|
target_vision_frames[1] = empty_vision_frame
|
|
target_vision_frames[2] = empty_vision_frame
|
|
|
|
assert len(track_faces(target_vision_frames, 0.3)) == 0
|
|
|
|
|
|
def test_create_face_tracks() -> None:
|
|
target_vision_frame = read_static_video_frame(get_test_example_file('target-240p.mp4'), 0)
|
|
multi_face_vision_frame = numpy.hstack([ target_vision_frame, target_vision_frame ])
|
|
|
|
face_tracks = create_face_tracks([ target_vision_frame, target_vision_frame ], 0.3)
|
|
|
|
assert len(face_tracks) == 1
|
|
assert sorted(get_first(face_tracks)) == [ 0, 1 ]
|
|
|
|
face_tracks = create_face_tracks([ multi_face_vision_frame, multi_face_vision_frame ], 0.3)
|
|
|
|
assert len(face_tracks) == 2
|
|
assert sorted(get_first(face_tracks)) == [ 0, 1 ]
|
|
assert sorted(get_last(face_tracks)) == [ 0, 1 ]
|
|
|
|
assert len(create_face_tracks([ target_vision_frame, target_vision_frame ], 1.0)) == 2
|
|
|
|
|
|
def test_select_face_track() -> None:
|
|
target_vision_frame = read_static_video_frame(get_test_example_file('target-240p.mp4'), 0)
|
|
face = get_one_face(get_many_faces([ target_vision_frame ]))
|
|
face_overlap = face._replace(bounding_box = numpy.array([ 12, 12, 52, 52 ]))
|
|
face_distant = face._replace(bounding_box = numpy.array([ 200, 200, 240, 240 ]))
|
|
face_track_overlap =\
|
|
{
|
|
0 : face._replace(bounding_box = numpy.array([ 10, 10, 50, 50 ]))
|
|
}
|
|
face_track_distant =\
|
|
{
|
|
0 : face._replace(bounding_box = numpy.array([ 100, 100, 140, 140 ]))
|
|
}
|
|
|
|
assert select_face_track([ face_track_overlap, face_track_distant ], face_overlap, 0.3) is face_track_overlap
|
|
assert select_face_track([ face_track_overlap, face_track_distant ], face_distant, 0.3) == {}
|