Adding python files
This commit is contained in:
63
src/database/models.py
Normal file
63
src/database/models.py
Normal file
@@ -0,0 +1,63 @@
|
||||
"""
|
||||
Data models for the microscopy object detection application.
|
||||
These dataclasses represent the database entities.
|
||||
"""
|
||||
|
||||
from dataclasses import dataclass
|
||||
from datetime import datetime
|
||||
from typing import Optional, Dict, Tuple
|
||||
|
||||
|
||||
@dataclass
|
||||
class Model:
|
||||
"""Represents a trained model."""
|
||||
|
||||
id: Optional[int]
|
||||
model_name: str
|
||||
model_version: str
|
||||
model_path: str
|
||||
base_model: str
|
||||
created_at: datetime
|
||||
training_params: Optional[Dict]
|
||||
metrics: Optional[Dict]
|
||||
|
||||
|
||||
@dataclass
|
||||
class Image:
|
||||
"""Represents an image in the database."""
|
||||
|
||||
id: Optional[int]
|
||||
relative_path: str
|
||||
filename: str
|
||||
width: int
|
||||
height: int
|
||||
captured_at: Optional[datetime]
|
||||
added_at: datetime
|
||||
checksum: Optional[str]
|
||||
|
||||
|
||||
@dataclass
|
||||
class Detection:
|
||||
"""Represents a detection result."""
|
||||
|
||||
id: Optional[int]
|
||||
image_id: int
|
||||
model_id: int
|
||||
class_name: str
|
||||
bbox: Tuple[float, float, float, float] # (x_min, y_min, x_max, y_max)
|
||||
confidence: float
|
||||
detected_at: datetime
|
||||
metadata: Optional[Dict]
|
||||
|
||||
|
||||
@dataclass
|
||||
class Annotation:
|
||||
"""Represents a manual annotation."""
|
||||
|
||||
id: Optional[int]
|
||||
image_id: int
|
||||
class_name: str
|
||||
bbox: Tuple[float, float, float, float] # (x_min, y_min, x_max, y_max)
|
||||
annotator: str
|
||||
created_at: datetime
|
||||
verified: bool
|
||||
Reference in New Issue
Block a user