mirror of
https://github.com/facefusion/facefusion.git
synced 2026-09-26 17:30:46 +02:00
modernize ffmpeg in test suite (#1190)
This commit is contained in:
@@ -1,8 +1,7 @@
|
||||
import subprocess
|
||||
|
||||
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.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
|
||||
@@ -12,13 +11,23 @@ from .assert_helper import get_test_example_file, get_test_examples_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'
|
||||
])
|
||||
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') ])
|
||||
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') ])
|
||||
|
||||
for crop_scale in [ 80, 70, 60 ]:
|
||||
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_providers', [ 'cpu' ])
|
||||
@@ -34,9 +43,17 @@ def before_all() -> None:
|
||||
'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') ])
|
||||
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') ])
|
||||
for crop_scale in [ 80, 70, 60 ]:
|
||||
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'))
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
@pytest.fixture(autouse = True)
|
||||
|
||||
Reference in New Issue
Block a user