-
Notifications
You must be signed in to change notification settings - Fork 52
Expand file tree
/
Copy pathtest_face.py
More file actions
66 lines (20 loc) · 964 Bytes
/
test_face.py
File metadata and controls
66 lines (20 loc) · 964 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
import pytest
from app.face.face_embedding import extract_embedding, verify_embedding
def test_extract_embedding():
image_path = "images/Aaron_Peirsol/Aaron_Peirsol_0001.jpg"
embedding = extract_embedding(image_path)
assert embedding is not None
assert len(embedding) > 0
def test_no_face_exception():
image_path = "tests/images/no_face.jpg"
with pytest.raises(ValueError):
extract_embedding(image_path)
def test_verify_embedding():
image_path1 = "images/Aaron_Peirsol/Aaron_Peirsol_0001.jpg"
image_path2 = "images/Aaron_Peirsol/Aaron_Peirsol_0002.jpg"
image_path3 = "images/Olivia_Newton-John/Olivia_Newton-John_0001.jpg"
embedding1 = extract_embedding(image_path1)
embedding2 = extract_embedding(image_path2)
embedding3 = extract_embedding(image_path3)
assert verify_embedding(embedding1, embedding2)
assert not verify_embedding(embedding1, embedding3)