updated to use new vis com class
This commit is contained in:
@@ -11,6 +11,7 @@ from dash import Input
|
|||||||
from dash import Output
|
from dash import Output
|
||||||
from dash import State
|
from dash import State
|
||||||
from dash_auth import BasicAuth
|
from dash_auth import BasicAuth
|
||||||
|
from minio import Minio
|
||||||
from pydantic import ValidationError
|
from pydantic import ValidationError
|
||||||
from pymongo.collection import Collection
|
from pymongo.collection import Collection
|
||||||
|
|
||||||
@@ -25,7 +26,8 @@ from shared.dto import ModelData
|
|||||||
|
|
||||||
|
|
||||||
def init_app(
|
def init_app(
|
||||||
collection: Collection,
|
mongo_collection: Collection,
|
||||||
|
minio_client: Minio,
|
||||||
) -> Dash:
|
) -> Dash:
|
||||||
"""Initialise web UI application."""
|
"""Initialise web UI application."""
|
||||||
# setup app
|
# setup app
|
||||||
@@ -92,11 +94,11 @@ def init_app(
|
|||||||
assert isinstance(filename_list, list)
|
assert isinstance(filename_list, list)
|
||||||
# get values from database
|
# get values from database
|
||||||
num_total = count_documents(
|
num_total = count_documents(
|
||||||
collection=collection,
|
collection=mongo_collection,
|
||||||
only_with_annotation=False,
|
only_with_annotation=False,
|
||||||
)
|
)
|
||||||
num_handled = count_documents(
|
num_handled = count_documents(
|
||||||
collection=collection,
|
collection=mongo_collection,
|
||||||
only_with_annotation=True,
|
only_with_annotation=True,
|
||||||
)
|
)
|
||||||
limit = int(num_total/20)
|
limit = int(num_total/20)
|
||||||
@@ -138,7 +140,7 @@ def init_app(
|
|||||||
vis_com_list.append(vis_com)
|
vis_com_list.append(vis_com)
|
||||||
# upsert documents
|
# upsert documents
|
||||||
success = upsert_visual_communication(
|
success = upsert_visual_communication(
|
||||||
collection=collection,
|
collection=mongo_collection,
|
||||||
visual_communication_list=vis_com_list,
|
visual_communication_list=vis_com_list,
|
||||||
)
|
)
|
||||||
if success:
|
if success:
|
||||||
@@ -217,7 +219,7 @@ def init_app(
|
|||||||
annotations = ModelData.from_annotations(**annotation_map)
|
annotations = ModelData.from_annotations(**annotation_map)
|
||||||
# save data to database
|
# save data to database
|
||||||
upsert_annotation(
|
upsert_annotation(
|
||||||
collection=collection,
|
collection=mongo_collection,
|
||||||
vis_com_name=vis_com_name,
|
vis_com_name=vis_com_name,
|
||||||
annotations=annotations,
|
annotations=annotations,
|
||||||
)
|
)
|
||||||
@@ -231,12 +233,12 @@ def init_app(
|
|||||||
try:
|
try:
|
||||||
# get data
|
# get data
|
||||||
vis_com = get_visual_communication(
|
vis_com = get_visual_communication(
|
||||||
collection=collection,
|
collection=mongo_collection,
|
||||||
with_annotation=False,
|
with_annotation=False,
|
||||||
)
|
)
|
||||||
# set variables
|
# set variables
|
||||||
vis_com_name = vis_com.name
|
vis_com_name = vis_com.name
|
||||||
image_src = vis_com.webencoded_image()
|
image_src = vis_com.webencoded_image(minio_client=minio_client)
|
||||||
if vis_com.prediction is not None:
|
if vis_com.prediction is not None:
|
||||||
# TODO: update to use optional predictions
|
# TODO: update to use optional predictions
|
||||||
pass
|
pass
|
||||||
|
|||||||
Reference in New Issue
Block a user