Skip to main content

sam3-mlx

Segment images from text and geometric prompts with an unofficial native MLX port of SAM 3.

Input Output
Image + text, boxes or points Masks, boxes and confidence scores

Apple Silicon · Metal · Python 3.13+ · uv

Quick start

uv venv --python 3.13
source .venv/bin/activate
export MLX_ENABLE_TF32=0

uv pip install "sam3-mlx==0.2.0"

Set MLX_ENABLE_TF32=0 before starting Python to use full FP32 matrix and attention operations; MLX otherwise may use reduced precision on supported GPUs. The builders also default an unset MLX_ENABLE_TF32 to 0 and check for an incompatible already-initialized MLX process.

Pass a local native MLX .safetensors image checkpoint file through checkpoint_path in the lower-level builder. Omitting that argument downloads preconverted image weights from a pinned mlx-community/sam3-image revision on Hugging Face. Official PyTorch .pt/.pth checkpoints require conversion before loading.

from sam3_mlx import build_sam3_image_model
from sam3_mlx.model.sam3_image_processor import Sam3Processor

model = build_sam3_image_model(checkpoint_path="weights/model.safetensors")
processor = Sam3Processor(model, resolution=1008)

state = processor.set_image("image.jpg")
state = processor.set_text_prompt("shoe", state)

masks, boxes, scores = state["masks"], state["boxes"], state["scores"]

Use a resolution divisible by 14. Selected-frame video runs each frame independently.

MedMLX runner

The registered runner uses the common optional weights-folder interface:

from sam3_mlx.medmlx import run

result = run(image_path="image.png", text_prompt="lesion", output_dir="outputs")

Omitting weights_path downloads the pinned mlx-community/sam3-image snapshot through the MedMLX cache. For offline use, pass a weights_path folder containing model.safetensors. The loader checks the actual tensors; no conversion manifest is required. details.weights_revision records the downloaded Hub revision, or null for a supplied folder without a revision record. The lower-level builder's explicit checkpoint-file API above remains available.

License

The SAM License and third-party notices are included in the distribution. This unofficial port is not affiliated with Meta. Checkpoints have separate access terms.

For research and education. Outputs require human review.

Metadata

Release files for sam3-mlx 0.2.0

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

Source distribution (sdist)

Source distribution for sam3-mlx 0.2.0
File Size Uploaded Provenance Actions
sam3_mlx-0.2.0.tar.gz 1.6 MB Without provenance Details for sam3_mlx-0.2.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for sam3-mlx 0.2.0
File Interpreter ABI Platform Actions
sam3_mlx-0.2.0-py3-none-any.whl Python 3 none any Details for sam3_mlx-0.2.0-py3-none-any.whl

Total release size: 3.2 MB

Release files / sam3_mlx-0.2.0.tar.gz

Download URL sam3_mlx-0.2.0.tar.gz
Size 1.6 MB
Tags Source
SHA-256 checksum
How to use checksums
61750d08669da45aa5718257b5e9fb7e49571c7b63af0d9d08ab7bb03b6adcc7
BLAKE2b-256 checksum
How to use checksums
53adbb44c8d4993352bb01ef794f4a4fc6bcf7bf71ee2c8797278a957cff3971
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.13.5 {"installer":{"name":"uv","version":"0.13.5","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Release files / sam3_mlx-0.2.0-py3-none-any.whl

Download URL sam3_mlx-0.2.0-py3-none-any.whl
Size 1.6 MB
Tags Python 3
SHA-256 checksum
How to use checksums
b12837269bbdced4d461c9634cb783d667ac7b8ad7f94f6b5a2e98823c154e45
BLAKE2b-256 checksum
How to use checksums
113b8954cdec1cf2e1077de651211be317a1acfb52dc9a18cc3da90f12465f66
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.13.5 {"installer":{"name":"uv","version":"0.13.5","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Security for sam3-mlx 0.2.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

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