Segmentation is the computer vision task of identifying the pixel level boundary or mask of an object in an image.
Practical uses of computer assisted segmentation include:
Faster photo and video editing
More accurate image processing in a wide variety of fields including medicine, manufacturings and autonomous machines
Ability to train machine vision models faster and cheaper by simplifying image labeling workflows.
An example of image segmentation:
Key Ideas
Meta AI Research has developed a foundation model called the Segment Anything Model or SAM that makes high quality, zero shot segmentation masks on unfamiliar objects and images.
The model was trained on over a billion segmentation masks across ~11 million images.
SAM uses PyTorch and the model can take advantage of GPU hardware acceleration.
OpenCV can be used to draw mask information and blend masks with the original picture
Getting the Code
Learn more about image segmentation by visiting the ML Reference Designs GitHub repository.
Set up instructions https://github.com/ccozad/ml-reference-designs/blob/master/computer-vision/SAM/README.md
Example code that shows how to generate segmentation masks: https://github.com/ccozad/ml-reference-designs/blob/master/computer-vision/SAM/sam_test.py
If the code helps you please give the repo a star or leave a comment here.
Resources
Background and capabilities of the Segment Anything Model
Model source code for the Segment Anything Model https://github.com/facebookresearch/segment-anything
Adding (blending) two images in OpenCV https://docs.opencv.org/4.x/d5/dc4/tutorial_adding_images.html