Detection Engine
app.infrastructure.detection.engine.detection_engineApplication-facing model loading and frame-detection delegation.
The engine selects a provider through
load_detection_model
and returns that provider's results directly. Preprocessing, inference, and
conversion to domain results belong to the
BaseDetectionModel
implementation, not this wrapper.
Layer: Infrastructure. Context: Implements concrete processing and I/O behind application-facing contracts.
DetectionEngine
Manage one model instance and delegate synchronous frame inference to it.
The generated API page lists registered model names. Model construction and inference run in the calling thread; application workers are responsible for keeping expensive operations off the GUI thread. This wrapper adds no synchronization or result copying.
Provider requirements
Real models may load or acquire weights and require compatible runtimes or hardware. Input handling and inference-failure behavior are provider-specific; some providers log failures and return an empty list.
Examples:
Given a NumPy frame prepared for the selected provider:
from app.infrastructure.detection.engine.detection_engine import DetectionEngine
engine = DetectionEngine("YOLOv8n")
detections = engine.detect(frame)
engine.set_model("YOLOv8s")
This illustrative example may require model weights; documentation builds do not execute it.
model_name: str
property
Return the last model name assigned during initialization or switching.
| RETURNS | DESCRIPTION |
|---|---|
str
|
Requested model name. After a failed switch, it can differ from |
str
|
the name associated with the retained model instance. |
__init__(model_name: str) -> None
| PARAMETER | DESCRIPTION |
|---|---|
model_name
|
Registered model name, or
TYPE:
|
| RAISES | DESCRIPTION |
|---|---|
DetectionModelError
|
If the name is not registered. |
Provider construction errors propagate without translation.
detect(frame: np.ndarray) -> list[DetectionResult]
Delegate one frame to the current provider without label selection.
| PARAMETER | DESCRIPTION |
|---|---|
frame
|
Image array prepared for the selected provider. The model interface describes RGB input; this wrapper does not validate shape, dtype, channel order, or copy the array.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
list[DetectionResult]
|
The provider's list of |
list[DetectionResult]
|
|
list[DetectionResult]
|
objects, unchanged and without an additional copy. An empty list |
list[DetectionResult]
|
may mean no detections or a failure handled by the provider. |
Errors not handled by the provider propagate to the caller. This wrapper does not guarantee that inference leaves the supplied array unchanged.
set_model(model_name: str) -> None
Switch to a different detection model by model_name.
| PARAMETER | DESCRIPTION |
|---|---|
model_name
|
Registered model name, or
TYPE:
|
| RAISES | DESCRIPTION |
|---|---|
DetectionModelError
|
If the name is not registered. |
Provider construction errors also propagate.
A failed switch is not atomic
The name is assigned before loading. If loading fails, the previous
model instance remains active but model_name reports the requested
name. This method does not roll back the name or coordinate concurrent
inference.
Supported models
This catalog is auto-generated from app.infrastructure.detection.model.names.
TorchVision
Torch FCOS_ResNet50_FPNTorch FasterRCNN_MobileNet_V3_Large_320_FPNTorch FasterRCNN_MobileNet_V3_Large_FPNTorch FasterRCNN_ResNet50_FPN_V2Torch FasterRCNN_ResNet50_FPNTorch RetinaNet_ResNet50_FPN_V2Torch RetinaNet_ResNet50_FPNTorch SSD300_VGG16Torch SSDLite320_MobileNet_V3_Large
Ultralytics YOLO
YOLOv3-tinyYOLOv3YOLOv3-sppYOLOv5nYOLOv5sYOLOv5mYOLOv5lYOLOv5xYOLOv8nYOLOv8sYOLOv8mYOLOv8lYOLOv8xYOLOv9tYOLOv9sYOLOv9mYOLOv9cYOLOv9eYOLOv10nYOLOv10sYOLOv10mYOLOv10bYOLOv10lYOLOv10xYOLO11nYOLO11sYOLO11mYOLO11lYOLO11xYOLO12nYOLO12sYOLO12mYOLO12lYOLO12xYOLOv26nYOLOv26sYOLOv26mYOLOv26lYOLOv26x
MTCNN
MTCNN-TensorflowMTCNN-Pytorch