Spaces:
Running
Running
Delete tests
Browse files- tests/__init__.py +0 -0
- tests/test_cli.py +0 -31
- tests/test_utilities.py +0 -107
tests/__init__.py
DELETED
File without changes
|
tests/test_cli.py
DELETED
@@ -1,31 +0,0 @@
|
|
1 |
-
import subprocess
|
2 |
-
import pytest
|
3 |
-
|
4 |
-
from DeepFakeAI import wording
|
5 |
-
from DeepFakeAI.utilities import conditional_download
|
6 |
-
|
7 |
-
|
8 |
-
@pytest.fixture(scope = 'module', autouse = True)
|
9 |
-
def before_all() -> None:
|
10 |
-
conditional_download('.assets/examples',
|
11 |
-
[
|
12 |
-
'https://github.com/DeepFakeAI/DeepFakeAI-assets/releases/download/examples/source.jpg',
|
13 |
-
'https://github.com/DeepFakeAI/DeepFakeAI-assets/releases/download/examples/target-1080p.mp4'
|
14 |
-
])
|
15 |
-
subprocess.run([ 'ffmpeg', '-i', '.assets/examples/target-1080p.mp4', '-vframes', '1', '.assets/examples/target-1080p.jpg' ])
|
16 |
-
|
17 |
-
|
18 |
-
def test_image_to_image() -> None:
|
19 |
-
commands = [ 'python', 'run.py', '-s', '.assets/examples/source.jpg', '-t', '.assets/examples/target-1080p.jpg', '-o', '.assets/examples' ]
|
20 |
-
run = subprocess.run(commands, stdout = subprocess.PIPE)
|
21 |
-
|
22 |
-
assert run.returncode == 0
|
23 |
-
assert wording.get('processing_image_succeed') in run.stdout.decode()
|
24 |
-
|
25 |
-
|
26 |
-
def test_image_to_video() -> None:
|
27 |
-
commands = [ 'python', 'run.py', '-s', '.assets/examples/source.jpg', '-t', '.assets/examples/target-1080p.mp4', '-o', '.assets/examples', '--trim-frame-end', '10' ]
|
28 |
-
run = subprocess.run(commands, stdout = subprocess.PIPE)
|
29 |
-
|
30 |
-
assert run.returncode == 0
|
31 |
-
assert wording.get('processing_video_succeed') in run.stdout.decode()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
tests/test_utilities.py
DELETED
@@ -1,107 +0,0 @@
|
|
1 |
-
import glob
|
2 |
-
import subprocess
|
3 |
-
import pytest
|
4 |
-
|
5 |
-
import DeepFakeAI.globals
|
6 |
-
from DeepFakeAI.utilities import conditional_download, detect_fps, extract_frames, create_temp, get_temp_directory_path, clear_temp
|
7 |
-
|
8 |
-
|
9 |
-
@pytest.fixture(scope = 'module', autouse = True)
|
10 |
-
def before_all() -> None:
|
11 |
-
DeepFakeAI.globals.temp_frame_quality = 100
|
12 |
-
DeepFakeAI.globals.trim_frame_start = None
|
13 |
-
DeepFakeAI.globals.trim_frame_end = None
|
14 |
-
DeepFakeAI.globals.temp_frame_format = 'png'
|
15 |
-
conditional_download('.assets/examples',
|
16 |
-
[
|
17 |
-
'https://github.com/DeepFakeAI/DeepFakeAI-assets/releases/download/examples/target-240p.mp4'
|
18 |
-
])
|
19 |
-
subprocess.run([ 'ffmpeg', '-i', '.assets/examples/target-240p.mp4', '-vf', 'fps=25', '.assets/examples/target-240p-25fps.mp4' ])
|
20 |
-
subprocess.run([ 'ffmpeg', '-i', '.assets/examples/target-240p.mp4', '-vf', 'fps=30', '.assets/examples/target-240p-30fps.mp4' ])
|
21 |
-
subprocess.run([ 'ffmpeg', '-i', '.assets/examples/target-240p.mp4', '-vf', 'fps=60', '.assets/examples/target-240p-60fps.mp4' ])
|
22 |
-
|
23 |
-
|
24 |
-
@pytest.fixture(scope = 'function', autouse = True)
|
25 |
-
def before_each() -> None:
|
26 |
-
DeepFakeAI.globals.trim_frame_start = None
|
27 |
-
DeepFakeAI.globals.trim_frame_end = None
|
28 |
-
DeepFakeAI.globals.temp_frame_quality = 90
|
29 |
-
DeepFakeAI.globals.temp_frame_format = 'jpg'
|
30 |
-
|
31 |
-
|
32 |
-
def test_detect_fps() -> None:
|
33 |
-
assert detect_fps('.assets/examples/target-240p-25fps.mp4') == 25.0
|
34 |
-
assert detect_fps('.assets/examples/target-240p-30fps.mp4') == 30.0
|
35 |
-
assert detect_fps('.assets/examples/target-240p-60fps.mp4') == 60.0
|
36 |
-
|
37 |
-
|
38 |
-
def test_extract_frames() -> None:
|
39 |
-
target_paths =\
|
40 |
-
[
|
41 |
-
'.assets/examples/target-240p-25fps.mp4',
|
42 |
-
'.assets/examples/target-240p-30fps.mp4',
|
43 |
-
'.assets/examples/target-240p-60fps.mp4'
|
44 |
-
]
|
45 |
-
for target_path in target_paths:
|
46 |
-
temp_directory_path = get_temp_directory_path(target_path)
|
47 |
-
create_temp(target_path)
|
48 |
-
|
49 |
-
assert extract_frames(target_path, 30.0) is True
|
50 |
-
assert len(glob.glob1(temp_directory_path, '*.jpg')) == 324
|
51 |
-
|
52 |
-
clear_temp(target_path)
|
53 |
-
|
54 |
-
|
55 |
-
def test_extract_frames_with_trim_start() -> None:
|
56 |
-
DeepFakeAI.globals.trim_frame_start = 224
|
57 |
-
data_provider =\
|
58 |
-
[
|
59 |
-
('.assets/examples/target-240p-25fps.mp4', 55),
|
60 |
-
('.assets/examples/target-240p-30fps.mp4', 100),
|
61 |
-
('.assets/examples/target-240p-60fps.mp4', 212)
|
62 |
-
]
|
63 |
-
for target_path, frame_total in data_provider:
|
64 |
-
temp_directory_path = get_temp_directory_path(target_path)
|
65 |
-
create_temp(target_path)
|
66 |
-
|
67 |
-
assert extract_frames(target_path, 30.0) is True
|
68 |
-
assert len(glob.glob1(temp_directory_path, '*.jpg')) == frame_total
|
69 |
-
|
70 |
-
clear_temp(target_path)
|
71 |
-
|
72 |
-
|
73 |
-
def test_extract_frames_with_trim_start_and_trim_end() -> None:
|
74 |
-
DeepFakeAI.globals.trim_frame_start = 124
|
75 |
-
DeepFakeAI.globals.trim_frame_end = 224
|
76 |
-
data_provider =\
|
77 |
-
[
|
78 |
-
('.assets/examples/target-240p-25fps.mp4', 120),
|
79 |
-
('.assets/examples/target-240p-30fps.mp4', 100),
|
80 |
-
('.assets/examples/target-240p-60fps.mp4', 50)
|
81 |
-
]
|
82 |
-
for target_path, frame_total in data_provider:
|
83 |
-
temp_directory_path = get_temp_directory_path(target_path)
|
84 |
-
create_temp(target_path)
|
85 |
-
|
86 |
-
assert extract_frames(target_path, 30.0) is True
|
87 |
-
assert len(glob.glob1(temp_directory_path, '*.jpg')) == frame_total
|
88 |
-
|
89 |
-
clear_temp(target_path)
|
90 |
-
|
91 |
-
|
92 |
-
def test_extract_frames_with_trim_end() -> None:
|
93 |
-
DeepFakeAI.globals.trim_frame_end = 100
|
94 |
-
data_provider =\
|
95 |
-
[
|
96 |
-
('.assets/examples/target-240p-25fps.mp4', 120),
|
97 |
-
('.assets/examples/target-240p-30fps.mp4', 100),
|
98 |
-
('.assets/examples/target-240p-60fps.mp4', 50)
|
99 |
-
]
|
100 |
-
for target_path, frame_total in data_provider:
|
101 |
-
temp_directory_path = get_temp_directory_path(target_path)
|
102 |
-
create_temp(target_path)
|
103 |
-
|
104 |
-
assert extract_frames(target_path, 30.0) is True
|
105 |
-
assert len(glob.glob1(temp_directory_path, '*.jpg')) == frame_total
|
106 |
-
|
107 |
-
clear_temp(target_path)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|