Skip to content

Commit

Permalink
Add missing files
Browse files Browse the repository at this point in the history
  • Loading branch information
Alexander Mishchenko committed Apr 2, 2022
1 parent e50d9e7 commit e35dc2b
Show file tree
Hide file tree
Showing 7 changed files with 38 additions and 0 deletions.
3 changes: 3 additions & 0 deletions insomniac/extra_features/face_detector.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from insomniac import activation_controller

exec(activation_controller.get_extra_feature('face_detector'))
Binary file added insomniac/tests/assets/face1.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added insomniac/tests/assets/face2.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added insomniac/tests/assets/face3.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added insomniac/tests/assets/notface1.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added insomniac/tests/assets/notface2.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
35 changes: 35 additions & 0 deletions insomniac/tests/face_detector_tests.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import os
import unittest

from insomniac.extra_features.face_detector import FaceDetector


class FaceDetectorTests(unittest.TestCase):

ASSETS_DIR = "assets"
face_detector = FaceDetector()

def setUp(self):
print("Initializing FaceDetector")
self.face_detector.init()

def test_positive(self):
for file in os.listdir(self.ASSETS_DIR):
filename = os.fsdecode(file)
if filename.startswith("face"):
is_face = self.face_detector.is_face_on_image_by_filename(os.path.join(self.ASSETS_DIR, file))
assert is_face

def test_negative(self):
for file in os.listdir(self.ASSETS_DIR):
filename = os.fsdecode(file)
if filename.startswith("notface"):
is_face = self.face_detector.is_face_on_image_by_filename(os.path.join(self.ASSETS_DIR, file))
assert not is_face

@staticmethod
def _interpret_faces_array(faces) -> str:
if len(faces) > 0:
return "face"
else:
return "not face"

0 comments on commit e35dc2b

Please sign in to comment.