What problem does it solve?
This Skill allows users to segment any object in images with zero-shot image segmentation via points, boxes, masks, providing flexibility and ease of use.
Core Features & Use Cases
- Zero-shot Segmentation: Segment objects in any image domain without specific training.
- Flexible Prompts: Use points, bounding boxes, or previous masks for segmentation.
- Automatic Segmentation: Generate all object masks automatically.
- High Quality: Trained on 1.1 billion masks from 11 million images.
- Multiple Model Sizes: Choose between fast (ViT-B) and accurate (ViT-H) models.
- ONNX Export: Deploy segmentation in browsers and edge devices.
- Use Cases: Build object detection/segmentation pipelines, process medical, satellite, or domain-specific images, and generate training data for other vision models.
Quick Start
To segment an object in an image, first install the skill:
pip install git+https://github.com/facebookresearch/segment-anything.git
Then, use the following command:
from segment_anything import sam_model_registry, SamPredictor
sam = sam_model_registry["vit_h"](checkpoint="sam_vit_h_4b8939.pth")
predictor = SamPredictor(sam)
predictor.set_image("image.jpg")
input_point = np.array([[500, 375]])
masks, scores, logits = predictor.predict(point_coords=input_point, point_labels=np.array([1]))