Metadata-Version: 2.5
Name: radimagenet-mlx
Version: 0.3.0
Summary: Native MLX implementation of RadImageNet
Project-URL: Homepage, https://huggingface.co/MedMLX/radimagenet-mlx
Author: Joseph Sandoval, Alfredo Sandoval Jr.
License-Expression: Apache-2.0 AND MIT
License-File: LICENSE
License-File: THIRD_PARTY_NOTICES.md
Classifier: Operating System :: MacOS :: MacOS X
Requires-Python: <3.14,>=3.13
Requires-Dist: medmlx-core==0.2.5
Requires-Dist: numpy<3,>=2.0
Requires-Dist: pillow<14,>=13
Provides-Extra: dev
Requires-Dist: h5py-stubs>=0.1.2; extra == 'dev'
Requires-Dist: h5py<4,>=3.14; extra == 'dev'
Requires-Dist: hypothesis<7,>=6.156; 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: types-tensorflow>=2.18.0.20261006; extra == 'dev'
Provides-Extra: reference
Requires-Dist: keras==3.15.0; extra == 'reference'
Requires-Dist: tensorflow==2.20.0; extra == 'reference'
Description-Content-Type: text/markdown

# radimagenet-mlx

Extract radiology-image features with native MLX RadImageNet encoders: ResNet50, DenseNet121, InceptionV3 and InceptionResNetV2.

[Model weights](https://huggingface.co/MedMLX/radimagenet-mlx)

| Input | Output |
| :--- | :--- |
| 2D image + safetensors checkpoint | Pooled and spatial features |

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

## Quick start

```bash
uv venv --python 3.13
source .venv/bin/activate
uv pip install "radimagenet-mlx>=0.3.0"
```

Download the [native weights](https://huggingface.co/MedMLX/radimagenet-mlx), then run:

```python
from huggingface_hub import hf_hub_download
from radimagenet_mlx.medmlx import run

weights = hf_hub_download(
    "MedMLX/radimagenet-mlx", "RadImageNet-ResNet50_notop.safetensors",
    revision="fd1c2663266360c899211c9a23ffc24f805d282a",
)
result = run(
    image_path="slice.png",
    weights_path=weights,
    output_dir="features",
)
print(result["outputs"]["features_npy"])
```

The safetensors file must contain float32 MLX-layout weights and declarative
`model_config` graph metadata. Registered MedMLX runners manage model-folder
downloads as described below. The published bundle contains four encoders without
classification heads. Classifier predictions require a checkpoint that includes a classifier.

## MedMLX runners

Each backbone has its own registered model ID:
`radimagenet-resnet50`, `radimagenet-densenet121`, `radimagenet-inceptionv3` and
`radimagenet-inceptionresnetv2`. Their runners take the same arguments:

```python
from radimagenet_mlx.medmlx import resnet50

result = resnet50(image_path="image.png", output_dir="outputs")
```

Omitting `weights_path` downloads the shared `MedMLX/radimagenet-mlx` folder.
Explicit folders contain the corresponding native safetensors file:
`RadImageNet-ResNet50_notop.safetensors`, `RadImageNet-DenseNet121_notop.safetensors`,
`RadImageNet-InceptionV3_notop.safetensors` or `RadImageNet-IRV2_notop.safetensors`.
`details.weights_revision` records the Hub revision when available. The
`RadImageNetMlx(checkpoint_file)` API also requires a native safetensors file.

## License

Apache-2.0; license and third-party notices are included in the distribution. Model weights retain their publisher terms.

For research and education. Outputs require human review.
