зеркало из
https://github.com/ssciwr/AMMICO.git
synced 2025-10-30 13:36:04 +02:00
* add image summary notebook * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * pin deepface version to avoid bug with progress bar after update * update actions version for checkout and python * test ci without lavis * no lavis for ci test * merging * return lavis * change lavis to salesforce-lavis * change pycocotools install method * change pycocotools install method * fix_pycocotools * Downgrade Python * back to 3.9 and remove pycocotools dependance * instrucctions for windows * missing comma after merge * lavis only for ubuntu * use lavis package name in install instead of git * adding multimodal searching py and notebook * exclude lavis on windows * skip import on windows * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * reactivate lavis * Revert "reactivate lavis" This reverts commit ecdaf9d316e4b08816ba62da5e0482c8ff15b14e. * Change input format for multimodal search * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * fix clip models * account for new interface in init imports * changed imports bec of lavis/windows * fix if-else, added clip ViT-L-14=336 model * fix code smells * add model change function to summary * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * fixed new model in summary.py * fixed summary windget * moved some function to utils * fixed imort torch in utils * added test_summary.py * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * fixed opencv version * added first test of multimodal_search.py * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * fixed test * removed windows in CI and added test in multimodal search * change lavis from dependencies from pip ro git * fixed blip2 model in test_multimodal_search.py * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * fixed test multimodal search on cpu and gpu machines * added test, fixed dependencies * add -vv to pytest command in CI * added test_multimodal_search tests * fixed tests in test_multimodal_search.py * fixed tests in test_summary * changed CI and fixed test_multimodel search * fixed ci * fixed error in test multimodal search, changed ci * added multimodal search test, added windows CI, added picture in test data * CI debuging * fixing tests in CI * fixing test in CI 2 * fixing CI 3 * fixing CI * added filtering function * Brought back all tests after CI fixing * changed CI one pytest by individual tests * fixed opencv problem * fix path for text, adjust result for new gcv * remove opencv * fixing cv2 error * added opencv-contrib, change objects_cvlib * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * fixing tests in CI * fixing CI testing * cleanup objects * fixing codecov in CI * fixing codecov in CI * run tests together; install opencv last * update requirements for opencv dependencies * moved lavis functions from utils to summary * Remove lavis from utils.py * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * add missing jupyter --------- 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>
91 строка
2.5 KiB
Python
91 строка
2.5 KiB
Python
import json
|
|
import pytest
|
|
import misinformation.objects as ob
|
|
import misinformation.objects_cvlib as ob_cvlib
|
|
|
|
OBJECT_1 = "cell phone"
|
|
OBJECT_2 = "motorcycle"
|
|
OBJECT_3 = "traffic light"
|
|
TEST_IMAGE_1 = "IMG_2809.png"
|
|
JSON_1 = "example_objects_cvlib.json"
|
|
|
|
|
|
@pytest.fixture()
|
|
def default_objects():
|
|
return ob.init_default_objects()
|
|
|
|
|
|
def test_objects_from_cvlib(default_objects):
|
|
objects_list = [OBJECT_1, OBJECT_2, OBJECT_3]
|
|
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(get_path):
|
|
mydict = {"filename": get_path + TEST_IMAGE_1}
|
|
ob_cvlib.ObjectCVLib().analyse_image(mydict)
|
|
|
|
with open(get_path + JSON_1, "r") as file:
|
|
out_dict = json.load(file)
|
|
for key in mydict.keys():
|
|
assert mydict[key] == out_dict[key]
|
|
|
|
|
|
def test_init_default_objects():
|
|
default_obj_list = [
|
|
"person",
|
|
"bicycle",
|
|
"car",
|
|
OBJECT_2,
|
|
"airplane",
|
|
"bus",
|
|
"train",
|
|
"truck",
|
|
"boat",
|
|
OBJECT_3,
|
|
OBJECT_1,
|
|
]
|
|
init_objects = ob_cvlib.init_default_objects()
|
|
for obj in default_obj_list:
|
|
assert init_objects[obj] == "no"
|
|
|
|
|
|
def test_analyse_image_from_file_cvlib(get_path):
|
|
file_path = get_path + TEST_IMAGE_1
|
|
objs = ob_cvlib.ObjectCVLib().analyse_image_from_file(get_path + file_path)
|
|
|
|
with open(get_path + JSON_1, "r") as file:
|
|
out_dict = json.load(file)
|
|
for key in objs.keys():
|
|
assert objs[key] == out_dict[key]
|
|
|
|
|
|
def test_detect_objects_cvlib(get_path):
|
|
file_path = get_path + TEST_IMAGE_1
|
|
objs = ob_cvlib.ObjectCVLib().detect_objects_cvlib(file_path)
|
|
|
|
with open(get_path + JSON_1, "r") as file:
|
|
out_dict = json.load(file)
|
|
for key in objs.keys():
|
|
assert objs[key] == out_dict[key]
|
|
|
|
|
|
def test_set_keys(default_objects, get_path):
|
|
mydict = {"filename": get_path + TEST_IMAGE_1}
|
|
key_objs = ob.ObjectDetector(mydict).set_keys()
|
|
assert str(default_objects) == str(key_objs)
|
|
|
|
|
|
def test_analyse_image(get_path):
|
|
mydict = {"filename": get_path + TEST_IMAGE_1}
|
|
ob.ObjectDetector.set_client_to_cvlib()
|
|
ob.ObjectDetector(mydict).analyse_image()
|
|
with open(get_path + JSON_1, "r") as file:
|
|
out_dict = json.load(file)
|
|
|
|
assert str(mydict) == str(out_dict)
|