josand commited on
Commit
f2a0b2d
·
verified ·
1 Parent(s): e3e8e13

Clean model card formatting and usage

Browse files
Files changed (1) hide show
  1. README.md +85 -40
README.md CHANGED
@@ -2,76 +2,121 @@
2
  license: apache-2.0
3
  library_name: mlx
4
  tags:
5
- - medical-imaging
 
6
  - apple-silicon
 
 
 
 
7
  - research
8
  language:
9
  - en
 
 
 
10
  ---
11
- # MONAI renalStructures_CECT_segmentation (SegResNet, 3-phase CECT)
12
 
13
- Native MLX package: [segresnet-mlx](https://github.com/MedMLX/segresnet-mlx.git).
14
- Evaluated revision: `0503a9a3ad1c1c4f2fa0abd033b31c223763b43f` plus the retained [renal correction](segresnet-mlx-renal-fix.patch).
15
 
16
- This card describes the one configuration evaluated in the MedMLX paper. It is research software; the single-case comparison does not estimate clinical accuracy.
 
17
 
18
- ## Source and checkpoint
 
 
19
 
20
- Original publisher: MONAI.
21
- Original implementation: [https://huggingface.co/MONAI/renalStructures_CECT_segmentation](https://huggingface.co/MONAI/renalStructures_CECT_segmentation).
22
- Source revision or version: `8ccbcd9573c004dc435d1913c0459ccd1a110ed1`.
23
- Original checkpoint: https://huggingface.co/MONAI/renalStructures_CECT_segmentation/resolve/8ccbcd9573c004dc435d1913c0459ccd1a110ed1/models/model.pt
 
 
24
 
25
- Conversion: segresnet_mlx.convert_checkpoint(spec=BUNDLES['renalStructures_CECT_segmentation'].spec).
26
- Conversion changes tensor layout or storage as specified by the native package; it does not retrain the model.
27
 
28
- ## Recorded example
29
 
30
- CPTAC-CCRCC (TCIA), patient C3L-01458, CC BY 4.0; CPTAC-CCRCC (TCIA), patient C3L-01458, CC BY 4.0; CPTAC-CCRCC (TCIA), patient C3L-01458, CC BY 4.0
 
 
 
 
 
 
 
 
 
31
 
32
  ```python
33
  from segresnet_mlx.medmlx import run
34
 
35
- # Replace file and directory names with your locally obtained inputs and weights.
36
- kwargs = {
37
- "bundle": "renalStructures_CECT_segmentation",
38
- "arterial_path": "arterial.nii.gz",
39
- "venous_path": "venous.nii.gz",
40
- "excretory_path": "excretory.nii.gz",
41
- "weights_path": "segresnet-renal-cect.safetensors",
42
- "output_dir": "mlx-final",
43
- "overwrite": False
44
- }
45
- result = run(**kwargs)
46
  print(result["outputs"])
47
  ```
48
 
 
 
 
 
 
 
 
 
 
 
49
  Native result: **success**. Original-code comparison: **pass**, `minimum per-label mask Dice` = `1.0`.
50
 
51
  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.
52
 
53
- The complete [native run](native-run.json) and [original-code comparison](reference-comparison.json) retain commands, geometry, precision, and output-specific checks. Use the [replay harness](https://github.com/MedMLX/Med-MLX/blob/main/benchmarks/README.md) to substitute local paths. The package README documents installation and conversion.
 
 
 
 
 
 
54
 
55
- ## Distribution terms
56
 
57
- Upstream code: **Apache-2.0**. Weights: **Apache-2.0**.
58
- Converted weights are hosted in this repository.
59
 
60
- 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. Converted weights may retain the identified upstream license and required notices; the accompanying notices describe the redistribution terms.
61
 
62
- Full [upstream license](LICENSE) accompanies any weight distribution.
 
 
 
63
 
64
- Required notices:
 
65
 
66
- - Retain the applicable license, copyright and attribution notices; identify the upstream checkpoint, authors, and MLX conversion changes.
67
- - Include Apache-2.0, retain applicable upstream NOTICE content, and mark modifications.
68
 
69
- Review sources:
70
 
71
- - https://huggingface.co/MONAI/renalStructures_CECT_segmentation
72
- - https://huggingface.co/MONAI/renalStructures_CECT_segmentation/resolve/8ccbcd9573c004dc435d1913c0459ccd1a110ed1/models/model.pt
73
- - https://huggingface.co/MONAI/renalStructures_CECT_segmentation/blob/8ccbcd9573c004dc435d1913c0459ccd1a110ed1/LICENSE
74
 
75
- ## Packaged files
 
76
 
77
- - `segresnet-renal-cect.safetensors`
 
 
 
 
 
 
 
 
 
 
 
2
  license: apache-2.0
3
  library_name: mlx
4
  tags:
5
+ - mlx
6
+ - native-mlx
7
  - apple-silicon
8
+ - medical-imaging
9
+ - ct
10
+ - kidney
11
+ - segmentation
12
  - research
13
  language:
14
  - en
15
+ inference: false
16
+ pipeline_tag: image-segmentation
17
+ base_model: MONAI/renalStructures_CECT_segmentation
18
  ---
 
19
 
20
+ # SegResNet Renal CECT Segmentation
 
21
 
22
+ Native MLX port of [MONAI renal structures CECT segmentation](https://huggingface.co/MONAI/renalStructures_CECT_segmentation).
23
+ Segment renal structures from three-phase contrast-enhanced CT locally on Apple Silicon.
24
 
25
+ - Arterial, venous and excretory CT inputs
26
+ - Five renal structure labels
27
+ - Converted MONAI SegResNet checkpoint included
28
 
29
+ MLX implementation by [MedMLX](https://github.com/MedMLX).
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
+ **Requires the companion `segresnet-mlx` runtime.** Follow the quick start below.
33
+
34
+ ## Requirements
35
 
36
+ Apple Silicon Mac with Metal GPU access, Python 3.12 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.12
43
+ source .venv/bin/activate
44
+ uv pip install "segresnet-mlx @ git+https://github.com/MedMLX/segresnet-mlx.git" huggingface_hub
45
+
46
+ hf download MedMLX/segresnet-renal-cect-mlx --local-dir models
47
+ ```
48
+
49
+ Authenticate with `hf auth login` if repository access is required.
50
+ Run this example in the same environment, replacing the input paths with your own:
51
 
52
  ```python
53
  from segresnet_mlx.medmlx import run
54
 
55
+ result = run(
56
+ bundle='renalStructures_CECT_segmentation',
57
+ arterial_path='arterial.nii.gz',
58
+ venous_path='venous.nii.gz',
59
+ excretory_path='excretory.nii.gz',
60
+ weights_path='models/segresnet-renal-cect.safetensors',
61
+ output_dir='outputs',
62
+ )
 
 
 
63
  print(result["outputs"])
64
  ```
65
 
66
+ ## Input and output
67
+
68
+ Input is three 3D NIfTI CT volumes on the same voxel grid: arterial, venous
69
+ and excretory phases, in that order.
70
+
71
+ Output is `renalStructures_CECT_segmentation_mask.nii.gz` on the input grid.
72
+ Labels: 0 background, 1 artery, 2 vein, 3 ureter, 4 neoplasm, 5 parenchyma.
73
+
74
+ ## Technical details
75
+
76
  Native result: **success**. Original-code comparison: **pass**, `minimum per-label mask Dice` = `1.0`.
77
 
78
  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.
79
 
80
+ These are recorded results for one configuration, not a new benchmark or an
81
+ estimate of clinical accuracy. The [native run](https://huggingface.co/MedMLX/segresnet-renal-cect-mlx/blob/main/native-run.json)
82
+ and [original-code comparison](https://huggingface.co/MedMLX/segresnet-renal-cect-mlx/blob/main/reference-comparison.json)
83
+ retain the commands, precision, geometry and output checks.
84
+
85
+ <details>
86
+ <summary>Checkpoint provenance and recorded configuration</summary>
87
 
88
+ Recorded configuration: **MONAI renalStructures_CECT_segmentation (SegResNet, 3-phase CECT)**.
89
 
90
+ Evaluated package revision: `0503a9a3ad1c1c4f2fa0abd033b31c223763b43f` plus the retained [renal correction](segresnet-mlx-renal-fix.patch).
 
91
 
92
+ Recorded input: CPTAC-CCRCC (TCIA), patient C3L-01458, CC BY 4.0.
93
 
94
+ Original publisher: MONAI.
95
+ Original implementation: [upstream source](https://huggingface.co/MONAI/renalStructures_CECT_segmentation).
96
+ Source revision or version: `8ccbcd9573c004dc435d1913c0459ccd1a110ed1`.
97
+ Original checkpoint: [pinned checkpoint](https://huggingface.co/MONAI/renalStructures_CECT_segmentation/resolve/8ccbcd9573c004dc435d1913c0459ccd1a110ed1/models/model.pt).
98
 
99
+ Weights were converted with the companion MLX package, without retraining.
100
+ Conversion changes tensor layout or storage as required by that implementation.
101
 
102
+ The [replay harness](https://github.com/MedMLX/Med-MLX/blob/main/benchmarks/README.md)
103
+ describes how to reproduce the recorded configuration with local paths.
104
 
105
+ </details>
106
 
107
+ ## Intended use
 
 
108
 
109
+ Research and education. Outputs require human review and are not intended for
110
+ clinical diagnosis or treatment decisions.
111
 
112
+ ## License
113
+
114
+ Weights: **Apache-2.0** ([license](https://huggingface.co/MedMLX/segresnet-renal-cect-mlx/blob/main/LICENSE)).
115
+ Upstream code: **Apache-2.0**. MLX port code:
116
+ [Apache-2.0](https://github.com/MedMLX/segresnet-mlx/blob/main/LICENSE).
117
+
118
+ Retain the [attribution and notices](https://huggingface.co/MedMLX/segresnet-renal-cect-mlx/blob/main/NOTICE) when redistributing
119
+ the bundle or a conversion:
120
+
121
+ - Retain the applicable license, copyright and attribution notices; identify the upstream checkpoint, authors, and MLX conversion changes.
122
+ - Include Apache-2.0, retain applicable upstream NOTICE content, and mark modifications.