jhj0517
commited on
Commit
•
e6eff1c
1
Parent(s):
6849ec3
Add video creation test script
Browse files- tests/test_video_creation.py +39 -0
tests/test_video_creation.py
ADDED
@@ -0,0 +1,39 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import os
|
2 |
+
import pytest
|
3 |
+
|
4 |
+
from test_config import *
|
5 |
+
from modules.live_portrait.live_portrait_inferencer import LivePortraitInferencer
|
6 |
+
from modules.utils.image_helper import save_image
|
7 |
+
|
8 |
+
|
9 |
+
@pytest.mark.parametrize(
|
10 |
+
"input_image,expression_video",
|
11 |
+
[
|
12 |
+
(TEST_IMAGE_PATH, TEST_VIDEO_PATH),
|
13 |
+
]
|
14 |
+
)
|
15 |
+
def test_video_creation(
|
16 |
+
input_image: str,
|
17 |
+
expression_video: str
|
18 |
+
):
|
19 |
+
if not os.path.exists(TEST_IMAGE_PATH):
|
20 |
+
download_image(
|
21 |
+
TEST_IMAGE_URL,
|
22 |
+
TEST_IMAGE_PATH
|
23 |
+
)
|
24 |
+
if not os.path.exists(TEST_VIDEO_PATH):
|
25 |
+
download_image(
|
26 |
+
TEST_VIDEO_URL,
|
27 |
+
TEST_VIDEO_PATH
|
28 |
+
)
|
29 |
+
|
30 |
+
inferencer = LivePortraitInferencer()
|
31 |
+
|
32 |
+
output_video_path = inferencer.create_video(
|
33 |
+
driving_vid_path=expression_video,
|
34 |
+
src_image=input_image,
|
35 |
+
)
|
36 |
+
|
37 |
+
assert os.path.exists(output_video_path)
|
38 |
+
assert are_videos_different(input_image, TEST_EXPRESSION_OUTPUT_PATH)
|
39 |
+
assert has_sound(output_video_path)
|