MCPcopy Create free account
hub / github.com/awsdocs/aws-doc-sdk-examples / make_faces

Function make_faces

python/example_code/rekognition/test/conftest.py:18–65  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

16
17@pytest.fixture()
18def make_faces():
19 def _make_faces(count, has_details=False, is_celebrity=False, is_index=False):
20 faces = []
21 for _ in range(0, count):
22 face_dict = {
23 "BoundingBox": {"Left": 0, "Top": 0.5, "Width": 0.3, "Height": 0.7},
24 "Confidence": random.randint(0, 100),
25 "Landmarks": [{"Type": "test"}],
26 "Pose": {"Roll": random.randint(0, 100)},
27 "Quality": {"Brightness": random.randint(0, 100)},
28 }
29 if has_details:
30 face_dict.update(
31 {
32 "AgeRange": {
33 "Low": random.randint(0, 30),
34 "High": random.randint(30, 100),
35 },
36 "Smile": {"Value": random.choice([True, False])},
37 "Eyeglasses": {"Value": random.choice([True, False])},
38 "Sunglasses": {"Value": random.choice([True, False])},
39 "Gender": {"Value": random.choice(["Male", "Female"])},
40 "Beard": {"Value": random.choice([True, False])},
41 "Mustache": {"Value": random.choice([True, False])},
42 "EyesOpen": {"Value": random.choice([True, False])},
43 "MouthOpen": {"Value": random.choice([True, False])},
44 "Emotions": [
45 {"Type": emotion, "Confidence": random.randint(0, 100)}
46 for emotion in ["BEMUSED", "CAUTIOUSLY OPTIMISTIC"]
47 ],
48 }
49 )
50 if is_index:
51 face_dict.update({"FaceId": "test-face-id", "ImageId": "test-image-id"})
52 if is_celebrity:
53 celeb = {
54 "Urls": ["http://example.com"],
55 "Name": "test-name",
56 "Id": "test-celeb-id",
57 "MatchConfidence": random.randint(0, 100),
58 "Face": face_dict,
59 }
60 faces.append(celeb)
61 else:
62 faces.append(face_dict)
63 return faces
64
65 return _make_faces
66
67
68@pytest.fixture()

Callers 8

test_detect_facesFunction · 0.85
test_compare_facesFunction · 0.85
test_do_face_detectionFunction · 0.85
test_index_facesFunction · 0.85
_make_personsFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected