flexible-unet-mlx
Native MLX port of the MONAI endoscopic tool segmentation model (FlexibleUNet, EfficientNet-B2) for Apple Silicon. Segment surgical tools in endoscopy frames, locally on Mac.
- RGB endoscopy frame in, tool mask out
- Apple Silicon GPU acceleration
- FP32 inference using MLX; PyTorch is only needed once to convert the checkpoint
Part of MedMLX. Technical notes
Quick start · Input and output · Technical details · License
Requirements
Apple Silicon Mac with Metal, Python 3.13 or 3.14 and uv.
Quick start
Install with the conversion extra, and install the Hugging Face CLI as a separate tool for downloading the checkpoint:
uv pip install "flexible-unet-mlx[conversion] @ git+https://github.com/MedMLX/flexible-unet-mlx.git"
uv tool install huggingface-hub
Download the MONAI checkpoint:
hf download MONAI/endoscopic_tool_segmentation models/model.pt \
--revision f0416a27d59516d9c1b6bec5181c9c33002c84fa --local-dir tool-bundle
Convert it once, then segment a frame:
from pathlib import Path
from flexible_unet_mlx import convert_checkpoint
from flexible_unet_mlx.medmlx import run
convert_checkpoint(Path("tool-bundle/models/model.pt"), Path("model.safetensors"))
result = run(image_path="frame.jpg", weights_path="model.safetensors", output_dir="out")
print(result["outputs"]["mask"])
Pass overwrite=True to replace existing output. The model is also discoverable by
medmlx as flexible-unet.
Input and output
Input is one RGB image Pillow can read (the bundle used JPEG frames).
For frame.jpg, the mask is written to out/frame/frame_trans.png: 8-bit grayscale
at the original frame size, 255 for tool and 0 for background. result["details"]
holds the frame size, tool pixel counts and timings.
Technical details
Preprocessing, inference and postprocessing follow the pinned MONAI 1.4.0 bundle, including Torch's bilinear resize rounding. The tests compare against recordings of the upstream transforms and network made on one Apple Silicon Mac, using synthetic frames and seeded random weights. Agreement with the released checkpoint is a separate, optional check, and no segmentation accuracy evaluation is included. The lower-level network API, tolerances and fixture regeneration are in docs/technical.md.
Intended use
Intended for research and education, not clinical decisions. Outputs require human review.
License
Code: Apache-2.0; see LICENSE. MONAI-derived code is Apache-2.0; see third-party notices. Checkpoint rights remain with their publishers.
Implementation mapping
Central implementation map records upstream-to-native changes, source references and qualification scope.
Metadata
Release files for flexible-unet-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)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| flexible_unet_mlx-0.2.1.tar.gz | 23.4 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| flexible_unet_mlx-0.2.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 55.0 kB
Release files / flexible_unet_mlx-0.2.1.tar.gz
| Download URL | flexible_unet_mlx-0.2.1.tar.gz |
|---|---|
| Size | 23.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
3665efb16db4dcd4e2794c51ee70075a75d33fd1d108a887d12ca744fba9f4ba
|
|
BLAKE2b-256 checksum How to use checksums |
8b26258020562c5b5fdba05ec5b6a664212bbb968f6840bad3b36663e58ff5ef
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.17
|
Release files / flexible_unet_mlx-0.2.1-py3-none-any.whl
| Download URL | flexible_unet_mlx-0.2.1-py3-none-any.whl |
|---|---|
| Size | 31.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
1e1efd8772d0ad333d409579c579eca663df6df0206cc6b05ea9d16a78eb1711
|
|
BLAKE2b-256 checksum How to use checksums |
7d8949bc1b43b0137d38ca24cc81d54595079468176e972e741d8673232e16b9
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.17
|
Security for flexible-unet-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.