AMMICO/misinformation/test/test_faces.py
xiaohemaikoo fdcb228294
M objdect (#23)
* colors expression by KMean algorithm

* object detection by imageai

* object detection by cvlib

* add encapsulation of object detection

* remove encapsulation of objdetect v0

* objects expression to dict

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* added imageai to requirements

* add objects to dictionary

* update for AnalysisMethod baseline

* add objects dection support explore_analysis display

* extend python version of misinf to allow imageai

* account for older python

* use global functionality for dict to csv convert

* update for docker build

* docker will build now but ipywidgets still not working

* test code

* include test data folder in repo

* add some sample images

* load cvs labels to dict

* add test data

* retrigger checks

* add map to human coding

* get orders from dict, missing dep

* add module to test accuracy

* retrigger checks

* retrigger checks

* now removing imageai

* removed imageai

* move labelmanager to analyse

* multiple faces in mydict

* fix pre-commit issues

* map mydict

* hide imageai

* objects default using cvlib, isolate and disable imageai

* correct python version

* refactor faces tests

* refactor objects tests

* sonarcloud issues

* refactor utils tests

* address code smells

* update readme

* update notebook without imageai

Co-authored-by: Ma Xianghe <825074348@qq.com>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: iulusoy <inga.ulusoy@uni-heidelberg.de>
2022-10-04 11:34:44 +02:00

26 строки
736 B
Python

import misinformation.faces as fc
import json
def test_analyse_faces():
mydict = {
"filename": "./test/data/IMG_2746.png",
}
mydict = fc.EmotionDetector(mydict).analyse_image()
print(mydict)
with open("./test/data/example_faces.json", "r") as file:
out_dict = json.load(file)
for key in mydict.keys():
if key != "emotion":
assert mydict[key] == out_dict[key]
# json can't handle tuples natively
for i in range(0, len(mydict["emotion"])):
temp = (
list(mydict["emotion"][i])
if type(mydict["emotion"][i]) == tuple
else mydict["emotion"][i]
)
assert temp == out_dict["emotion"][i]