Metadata-Version: 2.5
Name: flexible-unet-mlx
Version: 0.2.2
Summary: Native FP32 MLX FlexibleUNet released-checkpoint network
Author: Joseph Sandoval, Alfredo Sandoval Jr.
License-Expression: Apache-2.0
License-File: LICENSE
License-File: THIRD_PARTY_NOTICES.md
Classifier: Operating System :: MacOS :: MacOS X
Requires-Python: <3.15,>=3.13
Requires-Dist: medmlx-core==0.2.4
Requires-Dist: numpy<3,>=2.0
Requires-Dist: pillow<14,>=13
Provides-Extra: conversion
Requires-Dist: torch<2.14,>=2.13; extra == 'conversion'
Provides-Extra: dev
Requires-Dist: hypothesis<7,>=6.140; extra == 'dev'
Requires-Dist: mlx==0.32.4; (platform_machine == 'arm64' and sys_platform == 'darwin') and extra == 'dev'
Requires-Dist: pyright==1.1.414; extra == 'dev'
Requires-Dist: pytest<10,>=8.4; extra == 'dev'
Requires-Dist: ruff<1,>=0.13; extra == 'dev'
Requires-Dist: safetensors<1,>=0.6; extra == 'dev'
Requires-Dist: torch<2.14,>=2.13; extra == 'dev'
Description-Content-Type: text/markdown

# flexible-unet-mlx

Segment surgical tools in RGB endoscopy frames with FlexibleUNet and native MLX.

[Docs](https://github.com/MedMLX/flexible-unet-mlx/blob/main/docs/technical.md) · [MedMLX](https://github.com/MedMLX)

![flexible-unet-mlx example output](https://raw.githubusercontent.com/MedMLX/flexible-unet-mlx/main/docs/example.jpg)

*Predicted tool mask (yellow) and reference outline (dashed) on a Kvasir-Instrument endoscopy frame.*

| Input | Output |
| :--- | :--- |
| RGB image | Tool mask at the original size |

**Apple Silicon · Metal · Python 3.13 / 3.14** · [uv](https://docs.astral.sh/uv/)

## Quick start

```bash
uv venv --python 3.13
source .venv/bin/activate
uv pip install "flexible-unet-mlx[conversion]" huggingface-hub
```

Download and convert the checkpoint once, then run:

```python
from pathlib import Path

from huggingface_hub import hf_hub_download
from flexible_unet_mlx import convert_checkpoint
from flexible_unet_mlx.medmlx import run

checkpoint = hf_hub_download("MONAI/endoscopic_tool_segmentation", "models/model.pt")
convert_checkpoint(Path(checkpoint), Path("model.safetensors"))

result = run(image_path="frame.jpg", weights_path="model.safetensors", output_dir="out")
print(result["outputs"]["mask"])
```

## License

[Apache-2.0](https://github.com/MedMLX/flexible-unet-mlx/blob/main/LICENSE). See [third-party notices](https://github.com/MedMLX/flexible-unet-mlx/blob/main/THIRD_PARTY_NOTICES.md). Model weights retain their publisher terms.

For research and education. Outputs require human review.
