AMMICO/ammico/test/test_faces.py
Inga Ulusoy f128fa4754
check threshold for emotion and race lies in btw 0 and 100 (#175)
* check threshold for emotion and race liezs in btw 0 and 100

* Update release.yml

* correct order of calling args in test display
2024-01-16 11:13:22 +01:00

34 строки
1.0 KiB
Python

import ammico.faces as fc
import json
import pytest
def test_set_keys():
ed = fc.EmotionDetector({})
assert ed.subdict["face"] == "No"
assert ed.subdict["multiple_faces"] == "No"
assert ed.subdict["wears_mask"] == ["No"]
assert ed.subdict["emotion"] == [None]
with pytest.raises(ValueError):
fc.EmotionDetector({}, emotion_threshold=150)
with pytest.raises(ValueError):
fc.EmotionDetector({}, emotion_threshold=-50)
with pytest.raises(ValueError):
fc.EmotionDetector({}, race_threshold=150)
with pytest.raises(ValueError):
fc.EmotionDetector({}, race_threshold=-50)
def test_analyse_faces(get_path):
mydict = {
"filename": get_path + "IMG_2746.png",
}
mydict.update(fc.EmotionDetector(mydict).analyse_image())
with open(get_path + "example_faces.json", "r") as file:
out_dict = json.load(file)
# delete the filename key
mydict.pop("filename", None)
for key in mydict.keys():
assert mydict[key] == out_dict[key]