AMMICO/misinformation/test/test_objects.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

32 строки
889 B
Python

import json
import pytest
import misinformation
import misinformation.objects as ob
import misinformation.objects_cvlib as ob_cvlib
@pytest.fixture()
def default_objects():
return ob.init_default_objects()
def test_objects_from_cvlib(default_objects):
objects_list = ["cell phone", "motorcycle", "traffic light"]
objects = ob_cvlib.objects_from_cvlib(objects_list)
out_objects = default_objects
for obj in objects_list:
out_objects[obj] = "yes"
assert str(objects) == str(out_objects)
def test_analyse_image_cvlib():
mydict = {"filename": "./test/data/IMG_2809.png"}
ob_cvlib.ObjectCVLib().analyse_image(mydict)
with open("./test/data/example_objects_cvlib.json", "r") as file:
out_dict = json.load(file)
for key in mydict.keys():
print(key)
assert mydict[key] == out_dict[key]