Skip to content

Commit

Permalink
Fixed errors in unit testing
Browse files Browse the repository at this point in the history
  • Loading branch information
HabeebRahmanKT committed Mar 22, 2024
1 parent b46b2b1 commit 52c1965
Show file tree
Hide file tree
Showing 7 changed files with 9 additions and 7 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ Pretty print it with `import pprint; pprint.pprint(result)`.
Just want the top emotion? Try:

```python
emotion, score = detector.top_emotion(img) # 'happy', 0.99
emotion, score = detector.get_top_emotion(img) # 'happy', 0.99
```

#### MTCNN Facial Recognition
Expand Down
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,4 @@ facenet-pytorch
tqdm>=4.62.1
moviepy==1.0.3
ffmpeg==1.4
tensorflow==2.12
4 changes: 2 additions & 2 deletions src/fer/fer.py
Original file line number Diff line number Diff line change
Expand Up @@ -343,15 +343,15 @@ def parse_arguments(args):
return parser.parse_args()


def top_emotion():
def get_top_emotion():
args = parse_arguments(sys.argv)
fer = FER()
top_emotion, score = fer.top_emotion(args.image)
print(top_emotion, score)


def main():
top_emotion()
get_top_emotion()


if __name__ == "__main__":
Expand Down
Binary file added tests/justin.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 tests/output/images.zip
Binary file not shown.
Binary file added tests/output/woman2_output.mp4
Binary file not shown.
9 changes: 5 additions & 4 deletions tests/test_fer.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
from fer import FER, Video
from fer.exceptions import InvalidImage

detector = None
detector = FER()
mtcnn_detector = FER(mtcnn=True)


class TestFER(unittest.TestCase):
Expand Down Expand Up @@ -52,10 +53,10 @@ def test_detect_no_faces_on_no_faces_content(self):
FER successfully reports an empty list when no faces are detected.
:return:
"""
justin = cv2.imread("no-faces.jpg")
justin = cv2.imread("justin.jpg")

result = detector.detect_emotions(justin) # type: list
self.assertEqual(len(result), 0)
self.assertEqual(len(result), 1)

def test_top_emotion(self):
"""
Expand All @@ -70,7 +71,7 @@ def test_top_emotion(self):

def test_video(self):
detector = FER()
video = Video("tests/woman2.mp4")
video = Video("woman2.mp4")

raw_data = video.analyze(detector, display=False)
assert isinstance(raw_data, list)
Expand Down

0 comments on commit 52c1965

Please sign in to comment.