Skip to main content

SamTool is a Python library designed for easy integration of the SAM (Segment Anything with Masking) model into computer vision projects. SAM is a state-of-the-art model for segmenting objects in images with high accuracy.

Project description


SamTool

SamTool is a Python library designed for easy integration of the SAM (Segment Anything with Masking) model into computer vision projects. SAM is a state-of-the-art model for segmenting objects in images with high accuracy.

Installation

You can install SamTool via pip:

pip install samtool

Usage

Initializing SamTool

from samtool import Sam

# Initialize SamTool with the path to the SAM model file
sam = Sam(sam_file='path/to/sam_model.pth')

Predicting Masks

# Read an image
image = Sam.read_image('path/to/image.jpg')

# Generate masks for the entire image
masks, scores, logits = sam.predict(image)

# Display masks overlaid on the input image
sam.show_masks(masks, image, boxes=True, points=True)

Using Prompt for Segmentation

# Define a prompt (specific location to identify instead of the whole image)
prompt = [input_point, input_label, multimask_output]

# Generate masks based on the prompt
masks, scores, logits = sam.predict(image, prompt=prompt)

License

This project is licensed under the MIT License - see the LICENSE file for details.

Acknowledgments

  • Facebook Segment Anything: github

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

samtool-0.0.2.tar.gz (4.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

samtool-0.0.2-py3-none-any.whl (4.8 kB view details)

Uploaded Python 3

File details

Details for the file samtool-0.0.2.tar.gz.

File metadata

  • Download URL: samtool-0.0.2.tar.gz
  • Upload date:
  • Size: 4.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/5.0.0 CPython/3.12.3

File hashes

Hashes for samtool-0.0.2.tar.gz
Algorithm Hash digest
SHA256 e0a0b8c26e3eef27f7f1141cd4e9a3dd1052171750a6e7743fe7093bd7f68bf1
MD5 9469fdd40e2d338248de29fa85b1c0ac
BLAKE2b-256 24c4f550cfa5962e0c54bcf8bb6f008d7883ba01ace9f9e0a001ab3615d7350c

See more details on using hashes here.

File details

Details for the file samtool-0.0.2-py3-none-any.whl.

File metadata

  • Download URL: samtool-0.0.2-py3-none-any.whl
  • Upload date:
  • Size: 4.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/5.0.0 CPython/3.12.3

File hashes

Hashes for samtool-0.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 b1890ff3a827457c9eadbc1183f0c801e41ae50a9a02af5f9b2d1e46f192c995
MD5 a529d34d5c2bacff0b656fb035a2f9b6
BLAKE2b-256 40d0b4f7ccceaef4d387cb537c7a4a306f9c0c1fb0d5d46ce862d9177a68a5c9

See more details on using hashes here.

Supported by

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