Skip to main content
https://img.shields.io/pypi/v/segmate.svg Documentation Status License

This repository is a toolkit for using the Segment Anything Model (SAM) developed by Meta AI. It is capable of accurately “cutting out” any object from an image with just a single click.

SAM is a promptable segmentation system that exhibits zero-shot generalization to unfamiliar objects and images, eliminating the need for additional training. By providing prompts that specify what needs to be segmented in an image, SAM can perform a wide range of segmentation tasks without requiring additional training.

Features

  • Easy inference with SAM, supporting bounding boxes, points, masks, and text prompts

  • Automatic mask generation

  • Finetune SAM on custom datasets

  • GroundingDINO integration for text prompt segmentation

  • Training a custom decoder to auto segment a specific type of object

  • Training a prompt embedding to auto segment a specific type of object

Installation

First, install groundingdino from its repository, this is a dependency for segmate:

NOTE: There is an issue with the setup script in the GroundingDINO repository causing it not able to install torch properly, please manually install PyTorch for now. For other issues, refer to the installation guide:

pip install -U git+https://github.com/IDEA-Research/GroundingDINO.git

Then, install segmate from PyPI:

pip install segmate

Example Usage

To use the provided code snippets, follow the steps below:

  1. Import the required modules and initialize the necessary objects:

import torch

from segmate.segmenter import SAM
from segmate.object_detector import GroundingDINO
import segmate.utils as utils

# Model checkpoint path for GroundingDINO is optional. If no path provided, it will download from HuggingFace
od = GroundingDINO(device='cuda', ckpt_path='PATH_TO_CHECKPOINT')
sm = SAM(model_type='MODEL_TYPE', checkpoint='PATH_to_CHECKPOINT', device='cuda')
  1. Perform segmentation with bounding box prompts:

masks = sm.segment(image=input_image, boxes_prompt=bbox)
utils.show_masks(image, masks)

Documentation

Detailed package documentation: SegMate Docs

If you have any questions or need assistance, please don’t hesitate to reach out to our support team or join our community forum. We hope you find this toolkit valuable and look forward to seeing the incredible applications you create with SAM!

License

The code in this repository is published under 3-Clause BSD license (see LICENSE file).

Release files for segmate 0.3.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for segmate 0.3.1
File Size Uploaded
segmate-0.3.1.tar.gz 24.3 MB Details

Built distribution (wheel)

Table of built distributions (wheels) for segmate 0.3.1
File Interpreter ABI Platform
segmate-0.3.1-py3-none-any.whl Python 3 none any Details

Total release size: 24.3 MB

Release files / segmate-0.3.1.tar.gz

Download URL segmate-0.3.1.tar.gz
Size 24.3 MB
Tags Source
SHA-256 checksum
How to use checksums
0cc66ea5a06454b826251c498e4d256ef3f3b34610f5a13c7fc4ebf2910e84fd
BLAKE2b-256 checksum
How to use checksums
bf4509eead9cfa24931a2a6ef80a9514675748238e7a5411b24ac79a644bbf66
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.9.13

Release files / segmate-0.3.1-py3-none-any.whl

Download URL segmate-0.3.1-py3-none-any.whl
Size 13.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
68f83c4fa30f805741dec0fe0dd1abba0e4b42498bfe1447889fd709b9c90050
BLAKE2b-256 checksum
How to use checksums
83081e6a5ceb78d5d3ed35c93c253f81f05950199c5e30e3cfc7d703af0e0d1a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.9.13

Release history Release notifications | RSS feed

This release

0.3.1 This release

2 release files

0.3.0

2 release files

0.2.0

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page