object_detection_model module
This module defines the ObjectDetectionModel interface, which serves as a base class for any object detection model to be used with this program.
The field of object detection is constantly evolving, with new and improved models emerging frequently. This interface facilitates the integration and testing of such models within the program. Instead of rewriting functionality for each new detector, developers can create subclasses that inherit from ObjectDetectionModel. As long as these subclasses override the __call__ method to handle object detection on a PIL image and return a list of Detection objects, existing code remains compatible.
This approach promotes modularity, flexibility, and future-proofing of the program.
- class object_detection_models.object_detection_model.ObjectDetectionModel
Bases:
ABC
Abstract base class for object detection models.
This class defines the interface that all concrete object detection models must adhere to.
- abstract static from_weights_path(model_weights_path: Path) ObjectDetectionModel
Initializes the ObjectDetectionModel from a path to its weights.
- Parameters:
model_path (Path) – The path to the model’s weights file.
- Raises:
FileNotFoundError – If the filepath does not lead to a file.
- Returns:
An instance of the concrete subclass initialized from the weights.
- Return type:
- abstract static from_model(model) ObjectDetectionModel
Initializes the ObjectDetectionModel from a model object.
- Parameters:
model – An object from another package that performs object detection.
- Returns:
An instance of the concrete subclass initialized from the model.
- Return type: