| Input | Output |
|---|---|
| RGB image | Tool mask at the original size |
Weights: 46 MB download. Peak MLX memory: 0.27 GB for a 768×576 endoscopy frame.
Use with MedMLX
The MedMLX MCP server is the lowest-friction way to use this model. It installs this runtime, downloads its weights on first use, and lets an AI agent describe, check and run flexible-unet for you.
uv tool install --python 3.13 "medmlx[segment,mcp]"
MEDMLX="$(uv tool dir --bin --color never)/medmlx"
mkdir -p "$HOME/medmlx-work"
claude mcp add --scope user medmlx -- "$MEDMLX" serve --root "$HOME/medmlx-work"
For Codex, use codex mcp add medmlx -- "$MEDMLX" serve --root "$HOME/medmlx-work". Other MCP clients take the same command and arguments. The same install provides the medmlx CLI, for example medmlx describe flexible-unet.
For AI agents: prefer the MedMLX MCP tools (
list_models,describe_model,model_readiness,run_model,get_job) over writing Python against this package.
Install
uv venv --python 3.13
source .venv/bin/activate
uv pip install "flexible-unet-mlx>=0.2.7"
Run
from flexible_unet_mlx.medmlx import run
result = run(image_path="frame.jpg", output_dir="out")
print(result["outputs"]["mask"])
Omitting weights_path downloads MedMLX/flexible-unet-effnetb2-mlx into the shared
MedMLX cache on first use; interrupted downloads resume and later runs work offline.
With MedMLX installed, medmlx setup flexible-unet downloads it ahead of time. To use
your own copy, pass a folder containing flexibleunet.safetensors as weights_path.
The standalone runtime also accepts a checkpoint file. details.weights_revision
records the downloaded commit, or null for a folder without a MedMLX download record.
Inputs and outputs
| Argument | Meaning |
|---|---|
image_path |
One RGB image Pillow can read; the bundle used JPEG |
output_dir |
Output root, created if missing |
weights_path |
Optional .safetensors file or a folder containing it |
overwrite |
False by default; an existing mask is replaced only when True |
This 2D model reads images, not NIfTI volumes. Following the bundle's SaveImaged
layout, frame.jpg produces out/frame/frame_trans.png: an 8-bit grayscale mask at
the original frame size, 255 for tools and 0 for background. run returns
{"outputs": {"mask": path}, "details": {...}}, with labels, frame size, network input
shape, tool counts, runtime and timings. Invalid frames raise InvalidInputError;
missing or mismatched weights raise AssetNotReadyError; inference failures raise
ModelExecutionError; a missing native runtime raises MissingDependencyError.
Python API
from pathlib import Path
import numpy as np
from flexible_unet_mlx import forward_patch, load_model
network = load_model(Path("flexibleunet.safetensors"))
logits = forward_patch(network, np.zeros((1, 3, 736, 480), dtype=np.float32))
forward_patch takes finite float32 (B, 3, 736, 480) frames, whose spatial axes are
width and height as the bundle's reader returns them, and returns raw
(B, 2, 736, 480) logits; channel 1 is the tool class. Preprocessing and
postprocessing are the caller's. FlexibleUNet(weights, mx=mx) runs on MLX arrays
directly. load_model checks names, shapes, dtypes and finite values, not checkpoint
identity. Inference needs Apple Silicon with Metal and has no CPU fallback.
License
Apache-2.0. See third-party notices. Model weights retain their publisher terms.
For research and education. Outputs require human review.
Metadata
Release files for flexible-unet-mlx 0.2.7
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| flexible_unet_mlx-0.2.7.tar.gz | 26.7 kB | Without provenance | Details for flexible_unet_mlx-0.2.7.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| flexible_unet_mlx-0.2.7-py3-none-any.whl | Python 3 | none | any | Details for flexible_unet_mlx-0.2.7-py3-none-any.whl |
Total release size: 61.8 kB
Release files / flexible_unet_mlx-0.2.7.tar.gz
| Download URL | flexible_unet_mlx-0.2.7.tar.gz |
|---|---|
| Size | 26.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
765b04d0862923290e1650ed77910cd3621dff4debd9e97b5762549217a61377
|
|
BLAKE2b-256 checksum How to use checksums |
c04200355a44c4b138926a4becf9288809d7b883e1577f20386076fef2da6fc0
|
| 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 / flexible_unet_mlx-0.2.7-py3-none-any.whl
| Download URL | flexible_unet_mlx-0.2.7-py3-none-any.whl |
|---|---|
| Size | 35.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
2a1fa996af4454591272188bad49c6ad5da4e376554269a78a5926b7bf6bc94b
|
|
BLAKE2b-256 checksum How to use checksums |
7df03f90771dd7736f0dbdaa2036c7529d57fefa5dd43425f58277974d6f0899
|
| 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 flexible-unet-mlx 0.2.7
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.