Skip to content

Commit

Permalink
Rework testing suite files part2
Browse files Browse the repository at this point in the history
  • Loading branch information
henryruhs committed Jun 7, 2024
1 parent aa6fbfa commit 79ecd98
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 22 deletions.
5 changes: 3 additions & 2 deletions tests/test_download.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import pytest

from facefusion.download import conditional_download, get_download_size, is_download_done
from .helper import get_test_examples_directory, get_test_example_file


@pytest.fixture(scope = 'module', autouse = True)
def before_all() -> None:
conditional_download('.assets/examples',
conditional_download(get_test_examples_directory(),
[
'https://github.com/facefusion/facefusion-assets/releases/download/examples/target-240p.mp4'
])
Expand All @@ -18,6 +19,6 @@ def test_get_download_size() -> None:


def test_is_download_done() -> None:
assert is_download_done('https://github.com/facefusion/facefusion-assets/releases/download/examples/target-240p.mp4', '.assets/examples/target-240p.mp4') is True
assert is_download_done('https://github.com/facefusion/facefusion-assets/releases/download/examples/target-240p.mp4', get_test_example_file('target-240p.mp4')) is True
assert is_download_done('https://github.com/facefusion/facefusion-assets/releases/download/examples/target-240p.mp4', 'invalid') is False
assert is_download_done('invalid', 'invalid') is False
41 changes: 21 additions & 20 deletions tests/test_face_analyser.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,18 @@
from facefusion.face_analyser import pre_check, clear_face_analyser, get_one_face
from facefusion.typing import Face
from facefusion.vision import read_static_image
from .helper import get_test_examples_directory, get_test_example_file


@pytest.fixture(scope = 'module', autouse = True)
def before_all() -> None:
conditional_download('.assets/examples',
conditional_download(get_test_examples_directory(),
[
'https://github.com/facefusion/facefusion-assets/releases/download/examples/source.jpg'
])
subprocess.run([ 'ffmpeg', '-i', '.assets/examples/source.jpg', '-vf', 'crop=iw*0.8:ih*0.8', '.assets/examples/source-80crop.jpg' ])
subprocess.run([ 'ffmpeg', '-i', '.assets/examples/source.jpg', '-vf', 'crop=iw*0.7:ih*0.7', '.assets/examples/source-70crop.jpg' ])
subprocess.run([ 'ffmpeg', '-i', '.assets/examples/source.jpg', '-vf', 'crop=iw*0.6:ih*0.6', '.assets/examples/source-60crop.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') ])


@pytest.fixture(autouse = True)
Expand All @@ -34,10 +35,10 @@ def test_get_one_face_with_retinaface() -> None:
pre_check()
source_paths =\
[
'.assets/examples/source.jpg',
'.assets/examples/source-80crop.jpg',
'.assets/examples/source-70crop.jpg',
'.assets/examples/source-60crop.jpg'
get_test_example_file('source.jpg'),
get_test_example_file('source-80crop.jpg'),
get_test_example_file('source-70crop.jpg'),
get_test_example_file('source-60crop.jpg')
]
for source_path in source_paths:
source_frame = read_static_image(source_path)
Expand All @@ -53,10 +54,10 @@ def test_get_one_face_with_scrfd() -> None:
pre_check()
source_paths =\
[
'.assets/examples/source.jpg',
'.assets/examples/source-80crop.jpg',
'.assets/examples/source-70crop.jpg',
'.assets/examples/source-60crop.jpg'
get_test_example_file('source.jpg'),
get_test_example_file('source-80crop.jpg'),
get_test_example_file('source-70crop.jpg'),
get_test_example_file('source-60crop.jpg')
]
for source_path in source_paths:
source_frame = read_static_image(source_path)
Expand All @@ -72,10 +73,10 @@ def test_get_one_face_with_yoloface() -> None:
pre_check()
source_paths =\
[
'.assets/examples/source.jpg',
'.assets/examples/source-80crop.jpg',
'.assets/examples/source-70crop.jpg',
'.assets/examples/source-60crop.jpg'
get_test_example_file('source.jpg'),
get_test_example_file('source-80crop.jpg'),
get_test_example_file('source-70crop.jpg'),
get_test_example_file('source-60crop.jpg')
]
for source_path in source_paths:
source_frame = read_static_image(source_path)
Expand All @@ -91,10 +92,10 @@ def test_get_one_face_with_yunet() -> None:
pre_check()
source_paths =\
[
'.assets/examples/source.jpg',
'.assets/examples/source-80crop.jpg',
'.assets/examples/source-70crop.jpg',
'.assets/examples/source-60crop.jpg'
get_test_example_file('source.jpg'),
get_test_example_file('source-80crop.jpg'),
get_test_example_file('source-70crop.jpg'),
get_test_example_file('source-60crop.jpg')
]
for source_path in source_paths:
source_frame = read_static_image(source_path)
Expand Down

0 comments on commit 79ecd98

Please sign in to comment.