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.1"

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.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 sam3-mlx 0.2.1
File Size Uploaded Provenance Actions
sam3_mlx-0.2.1.tar.gz 1.6 MB Without provenance Details for sam3_mlx-0.2.1.tar.gz

Built distribution (wheel)

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

Total release size: 3.3 MB

Release files / sam3_mlx-0.2.1.tar.gz

Download URL sam3_mlx-0.2.1.tar.gz
Size 1.6 MB
Tags Source
SHA-256 checksum
How to use checksums
cf279d140be57e2b9ee8f05b7d6da83f6184578fbfa207fc2f008a9aeddaf9e3
BLAKE2b-256 checksum
How to use checksums
99700ce51795f356c8e1247293ceddd1d23d18c3cb2868ba61e2cd6cbf4e5c70
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.1-py3-none-any.whl

Download URL sam3_mlx-0.2.1-py3-none-any.whl
Size 1.6 MB
Tags Python 3
SHA-256 checksum
How to use checksums
0f50b9bf2e5afb03939e46ef1a66b1c4c654e1b1a1373e7a7ef3ba4e54e08488
BLAKE2b-256 checksum
How to use checksums
3e565f386a8af3b95af2ee96726b363883f52a877b40f7bf6a820c47959eae45
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.1

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