Skip to main content

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

Metadata

Release files for samtool 0.0.2

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

Source distribution (sdist)

Source distribution for samtool 0.0.2
File Size Uploaded
samtool-0.0.2.tar.gz 4.4 kB Details

Built distribution (wheel)

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

Total release size: 9.2 kB

Release files / samtool-0.0.2.tar.gz

Download URL samtool-0.0.2.tar.gz
Size 4.4 kB
Tags Source
SHA-256 checksum
How to use checksums
e0a0b8c26e3eef27f7f1141cd4e9a3dd1052171750a6e7743fe7093bd7f68bf1
BLAKE2b-256 checksum
How to use checksums
24c4f550cfa5962e0c54bcf8bb6f008d7883ba01ace9f9e0a001ab3615d7350c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/5.0.0 CPython/3.12.3

Release files / samtool-0.0.2-py3-none-any.whl

Download URL samtool-0.0.2-py3-none-any.whl
Size 4.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
b1890ff3a827457c9eadbc1183f0c801e41ae50a9a02af5f9b2d1e46f192c995
BLAKE2b-256 checksum
How to use checksums
40d0b4f7ccceaef4d387cb537c7a4a306f9c0c1fb0d5d46ce862d9177a68a5c9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/5.0.0 CPython/3.12.3

Release history Release notifications | RSS feed

This release

0.0.2 This release

2 release files

0.0.1

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