removed unused object
This commit is contained in:
@@ -11,101 +11,18 @@ from pydantic import BaseModel
|
||||
from pydantic import field_serializer
|
||||
from pydantic import field_validator
|
||||
|
||||
from src.model_experiential import (
|
||||
VisualSyntaxModelOutput,
|
||||
)
|
||||
from src.model_interpersonal import AngleModelOutput
|
||||
from src.model_interpersonal import ContactModelOutput
|
||||
from src.model_interpersonal import DistanceModelOutput
|
||||
from src.model_interpersonal import ModalityColorModelOutput
|
||||
from src.model_interpersonal import ModalityDepthModelOutput
|
||||
from src.model_interpersonal import ModalityLightingModelOutput
|
||||
from src.model_interpersonal import PointOfViewModelOutput
|
||||
from src.model_textual import FramingModelOutput
|
||||
from src.model_textual import InformationValueModelOutput
|
||||
from src.model_textual import SalienceModelOutput
|
||||
from core.dto import ModelData
|
||||
|
||||
|
||||
class NoDocumentFoundException(Exception):
|
||||
pass
|
||||
|
||||
|
||||
class ModelOutputs(BaseModel):
|
||||
visual_syntax: VisualSyntaxModelOutput
|
||||
contact: ContactModelOutput
|
||||
angle: AngleModelOutput
|
||||
point_of_view: PointOfViewModelOutput
|
||||
distance: DistanceModelOutput
|
||||
modality_lighting: ModalityLightingModelOutput
|
||||
modality_color: ModalityColorModelOutput
|
||||
modality_depth: ModalityDepthModelOutput
|
||||
information_value: InformationValueModelOutput
|
||||
framing: FramingModelOutput
|
||||
salience: SalienceModelOutput
|
||||
|
||||
@classmethod
|
||||
def list_fields(cls) -> list[str]:
|
||||
"""List options that are stored as attributes."""
|
||||
return list(cls.model_fields.keys())
|
||||
|
||||
@classmethod
|
||||
def from_random(cls) -> ModelOutputs:
|
||||
"""Instantiate with random numbers."""
|
||||
kwargs = {
|
||||
field: field_info.annotation.from_random() # type: ignore
|
||||
for field, field_info
|
||||
in cls.model_fields.items()
|
||||
}
|
||||
return cls(**kwargs)
|
||||
|
||||
@classmethod
|
||||
def from_annotations(
|
||||
cls,
|
||||
visual_syntax: str,
|
||||
contact: str,
|
||||
angle: str,
|
||||
point_of_view: str,
|
||||
distance: str,
|
||||
modality_lighting: str,
|
||||
modality_color: str,
|
||||
modality_depth: str,
|
||||
information_value: str,
|
||||
framing: str,
|
||||
salience: str,
|
||||
) -> ModelOutputs:
|
||||
"""Instantiate from annotation."""
|
||||
kwargs = {
|
||||
'visual_syntax': VisualSyntaxModelOutput
|
||||
.from_choice(visual_syntax),
|
||||
'contact': ContactModelOutput
|
||||
.from_choice(contact),
|
||||
'angle': AngleModelOutput
|
||||
.from_choice(angle),
|
||||
'point_of_view': PointOfViewModelOutput
|
||||
.from_choice(point_of_view),
|
||||
'distance': DistanceModelOutput
|
||||
.from_choice(distance),
|
||||
'modality_lighting': ModalityLightingModelOutput
|
||||
.from_choice(modality_lighting),
|
||||
'modality_color': ModalityColorModelOutput
|
||||
.from_choice(modality_color),
|
||||
'modality_depth': ModalityDepthModelOutput
|
||||
.from_choice(modality_depth),
|
||||
'information_value': InformationValueModelOutput
|
||||
.from_choice(information_value),
|
||||
'framing': FramingModelOutput
|
||||
.from_choice(framing),
|
||||
'salience': SalienceModelOutput
|
||||
.from_choice(salience),
|
||||
}
|
||||
return cls(**kwargs)
|
||||
|
||||
|
||||
class VisualCommunication(BaseModel):
|
||||
name: str
|
||||
image: Image.Image
|
||||
annotation: ModelOutputs | None = None
|
||||
prediction: ModelOutputs | None = None
|
||||
annotation: ModelData | None = None
|
||||
prediction: ModelData | None = None
|
||||
|
||||
class Config:
|
||||
arbitrary_types_allowed = True
|
||||
@@ -162,4 +79,4 @@ class VisualCommunication(BaseModel):
|
||||
"""Generate random prediction values."""
|
||||
if not force and self.prediction is not None:
|
||||
logging.warning('set force=True to overwrite existing values.')
|
||||
self.prediction = ModelOutputs.from_random()
|
||||
self.prediction = ModelData.from_random()
|
||||
|
||||
@@ -4,9 +4,9 @@ import logging
|
||||
|
||||
from pymongo.collection import Collection
|
||||
|
||||
from .classes import ModelOutputs
|
||||
from .classes import NoDocumentFoundException
|
||||
from .classes import VisualCommunication
|
||||
from core.dto import ModelData
|
||||
|
||||
|
||||
def count_documents(
|
||||
@@ -97,7 +97,7 @@ def get_visual_communication(
|
||||
def upsert_predictions(
|
||||
collection: Collection,
|
||||
vis_com_name: str,
|
||||
predictions: ModelOutputs,
|
||||
predictions: ModelData,
|
||||
) -> None:
|
||||
"""Upsert prediction data in the database."""
|
||||
query = {
|
||||
@@ -120,7 +120,7 @@ def upsert_predictions(
|
||||
def upsert_annotations(
|
||||
collection: Collection,
|
||||
vis_com_name: str,
|
||||
annotations: ModelOutputs,
|
||||
annotations: ModelData,
|
||||
) -> None:
|
||||
"""Upserts annotation data in the database."""
|
||||
query = {
|
||||
|
||||
Reference in New Issue
Block a user