Exemplo n.º 1
0
def test__given_img__when_scanned__then_1_to_1_relationship_between_all_returned_boxes_and_faces(scanner_cls, row):
    scanner: FaceScanner = get_scanner(scanner_cls)
    img = IMG_DIR / row.img_name

    scanned_faces = scanner.scan(img)

    assert calculate_errors(boxes=[face.box for face in scanned_faces], noses=row.noses) == 0
Exemplo n.º 2
0
def test__given_threshold_set_to_1__when_scanned__then_returns_no_faces(scanner_cls):
    scanner: FaceScanner = get_scanner(scanner_cls)
    img = IMG_DIR / '000_5.jpg'

    result = scanner.scan(img, det_prob_threshold=1)

    assert len(result) == 0
Exemplo n.º 3
0
def test__given_no_faces_img__when_scanned__then_returns_no_faces(scanner_cls):
    scanner: FaceScanner = get_scanner(scanner_cls)
    img = IMG_DIR / '017_0.jpg'

    result = scanner.scan(img)

    assert len(result) == 0
Exemplo n.º 4
0
def test__given_diff_face_images__when_scanned__then_returns_diff_embeddings(scanner_cls):
    scanner: FaceScanner = get_scanner(scanner_cls)
    img1 = IMG_DIR / '007_B.jpg'
    img2 = IMG_DIR / '009_C.jpg'

    emb1 = first_and_only(scanner.scan(img1)).embedding
    emb2 = first_and_only(scanner.scan(img2)).embedding

    assert not embeddings_are_equal(emb1, emb2, DIFFERENCE_THRESHOLD[scanner_cls])
Exemplo n.º 5
0
def test__given_5face_img__when_scanned__then_returns_5_correct_bounding_boxes_sorted_by_probability(scanner_cls):
    correct_boxes = [BoundingBoxDTO(544, 222, 661, 361, 1),
                     BoundingBoxDTO(421, 236, 530, 369, 1),
                     BoundingBoxDTO(161, 36, 266, 160, 1),
                     BoundingBoxDTO(342, 160, 437, 268, 1),
                     BoundingBoxDTO(243, 174, 352, 309, 1)]
    scanner: FaceScanner = get_scanner(scanner_cls)
    img = IMG_DIR / '000_5.jpg'

    faces = scanner.scan(img)

    for face in faces:
        assert face.box.similar_to_any(correct_boxes, tolerance=20)
    assert is_sorted([face.box.probability for face in faces])