From 61a84d41224fe191ee4e5616b3657122aaa072b4 Mon Sep 17 00:00:00 2001 From: Paul Guerrie Date: Wed, 17 May 2023 13:47:28 +0000 Subject: [PATCH] Added the `local` parameter functionality to instance segmentation giving the ability to infer using a local inference server instead of the hosted endpoint. --- roboflow/__init__.py | 2 +- roboflow/core/version.py | 1 + roboflow/models/instance_segmentation.py | 11 +++++++++-- 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/roboflow/__init__.py b/roboflow/__init__.py index 25541138..8aee5613 100644 --- a/roboflow/__init__.py +++ b/roboflow/__init__.py @@ -12,7 +12,7 @@ from roboflow.core.workspace import Workspace from roboflow.util.general import write_line -__version__ = "1.0.8" +__version__ = "1.0.9" def check_key(api_key, model, notebook, num_retries=0): diff --git a/roboflow/core/version.py b/roboflow/core/version.py index 8be76ca6..fdc573ab 100644 --- a/roboflow/core/version.py +++ b/roboflow/core/version.py @@ -120,6 +120,7 @@ def __init__( self.id, colors=self.colors, preprocessing=self.preprocessing, + local=local, ) elif self.type == TYPE_SEMANTIC_SEGMENTATION: self.model = SemanticSegmentationModel(self.__api_key, self.id) diff --git a/roboflow/models/instance_segmentation.py b/roboflow/models/instance_segmentation.py index bcb98f8f..135fe418 100644 --- a/roboflow/models/instance_segmentation.py +++ b/roboflow/models/instance_segmentation.py @@ -3,13 +3,20 @@ class InstanceSegmentationModel(InferenceModel): - def __init__(self, api_key, version_id, colors=None, preprocessing=None): + def __init__( + self, api_key, version_id, colors=None, preprocessing=None, local=None + ): """ :param api_key: Your API key (obtained via your workspace API settings page) :param version_id: The ID of the dataset version to use for predicting """ super(InstanceSegmentationModel, self).__init__(api_key, version_id) - self.api_url = f"{INSTANCE_SEGMENTATION_URL}/{self.dataset_id}/{self.version}" + if local is None: + self.api_url = ( + f"{INSTANCE_SEGMENTATION_URL}/{self.dataset_id}/{self.version}" + ) + else: + self.api_url = f"{local}/{self.dataset_id}/{self.version}" self.colors = {} if colors is None else colors self.preprocessing = {} if preprocessing is None else preprocessing