Instance Segmentation
InstanceSegmentationModel
¶
Bases: InferenceModel
Run inference on a instance segmentation model hosted on Roboflow or served through Roboflow Inference.
Source code in roboflow/models/instance_segmentation.py
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 |
|
__init__(api_key, version_id, colors=None, preprocessing=None, local=None)
¶
Create a InstanceSegmentationModel object through which you can run inference.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
api_key |
str
|
private roboflow api key |
required |
version_id |
str
|
the workspace/project id |
required |
colors |
dict
|
colors to use for the image |
None
|
preprocessing |
dict
|
preprocessing to use for the image |
None
|
local |
bool
|
whether the image is local or hosted |
None
|
Source code in roboflow/models/instance_segmentation.py
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
|
predict(image_path, confidence=40)
¶
Infers detections based on image from a specified model and image path.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
image_path |
str
|
path to the image you'd like to perform prediction on |
required |
confidence |
int
|
confidence threshold for predictions, on a scale from 0-100 |
40
|
Returns:
Type | Description |
---|---|
PredictionGroup Object |
Example
import roboflow
rf = roboflow.Roboflow(api_key="")
project = rf.workspace().project("PROJECT_ID")
model = project.version("1").model
prediction = model.predict("YOUR_IMAGE.jpg")
Source code in roboflow/models/instance_segmentation.py
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 |
|