Python API Reference¶
- class opendetect.Detector(model='rfdetr-m', *, model_path=None, input_size=None, hardware_acceleration=True, tensor_rt=False, mixed_precision=False, threshold=0.3, num_select=300, class_ids=None, auto_download=True, cache_dir=None, show_download_progress=False)[source]¶
Bases:
object- Parameters:
model (str)
model_path (str | Path | None)
input_size (tuple[int, int] | None)
hardware_acceleration (bool)
tensor_rt (bool)
mixed_precision (bool)
threshold (float)
num_select (int)
class_ids (list[int] | None)
auto_download (bool)
cache_dir (str | Path | None)
show_download_progress (bool)
- property backend: DetectorModel¶
- property class_names: list[str] | None¶
- set_class_filter(class_ids)[source]¶
- Parameters:
class_ids (list[int] | None)
- Return type:
list[int] | None
- predict(image, *, color='bgr')[source]¶
- Parameters:
image (numpy.ndarray)
color (str)
- Return type:
dict[str, numpy.ndarray]
- annotate(image, detections=None, *, color='bgr')[source]¶
- Parameters:
image (numpy.ndarray)
detections (dict[str, numpy.ndarray] | None)
color (str)
- Return type:
numpy.ndarray
- predict_and_annotate(image, *, color='bgr')[source]¶
- Parameters:
image (numpy.ndarray)
color (str)
- Return type:
tuple[dict[str, numpy.ndarray], numpy.ndarray]
- class opendetect.LoadedModelInfo(model_id: 'str | None', implementation: 'str', input_size: 'tuple[int, int]', model_path: 'Path', source: 'str')[source]¶
Bases:
object- Parameters:
model_id (str | None)
implementation (str)
input_size (tuple[int, int])
model_path (Path)
source (str)
- model_id: str | None¶
- implementation: str¶
- input_size: tuple[int, int]¶
- model_path: Path¶
- source: str¶
- class opendetect.ModelSpec(model_id: 'str', implementation: 'str', input_size: 'tuple[int, int]', artifact_path: 'str', aliases: 'tuple[str, ...]' = (), description: 'str' = '', base_url: 'str | None' = None)[source]¶
Bases:
object- Parameters:
model_id (str)
implementation (str)
input_size (tuple[int, int])
artifact_path (str)
aliases (tuple[str, ...])
description (str)
base_url (str | None)
- model_id: str¶
- implementation: str¶
- input_size: tuple[int, int]¶
- artifact_path: str¶
- aliases: tuple[str, ...] = ()¶
- description: str = ''¶
- base_url: str | None = None¶
- property filename: str¶
- opendetect.download_model(model, *, cache_dir=None, force=False, show_progress=True, timeout_sec=60)[source]¶
- Parameters:
model (str | ModelSpec)
cache_dir (Path | str | None)
force (bool)
show_progress (bool)
timeout_sec (int)
- Return type:
Path
- opendetect.model_url(spec, base_url=None)[source]¶
- Parameters:
spec (ModelSpec)
base_url (str | None)
- Return type:
str
Detector¶
- class opendetect.detector.Detector(model='rfdetr-m', *, model_path=None, input_size=None, hardware_acceleration=True, tensor_rt=False, mixed_precision=False, threshold=0.3, num_select=300, class_ids=None, auto_download=True, cache_dir=None, show_download_progress=False)[source]¶
Bases:
object- Parameters:
model (str)
model_path (str | Path | None)
input_size (tuple[int, int] | None)
hardware_acceleration (bool)
tensor_rt (bool)
mixed_precision (bool)
threshold (float)
num_select (int)
class_ids (list[int] | None)
auto_download (bool)
cache_dir (str | Path | None)
show_download_progress (bool)
- property backend: DetectorModel¶
- property class_names: list[str] | None¶
- set_class_filter(class_ids)[source]¶
- Parameters:
class_ids (list[int] | None)
- Return type:
list[int] | None
- predict(image, *, color='bgr')[source]¶
- Parameters:
image (numpy.ndarray)
color (str)
- Return type:
dict[str, numpy.ndarray]
- annotate(image, detections=None, *, color='bgr')[source]¶
- Parameters:
image (numpy.ndarray)
detections (dict[str, numpy.ndarray] | None)
color (str)
- Return type:
numpy.ndarray
- predict_and_annotate(image, *, color='bgr')[source]¶
- Parameters:
image (numpy.ndarray)
color (str)
- Return type:
tuple[dict[str, numpy.ndarray], numpy.ndarray]
Registry and Download¶
- class opendetect.registry.ModelSpec(model_id: 'str', implementation: 'str', input_size: 'tuple[int, int]', artifact_path: 'str', aliases: 'tuple[str, ...]' = (), description: 'str' = '', base_url: 'str | None' = None)[source]¶
Bases:
object- Parameters:
model_id (str)
implementation (str)
input_size (tuple[int, int])
artifact_path (str)
aliases (tuple[str, ...])
description (str)
base_url (str | None)
- model_id: str¶
- implementation: str¶
- input_size: tuple[int, int]¶
- artifact_path: str¶
- aliases: tuple[str, ...] = ()¶
- description: str = ''¶
- base_url: str | None = None¶
- property filename: str¶
- opendetect.registry.model_url(spec, base_url=None)[source]¶
- Parameters:
spec (ModelSpec)
base_url (str | None)
- Return type:
str
- opendetect.registry.default_model_id(implementation)[source]¶
- Parameters:
implementation (str)
- Return type:
str