2023-08-21 16:19:01 +02:00
|
|
|
import subprocess
|
2023-09-19 11:21:18 +02:00
|
|
|
import sys
|
2023-08-21 16:19:01 +02:00
|
|
|
import pytest
|
|
|
|
|
|
2023-12-20 00:00:32 +01:00
|
|
|
from facefusion.download import conditional_download
|
2023-08-21 16:19:01 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
@pytest.fixture(scope = 'module', autouse = True)
|
2023-08-21 18:56:44 +02:00
|
|
|
def before_all() -> None:
|
2023-08-21 16:19:01 +02:00
|
|
|
conditional_download('.assets/examples',
|
|
|
|
|
[
|
|
|
|
|
'https://github.com/facefusion/facefusion-assets/releases/download/examples/source.jpg',
|
2024-02-14 14:08:29 +01:00
|
|
|
'https://github.com/facefusion/facefusion-assets/releases/download/examples/source.mp3',
|
|
|
|
|
'https://github.com/facefusion/facefusion-assets/releases/download/examples/target-240p.mp4'
|
2023-08-21 16:19:01 +02:00
|
|
|
])
|
2024-02-14 14:08:29 +01:00
|
|
|
subprocess.run([ 'ffmpeg', '-i', '.assets/examples/target-240p.mp4', '-vframes', '1', '.assets/examples/target-240p.jpg' ])
|
2023-08-21 16:19:01 +02:00
|
|
|
|
|
|
|
|
|
2024-02-14 14:08:29 +01:00
|
|
|
def test_debug_face_to_image() -> None:
|
|
|
|
|
commands = [ sys.executable, 'run.py', '--frame-processors', 'face_debugger', '-t', '.assets/examples/target-240p.jpg', '-o', '.assets/examples/test_debug_face_to_image.jpg', '--headless' ]
|
2023-12-20 00:00:32 +01:00
|
|
|
run = subprocess.run(commands, stdout = subprocess.PIPE, stderr = subprocess.STDOUT)
|
2023-08-21 18:56:44 +02:00
|
|
|
|
2023-08-21 16:19:01 +02:00
|
|
|
assert run.returncode == 0
|
2024-01-19 19:57:48 +01:00
|
|
|
assert 'image succeed' in run.stdout.decode()
|
2023-08-21 16:19:01 +02:00
|
|
|
|
|
|
|
|
|
2024-02-14 14:08:29 +01:00
|
|
|
def test_debug_face_to_video() -> None:
|
|
|
|
|
commands = [ sys.executable, 'run.py', '--frame-processors', 'face_debugger', '-t', '.assets/examples/target-240p.mp4', '-o', '.assets/examples/test_debug_face_to_video.mp4', '--trim-frame-end', '10', '--headless' ]
|
|
|
|
|
run = subprocess.run(commands, stdout = subprocess.PIPE, stderr = subprocess.STDOUT)
|
|
|
|
|
|
|
|
|
|
assert run.returncode == 0
|
|
|
|
|
assert 'video succeed' in run.stdout.decode()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def test_enhance_face_to_image() -> None:
|
|
|
|
|
commands = [ sys.executable, 'run.py', '--frame-processors', 'face_enhancer', '-t', '.assets/examples/target-240p.jpg', '-o', '.assets/examples/test_enhance_face_to_image.jpg', '--headless' ]
|
|
|
|
|
run = subprocess.run(commands, stdout = subprocess.PIPE, stderr = subprocess.STDOUT)
|
|
|
|
|
|
|
|
|
|
assert run.returncode == 0
|
|
|
|
|
assert 'image succeed' in run.stdout.decode()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def test_enhance_face_to_video() -> None:
|
|
|
|
|
commands = [ sys.executable, 'run.py', '--frame-processors', 'face_enhancer', '-t', '.assets/examples/target-240p.mp4', '-o', '.assets/examples/test_enhance_face_to_video.mp4', '--trim-frame-end', '10', '--headless' ]
|
|
|
|
|
run = subprocess.run(commands, stdout = subprocess.PIPE, stderr = subprocess.STDOUT)
|
|
|
|
|
|
|
|
|
|
assert run.returncode == 0
|
|
|
|
|
assert 'video succeed' in run.stdout.decode()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def test_swap_face_to_image() -> None:
|
|
|
|
|
commands = [ sys.executable, 'run.py', '--frame-processors', 'face_swapper', '-s', '.assets/examples/source.jpg', '-t', '.assets/examples/target-240p.jpg', '-o', '.assets/examples/test_swap_face_to_image.jpg', '--headless' ]
|
|
|
|
|
run = subprocess.run(commands, stdout = subprocess.PIPE, stderr = subprocess.STDOUT)
|
|
|
|
|
|
|
|
|
|
assert run.returncode == 0
|
|
|
|
|
assert 'image succeed' in run.stdout.decode()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def test_swap_face_to_video() -> None:
|
|
|
|
|
commands = [ sys.executable, 'run.py', '--frame-processors', 'face_swapper', '-s', '.assets/examples/source.jpg', '-t', '.assets/examples/target-240p.mp4', '-o', '.assets/examples/test_swap_face_to_video.mp4', '--trim-frame-end', '10', '--headless' ]
|
|
|
|
|
run = subprocess.run(commands, stdout = subprocess.PIPE, stderr = subprocess.STDOUT)
|
|
|
|
|
|
|
|
|
|
assert run.returncode == 0
|
|
|
|
|
assert 'video succeed' in run.stdout.decode()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def test_sync_lip_to_image() -> None:
|
|
|
|
|
commands = [ sys.executable, 'run.py', '--frame-processors', 'lip_syncer', '-s', '.assets/examples/source.mp3', '-t', '.assets/examples/target-240p.jpg', '-o', '.assets/examples/test_sync_lip_to_image.jpg', '--headless' ]
|
|
|
|
|
run = subprocess.run(commands, stdout = subprocess.PIPE, stderr = subprocess.STDOUT)
|
|
|
|
|
|
|
|
|
|
assert run.returncode == 0
|
|
|
|
|
assert 'image succeed' in run.stdout.decode()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def test_sync_lip_to_video() -> None:
|
|
|
|
|
commands = [ sys.executable, 'run.py', '--frame-processors', 'lip_syncer', '-s', '.assets/examples/source.mp3', '-t', '.assets/examples/target-240p.mp4', '-o', '.assets/examples/test_sync_lip_to_video.mp4', '--trim-frame-end', '10', '--headless' ]
|
2023-12-20 00:00:32 +01:00
|
|
|
run = subprocess.run(commands, stdout = subprocess.PIPE, stderr = subprocess.STDOUT)
|
2023-08-21 18:56:44 +02:00
|
|
|
|
2023-08-21 16:19:01 +02:00
|
|
|
assert run.returncode == 0
|
2024-01-19 19:57:48 +01:00
|
|
|
assert 'video succeed' in run.stdout.decode()
|