What Is Instance Segmentation?
Instance segmentation, also known as image segmentation, is the computer vision task of recognizing objects in images along with their associated shape. In other words, it is the outline of a given object.
It also includes a bounding box surrounding the object in addition to its outline, which when annotating, is used by labeling with polygons.
When should I use it?
You should use instance segmentation for when you need to measure the size of detected objects, cut them out of their background, or more accurately detect oblong rotated objects. With instance segmentation, your application can determine the number of objects in an image, the classifications, and their outline.
Train
You can now train an Instance Segmentation project within Roboflow itself from the pre-trained COCO checkpoint, or export as COCO Segmentation or YOLOv5 Oriented Bounding Boxes.
Inference
You can infer your instance segmentation model via RF Widget , curl command, example web app, or one of our code samples (available in different languages) in your application.
Use the code example below to infer with multi part forms in Python.
pip install requests pillow
pip install requests_toolbelt
import io
import cv2
import requests
from PIL import Image
from requests_toolbelt.multipart.encoder import MultipartEncoder
# Load Image with PIL
img = cv2.imread("/Users/wolf/Downloads/P7.jpg")
image = cv2.cvtColor(img, cv2.COLOR_BGR2RGB)
pilImage = Image.fromarray(image)
# Convert to JPEG Buffer
buffered = io.BytesIO()
pilImage.save(buffered, quality=100, format="JPEG")
# Build multipart form and post request
m = MultipartEncoder(fields={'file': ("imageToUpload", buffered.getvalue(), "image/jpeg")})
response = requests.post("https://detect.roboflow.com/your-model/your-model-version?api_key=your-api-key", data=m, headers={'Content-Type': m.content_type})
print(response)
print(response.json())
Try it today!
To get started, log in to your Roboflow account, create a new project, and choose the Instance Segmentation project type.
Reach out to us on https://discuss.roboflow.com/ to share your project with the community!
Cite this Post
Use the following entry to cite this post in your research:
Kelly M.. (May 19, 2022). Launch: Instance Segmentation Project Training and Inference. Roboflow Blog: https://blog.roboflow.com/instance-segmentation-training-roboflow/
Discuss this Post
If you have any questions about this blog post, start a discussion on the Roboflow Forum.