Skip to main content

SegMate package

Project description

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).

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

segmate-0.3.1.tar.gz (24.3 MB view details)

Uploaded Source

Built Distribution

segmate-0.3.1-py3-none-any.whl (13.4 kB view details)

Uploaded Python 3

File details

Details for the file segmate-0.3.1.tar.gz.

File metadata

  • Download URL: segmate-0.3.1.tar.gz
  • Upload date:
  • Size: 24.3 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.13

File hashes

Hashes for segmate-0.3.1.tar.gz
Algorithm Hash digest
SHA256 0cc66ea5a06454b826251c498e4d256ef3f3b34610f5a13c7fc4ebf2910e84fd
MD5 2c006257ebf56e1ca7158ce6102dbf79
BLAKE2b-256 bf4509eead9cfa24931a2a6ef80a9514675748238e7a5411b24ac79a644bbf66

See more details on using hashes here.

File details

Details for the file segmate-0.3.1-py3-none-any.whl.

File metadata

  • Download URL: segmate-0.3.1-py3-none-any.whl
  • Upload date:
  • Size: 13.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.13

File hashes

Hashes for segmate-0.3.1-py3-none-any.whl
Algorithm Hash digest
SHA256 68f83c4fa30f805741dec0fe0dd1abba0e4b42498bfe1447889fd709b9c90050
MD5 ff3ff4f4b37d4247600872847e06a942
BLAKE2b-256 83081e6a5ceb78d5d3ed35c93c253f81f05950199c5e30e3cfc7d703af0e0d1a

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page