AMMICO/ammico/test/test_display.py
Inga Ulusoy e11d4c05f4
Update notebooks and add options in display for text model names (#133)
* updated notebooks for the new interface

---------

Co-authored-by: Petr Andriushchenko <pitandmind@gmail.com>
2023-07-12 09:31:58 +02:00

128 строки
3.2 KiB
Python

import json
import ammico.display as ammico_display
import pytest
@pytest.fixture
def get_options(get_path):
path_img_1 = get_path + "IMG_2809.png"
path_img_2 = get_path + "IMG_2746.png"
mydict = {
"IMG_2809": {"filename": path_img_1},
"IMG_2746": {"filename": path_img_2},
}
all_options_dict = {
path_img_1: "IMG_2809",
path_img_2: "IMG_2746",
}
return path_img_1, path_img_2, mydict, all_options_dict
@pytest.fixture
def get_AE(get_options):
analysis_explorer = ammico_display.AnalysisExplorer(get_options[2])
return analysis_explorer
def test_explore_analysis_faces(get_path):
mydict = {"IMG_2746": {"filename": get_path + "IMG_2746.png"}}
with open(get_path + "example_faces.json", "r") as file:
outs = json.load(file)
mydict["IMG_2746"].pop("filename", None)
for im_key in mydict.keys():
sub_dict = mydict[im_key]
for key in sub_dict.keys():
assert sub_dict[key] == outs[key]
def test_explore_analysis_objects(get_path):
mydict = {"IMG_2809": {"filename": get_path + "IMG_2809.png"}}
with open(get_path + "example_analysis_objects.json", "r") as file:
outs = json.load(file)
mydict["IMG_2809"].pop("filename", None)
for im_key in mydict.keys():
sub_dict = mydict[im_key]
for key in sub_dict.keys():
assert sub_dict[key] == outs[key]
def test_AnalysisExplorer(get_AE, get_options):
get_AE.update_picture(get_options[0])
assert get_AE.update_picture(None) is None
def test_right_output_analysis_objects(get_AE, get_options):
get_AE._right_output_analysis(
2,
get_options[3],
get_options[0],
"ObjectDetector",
True,
None,
None,
50,
50,
"CIE 1976",
"summary_and_questions",
"base",
"How many people are in the picture?",
)
def test_right_output_analysis_emotions(get_AE, get_options):
get_AE._right_output_analysis(
2,
get_options[3],
get_options[0],
"EmotionDetector",
True,
50,
None,
None,
50,
"CIE 1976",
"summary_and_questions",
"base",
"How many people are in the picture?",
)
def test_right_output_analysis_summary(get_AE, get_options):
get_AE._right_output_analysis(
2,
get_options[3],
get_options[0],
"SummaryDetector",
True,
None,
None,
50,
50,
"CIE 1976",
"summary_and_questions",
"base",
"How many people are in the picture?",
)
def test_right_output_analysis_colors(get_AE, get_options):
get_AE._right_output_analysis(
2,
get_options[3],
get_options[0],
"ColorDetector",
True,
None,
None,
50,
50,
"CIE 1976",
"summary_and_questions",
"base",
"How many people are in the picture?",
)
with pytest.raises(EnvironmentError):
get_AE.run_server(port=8050)