Image Segmentation
MLX
English
native-mlx
apple-silicon
medical-imaging
ct
kidney
segmentation
research
Instructions to use MedMLX/segresnet-renal-cect-mlx with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- MLX
How to use MedMLX/segresnet-renal-cect-mlx with MLX:
# Download the model from the Hub pip install huggingface_hub[hf_xet] hf download MedMLX/segresnet-renal-cect-mlx --local-dir segresnet-renal-cect-mlx
- Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- LM Studio
- Atomic Chat
Simplify model card with concise usage and MedMLX branding
Browse files- README.md +17 -76
- banner.png +0 -0
- banner.svg +1 -0
README.md
CHANGED
|
@@ -17,38 +17,35 @@ pipeline_tag: image-segmentation
|
|
| 17 |
base_model: MONAI/renalStructures_CECT_segmentation
|
| 18 |
---
|
| 19 |
|
| 20 |
-
|
| 21 |
|
| 22 |
-
|
| 23 |
-
Segment renal structures from three-phase contrast-enhanced CT locally on Apple Silicon.
|
| 24 |
|
| 25 |
-
|
| 26 |
-
- Five renal structure labels
|
| 27 |
-
- Converted MONAI SegResNet checkpoint included
|
| 28 |
|
| 29 |
-
|
| 30 |
-
[GitHub](https://github.com/MedMLX/segresnet-mlx) · [Usage](https://github.com/MedMLX/segresnet-mlx#quick-start) · [Upstream](https://huggingface.co/MONAI/renalStructures_CECT_segmentation)
|
| 31 |
|
| 32 |
-
|
|
|
|
|
|
|
| 33 |
|
| 34 |
-
|
| 35 |
-
|
| 36 |
-
Apple Silicon Mac with Metal GPU access, Python 3.13 or 3.14 and [uv](https://docs.astral.sh/uv/).
|
| 37 |
-
The weights are included here; checkpoint conversion is not needed.
|
| 38 |
|
| 39 |
## Quick start
|
| 40 |
|
| 41 |
```bash
|
| 42 |
uv venv --python 3.13
|
| 43 |
source .venv/bin/activate
|
| 44 |
-
|
|
|
|
|
|
|
|
|
|
| 45 |
uv tool install huggingface-hub
|
| 46 |
|
| 47 |
hf download MedMLX/segresnet-renal-cect-mlx --local-dir models
|
| 48 |
```
|
| 49 |
|
| 50 |
-
|
| 51 |
-
Run this example in the same environment, replacing the input paths with your own:
|
| 52 |
|
| 53 |
```python
|
| 54 |
from segresnet_mlx.medmlx import run
|
|
@@ -64,66 +61,10 @@ result = run(
|
|
| 64 |
print(result["outputs"])
|
| 65 |
```
|
| 66 |
|
| 67 |
-
|
| 68 |
-
|
| 69 |
-
Input is three 3D NIfTI CT volumes on the same voxel grid: arterial, venous
|
| 70 |
-
and excretory phases, in that order.
|
| 71 |
-
|
| 72 |
-
Output is `renalStructures_CECT_segmentation_mask.nii.gz` on the input grid.
|
| 73 |
-
Labels: 0 background, 1 artery, 2 vein, 3 ureter, 4 neoplasm, 5 parenchyma.
|
| 74 |
-
|
| 75 |
-
## Technical details
|
| 76 |
-
|
| 77 |
-
The companion runtime is [v0.2.1](https://github.com/MedMLX/segresnet-mlx/releases/tag/v0.2.1), source `b5cc265cd0426fe8f64b40a8ed9be4c42a599724`, with `medmlx-core==0.2.3`. All 89 tensors here exactly match a fresh CPU host conversion of the pinned renal checkpoint through that installed release's public `convert_state_dict` API. The weights were retained unchanged.
|
| 78 |
-
|
| 79 |
-
Its fresh installed-wheel suite passed 145 tests with zero skips, including 12 released renal-checkpoint cases with independent MONAI references and unchanged numerical gates. The default runtime arithmetic profile is `torch-order-fp32`; compensated profiles and their reference precision are separate contracts. The current release already contains the renal operator correction: the retained patch below documents the historical comparison and is not an installation step.
|
| 80 |
-
|
| 81 |
-
The following full-volume measurements retain their original source revision, arithmetic profile and single-case scope. They do not establish clinical or tumor anatomical accuracy.
|
| 82 |
-
|
| 83 |
-
Historical native result: **success**. Original-code comparison: **pass**, `minimum per-label mask Dice` = `1.0`.
|
| 84 |
-
|
| 85 |
-
Corrected October 12 native path matches all 85,089,840 raw FP32 logits and all 5,935,600 exported mask voxels in a fresh MONAI CPU comparison. The unchanged tolerance is rtol=atol=1e-4. Tumor anatomical correctness is unverified.
|
| 86 |
-
|
| 87 |
-
These are recorded results for one configuration, not a new benchmark or an
|
| 88 |
-
estimate of clinical accuracy. The [native run](https://huggingface.co/MedMLX/segresnet-renal-cect-mlx/blob/main/native-run.json)
|
| 89 |
-
and [original-code comparison](https://huggingface.co/MedMLX/segresnet-renal-cect-mlx/blob/main/reference-comparison.json)
|
| 90 |
-
retain the commands, precision, geometry and output checks.
|
| 91 |
-
|
| 92 |
-
<details>
|
| 93 |
-
<summary>Checkpoint provenance and recorded configuration</summary>
|
| 94 |
-
|
| 95 |
-
Recorded configuration: **MONAI renalStructures_CECT_segmentation (SegResNet, 3-phase CECT)**.
|
| 96 |
-
|
| 97 |
-
Evaluated package revision: `0503a9a3ad1c1c4f2fa0abd033b31c223763b43f` plus the retained [renal correction](https://huggingface.co/MedMLX/segresnet-renal-cect-mlx/blob/main/segresnet-mlx-renal-fix.patch).
|
| 98 |
-
|
| 99 |
-
Recorded input: CPTAC-CCRCC (TCIA), patient C3L-01458, CC BY 4.0.
|
| 100 |
-
|
| 101 |
-
Original publisher: MONAI.
|
| 102 |
-
Original implementation: [upstream source](https://huggingface.co/MONAI/renalStructures_CECT_segmentation).
|
| 103 |
-
Source revision or version: `8ccbcd9573c004dc435d1913c0459ccd1a110ed1`.
|
| 104 |
-
Original checkpoint: [pinned checkpoint](https://huggingface.co/MONAI/renalStructures_CECT_segmentation/resolve/8ccbcd9573c004dc435d1913c0459ccd1a110ed1/models/model.pt).
|
| 105 |
-
|
| 106 |
-
Weights were converted with the companion MLX package, without retraining.
|
| 107 |
-
Conversion changes tensor layout or storage as required by that implementation.
|
| 108 |
-
|
| 109 |
-
The [replay harness](https://github.com/MedMLX/Med-MLX/blob/main/benchmarks/README.md)
|
| 110 |
-
describes how to reproduce the recorded configuration with local paths.
|
| 111 |
-
|
| 112 |
-
</details>
|
| 113 |
-
|
| 114 |
-
## Intended use
|
| 115 |
-
|
| 116 |
-
Research and education. Outputs require human review and are not intended for
|
| 117 |
-
clinical diagnosis or treatment decisions.
|
| 118 |
-
|
| 119 |
-
## License
|
| 120 |
|
| 121 |
-
|
| 122 |
-
Upstream code: **Apache-2.0**. MLX port code:
|
| 123 |
-
[Apache-2.0](https://github.com/MedMLX/segresnet-mlx/blob/main/LICENSE).
|
| 124 |
|
| 125 |
-
|
| 126 |
-
the bundle or a conversion:
|
| 127 |
|
| 128 |
-
-
|
| 129 |
-
- Include Apache-2.0, retain applicable upstream NOTICE content, and mark modifications.
|
|
|
|
| 17 |
base_model: MONAI/renalStructures_CECT_segmentation
|
| 18 |
---
|
| 19 |
|
| 20 |
+
<img src="https://huggingface.co/MedMLX/segresnet-renal-cect-mlx/resolve/main/banner.png" alt="MedMLX — Segment. RENAL CECT / SEGRESNET" width="100%">
|
| 21 |
|
| 22 |
+
# SegResNet · Renal CECT
|
|
|
|
| 23 |
|
| 24 |
+
Segment renal structures from three-phase contrast-enhanced CT with native MLX.
|
|
|
|
|
|
|
| 25 |
|
| 26 |
+
[GitHub](https://github.com/MedMLX/segresnet-mlx) · [Files](https://huggingface.co/MedMLX/segresnet-renal-cect-mlx/tree/main) · [Docs](https://github.com/MedMLX/segresnet-mlx/blob/main/README.md#quick-start)
|
|
|
|
| 27 |
|
| 28 |
+
| Input | Output |
|
| 29 |
+
| :--- | :--- |
|
| 30 |
+
| Arterial, venous + excretory CT | Five renal structure labels |
|
| 31 |
|
| 32 |
+
**Apple Silicon · Metal · Python 3.13 / 3.14**
|
|
|
|
|
|
|
|
|
|
| 33 |
|
| 34 |
## Quick start
|
| 35 |
|
| 36 |
```bash
|
| 37 |
uv venv --python 3.13
|
| 38 |
source .venv/bin/activate
|
| 39 |
+
|
| 40 |
+
repo="https://github.com/MedMLX/segresnet-mlx"
|
| 41 |
+
release="$repo/releases/download/v0.2.1"
|
| 42 |
+
uv pip install "$release/segresnet_mlx-0.2.1-py3-none-any.whl"
|
| 43 |
uv tool install huggingface-hub
|
| 44 |
|
| 45 |
hf download MedMLX/segresnet-renal-cect-mlx --local-dir models
|
| 46 |
```
|
| 47 |
|
| 48 |
+
Replace the example input paths with your own files.
|
|
|
|
| 49 |
|
| 50 |
```python
|
| 51 |
from segresnet_mlx.medmlx import run
|
|
|
|
| 61 |
print(result["outputs"])
|
| 62 |
```
|
| 63 |
|
| 64 |
+
All three CT phases must share the same voxel grid.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 65 |
|
| 66 |
+
## Use & license
|
|
|
|
|
|
|
| 67 |
|
| 68 |
+
For research and education. Not validated for clinical use.
|
|
|
|
| 69 |
|
| 70 |
+
Weights: [Apache-2.0](https://huggingface.co/MedMLX/segresnet-renal-cect-mlx/blob/main/LICENSE). [Notices](https://huggingface.co/MedMLX/segresnet-renal-cect-mlx/blob/main/NOTICE).
|
|
|
banner.png
ADDED
|
banner.svg
ADDED
|
|