Metadata-Version: 2.5
Name: swin-unetr-mlx
Version: 0.2.2
Summary: Native FP32 MLX SwinUNETR for macOS Apple Silicon with Metal
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: nibabel<6,>=5.3
Requires-Dist: numpy<3,>=2.0
Requires-Dist: simpleitk<3,>=2.4
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: pyright==1.1.414; extra == 'dev'
Requires-Dist: pytest<10,>=8.4; extra == 'dev'
Requires-Dist: ruff<1,>=0.13; extra == 'dev'
Requires-Dist: torch<2.14,>=2.13; extra == 'dev'
Description-Content-Type: text/markdown

# swin-unetr-mlx

Segment 13 abdominal organs in CT with MONAI SwinUNETR and native MLX.

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

![Abdominal CT → multi-organ segmentation.](https://raw.githubusercontent.com/MedMLX/swin-unetr-mlx/main/docs/showcase.png)

*Abdominal CT → multi-organ segmentation.*

| Input | Output |
| :--- | :--- |
| 3D abdominal CT · NIfTI | Organ mask on the input grid |

**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 "swin-unetr-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 swin_unetr_mlx import convert_checkpoint
from swin_unetr_mlx.medmlx import run

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

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

## License

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

For research and education. Outputs require human review.
