Roboflow Model¶
sahi.models.roboflow
¶
Roboflow detection model wrapper for SAHI.
Provides integration with Roboflow's inference SDK for object detection and instance segmentation models.
Classes¶
RoboflowDetectionModel
¶
RoboflowDetectionModel(
model: object | None = None,
model_path: str | None = None,
config_path: str | None = None,
device: str | None = None,
mask_threshold: float = 0.5,
confidence_threshold: float = 0.3,
category_mapping: dict | None = None,
category_remapping: dict | None = None,
load_at_init: bool = True,
image_size: int | None = None,
api_key: str | None = None,
)
Bases: DetectionModel
Roboflow object detection model.
Supports both Roboflow Universe models (API-based) and local RF-DETR models.
Initialize the RoboflowDetectionModel with the given parameters.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
|
object | None
|
object Either a Roboflow model string identifier or an RF-DETR model class. |
None
|
|
str | None
|
str Roboflow API key for authentication. |
None
|
|
str | None
|
str Path for the instance segmentation model weight |
None
|
|
str | None
|
str Path for the mmdetection instance segmentation model config file |
None
|
|
str | None
|
Torch device, "cpu", "mps", "cuda", "cuda:0", "cuda:1", etc. |
None
|
|
float
|
float Value to threshold mask pixels, should be between 0 and 1 |
0.5
|
|
float
|
float All predictions with score < confidence_threshold will be discarded |
0.3
|
|
dict | None
|
dict: str to str Mapping from category id (str) to category name (str) e.g. {"1": "pedestrian"} |
None
|
|
dict | None
|
dict: str to int Remap category ids based on category names, after performing inference e.g. {"car": 3} |
None
|
|
bool
|
bool If True, automatically loads the model at initialization |
True
|
|
int | None
|
int Inference input size. |
None
|
Source code in sahi/models/roboflow.py
Attributes¶
Methods:¶
set_model
¶
load_model
¶
Load detection model from Roboflow.
This function initializes detection model and sets to self.model. Uses self.model_path, self.config_path, and self.device.
Source code in sahi/models/roboflow.py
perform_inference
¶
perform_inference(image: ndarray) -> None
Run inference on image and store predictions.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
image
¶ |
ndarray
|
np.ndarray A numpy array that contains the image to be predicted. |
required |