mirror of
https://github.com/facefusion/facefusion.git
synced 2026-06-06 12:43:53 +02:00
775985645e
* move to push based receive * move to push based receive, fix mocks * fix tests * add todos * remove asyncio * remove asyncio * resolve todos * move to queue without events * prevent debug spam * concurrent stream inference stream_video.py: pipeline face-swap inference across execution_thread_count workers (ThreadPoolExecutor + bounded in-flight deque, ordered encode) to keep the GPU busy during encode Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> * add todos * add todos * add missing state --------- Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
51 lines
1.7 KiB
Python
51 lines
1.7 KiB
Python
from unittest.mock import patch
|
|
|
|
import cv2
|
|
import pytest
|
|
from tests.assert_helper import get_test_example_file, get_test_examples_directory
|
|
|
|
from facefusion import state_manager
|
|
from facefusion.codecs.aom_encoder import create, destroy, encode
|
|
from facefusion.common_helper import is_linux, is_macos, is_windows
|
|
from facefusion.download import conditional_download
|
|
from facefusion.hash_helper import create_hash
|
|
from facefusion.libraries import aom as aom_module
|
|
from facefusion.vision import read_video_frame
|
|
|
|
|
|
@pytest.fixture(scope = 'module', autouse = True)
|
|
def before_all() -> None:
|
|
state_manager.init_item('download_providers', [ 'github', 'huggingface' ])
|
|
|
|
conditional_download(get_test_examples_directory(), [ 'https://github.com/facefusion/facefusion-assets/releases/download/examples-3.0.0/target-240p.mp4' ])
|
|
|
|
aom_module.pre_check()
|
|
|
|
|
|
def test_create() -> None:
|
|
assert create((320, 240), 1000, 8, 16)
|
|
|
|
with patch('facefusion.libraries.aom.create_static_library', return_value = None):
|
|
assert create((320, 240), 1000, 8, 16) is None
|
|
|
|
|
|
def test_encode() -> None:
|
|
video_frame = read_video_frame(get_test_example_file('target-240p.mp4'))
|
|
video_buffer = cv2.cvtColor(video_frame, cv2.COLOR_BGR2YUV_I420).tobytes()
|
|
video_resolution = (video_frame.shape[1], video_frame.shape[0])
|
|
aom_encoder = create(video_resolution, 1000, 1, 0)
|
|
|
|
if is_linux() or is_windows():
|
|
assert create_hash(encode(aom_encoder, video_buffer, video_resolution, 3)) == '3ab6cc31'
|
|
|
|
if is_macos():
|
|
pytest.skip()
|
|
|
|
|
|
def test_destroy() -> None:
|
|
aom_encoder = create((320, 240), 1000, 8, 16)
|
|
|
|
with patch.object(aom_module.create_static_library(), 'aom_codec_destroy') as mock:
|
|
destroy(aom_encoder)
|
|
mock.assert_called_once_with(aom_encoder)
|