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