Instance Segmentation

Instance Segmentation1. Model Introduction2. Instance segmentation: imageEffect preview3. Instance segmentation: videoEffect preview4. Instance segmentation: real-time detection4.1. USB cameraEffect preview4.2, CSI cameraEffect previewReferences

Use Python to demonstrate the effects of Ultralytics: Instance Segmentation in images, videos, and real-time detection.

1. Model Introduction

Instance segmentation goes a step further than object detection. It involves identifying individual objects in an image and separating them from the rest of the image.

The output of the instance segmentation model is a set of masks or outlines that outline each object in the image, as well as the class label and confidence score for each object. Instance segmentation is very useful when you need to know not only the location of objects in the image, but also their specific shape.

2. Instance segmentation: image

Use yolo11n-seg.pt to predict the pictures that come with the ultralytics project.

Enter the code folder:

Run the code:

Effect preview

Yolo recognition output image location: /home/pi/ultralytics/ultralytics/output/

image-20241230155959082

Sample code:

3. Instance segmentation: video

Use yolo11n-seg.pt to predict videos under the ultralytics project (not the videos that come with ultralytics).

Enter the code folder:

Run the code:

Effect preview

Video location of yolo recognition output: /home/pi/ultralytics/ultralytics/output/

image-20241230161651694

Sample code:

4. Instance segmentation: real-time detection

4.1. USB camera

Use yolo11n-seg.pt to predict the USB camera screen.

Enter the code folder:

Run the code: Click the preview screen and press the q key to terminate the program!

Effect preview

Yolo recognizes the output video location: /home/pi/ultralytics/ultralytics/output/

image-20241230162518100

Sample code:

4.2, CSI camera

Use yolo11n-seg.pt to predict the CSI camera image.

Enter the code folder:

Run the code: Click the preview image, press the q key to terminate the program!

Effect preview

Yolo recognizes the output video location: /home/pi/ultralytics/ultralytics/output/

image-20241230163136085

Sample code:

References

https://docs.ultralytics.com/tasks/segment/