Image Segmentation
MLX
Safetensors
English
native-mlx
apple-silicon
medical-imaging
x-ray
segmentation
noncommercial
research
Instructions to use MedMLX/flexray-mlx with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- MLX
How to use MedMLX/flexray-mlx with MLX:
# Download the model from the Hub pip install huggingface_hub[hf_xet] hf download MedMLX/flexray-mlx --local-dir flexray-mlx
- Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- LM Studio
- Atomic Chat
Clean model card formatting and usage
Browse files
README.md
CHANGED
|
@@ -2,80 +2,126 @@
|
|
| 2 |
license: cc-by-nc-4.0
|
| 3 |
library_name: mlx
|
| 4 |
tags:
|
| 5 |
-
-
|
|
|
|
| 6 |
- apple-silicon
|
|
|
|
|
|
|
|
|
|
|
|
|
| 7 |
- research
|
| 8 |
language:
|
| 9 |
- en
|
|
|
|
|
|
|
| 10 |
---
|
| 11 |
-
# FleXray flux0375 single member, label 'lungs', threshold 0.5, no TTA
|
| 12 |
|
| 13 |
-
|
| 14 |
-
Evaluated revision: `d768bb15d04ee677ecec0c469fd3170256b345df`.
|
| 15 |
|
| 16 |
-
|
|
|
|
| 17 |
|
| 18 |
-
|
|
|
|
|
|
|
| 19 |
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 24 |
|
| 25 |
-
|
| 26 |
-
Conversion changes tensor layout or storage as specified by the native package; it does not retrain the model.
|
| 27 |
|
| 28 |
-
|
|
|
|
|
|
|
|
|
|
| 29 |
|
| 30 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 31 |
|
| 32 |
```python
|
| 33 |
from flexray_mlx.medmlx import run
|
| 34 |
|
| 35 |
-
|
| 36 |
-
|
| 37 |
-
|
| 38 |
-
|
| 39 |
-
|
| 40 |
-
|
| 41 |
-
|
| 42 |
-
"overwrite": True
|
| 43 |
-
}
|
| 44 |
-
result = run(**kwargs)
|
| 45 |
print(result["outputs"])
|
| 46 |
```
|
| 47 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 48 |
Native result: **success**. Original-code comparison: **pass**, `minimum_per_label_dice` = `0.9999704176268988`.
|
| 49 |
|
| 50 |
Paper uses flux0375 only; the prepared bundle supports `ensemble=False`. The unchanged upstream ensemble descriptor lists all five members, but only the flagship member is packaged. Original comparison passes. Montgomery radiograph panels are excluded from submission/distribution pending image-sharing clearance.
|
| 51 |
|
| 52 |
-
|
|
|
|
|
|
|
|
|
|
| 53 |
|
| 54 |
-
|
|
|
|
| 55 |
|
| 56 |
-
|
| 57 |
-
Converted weights are hosted in this repository.
|
| 58 |
|
| 59 |
-
|
| 60 |
|
| 61 |
-
|
| 62 |
|
| 63 |
-
|
|
|
|
|
|
|
|
|
|
| 64 |
|
| 65 |
-
|
| 66 |
-
|
| 67 |
-
|
|
|
|
| 68 |
|
| 69 |
-
|
| 70 |
|
| 71 |
-
|
| 72 |
-
- https://huggingface.co/VictorButoi/flexray/resolve/6b63ddf09cfdff99aea494e3738cf243a4e22cdb/members/flux0375/model.safetensors
|
| 73 |
|
| 74 |
-
|
|
|
|
| 75 |
|
| 76 |
-
|
| 77 |
-
|
| 78 |
-
-
|
| 79 |
-
|
| 80 |
-
-
|
| 81 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2 |
license: cc-by-nc-4.0
|
| 3 |
library_name: mlx
|
| 4 |
tags:
|
| 5 |
+
- mlx
|
| 6 |
+
- native-mlx
|
| 7 |
- apple-silicon
|
| 8 |
+
- medical-imaging
|
| 9 |
+
- x-ray
|
| 10 |
+
- segmentation
|
| 11 |
+
- noncommercial
|
| 12 |
- research
|
| 13 |
language:
|
| 14 |
- en
|
| 15 |
+
inference: false
|
| 16 |
+
pipeline_tag: image-segmentation
|
| 17 |
---
|
|
|
|
| 18 |
|
| 19 |
+
# FleXray Radiograph Segmentation
|
|
|
|
| 20 |
|
| 21 |
+
Native MLX port of [FleXray](https://github.com/VictorButoi/FleXray).
|
| 22 |
+
Segment anatomical structures in radiographs locally on Apple Silicon.
|
| 23 |
|
| 24 |
+
- Released `flux0375` member
|
| 25 |
+
- Lung segmentation in the quick start
|
| 26 |
+
- Single-member inference; noncommercial weights
|
| 27 |
|
| 28 |
+
MLX implementation by [MedMLX](https://github.com/MedMLX).
|
| 29 |
+
[GitHub](https://github.com/MedMLX/flexray-mlx) · [Usage](https://github.com/MedMLX/flexray-mlx#quick-start) · [Upstream](https://github.com/VictorButoi/FleXray)
|
| 30 |
+
|
| 31 |
+
**Requires the companion `flexray-mlx` runtime.** Follow the quick start below.
|
| 32 |
+
|
| 33 |
+
## Requirements
|
| 34 |
+
|
| 35 |
+
Apple Silicon Mac with Metal GPU access, Python 3.12 and [uv](https://docs.astral.sh/uv/).
|
| 36 |
+
The weights are included here; checkpoint conversion is not needed.
|
| 37 |
|
| 38 |
+
## Quick start
|
|
|
|
| 39 |
|
| 40 |
+
```bash
|
| 41 |
+
uv venv --python 3.12
|
| 42 |
+
source .venv/bin/activate
|
| 43 |
+
uv pip install "flexray-mlx @ git+https://github.com/MedMLX/flexray-mlx.git" huggingface_hub
|
| 44 |
|
| 45 |
+
hf download MedMLX/flexray-mlx --local-dir models
|
| 46 |
+
```
|
| 47 |
+
|
| 48 |
+
Authenticate with `hf auth login` if repository access is required.
|
| 49 |
+
Run this example in the same environment, replacing the input paths with your own:
|
| 50 |
|
| 51 |
```python
|
| 52 |
from flexray_mlx.medmlx import run
|
| 53 |
|
| 54 |
+
result = run(
|
| 55 |
+
image_path='chest.png',
|
| 56 |
+
weights_path='models',
|
| 57 |
+
output_dir='outputs',
|
| 58 |
+
label_name='lungs',
|
| 59 |
+
ensemble=False,
|
| 60 |
+
)
|
|
|
|
|
|
|
|
|
|
| 61 |
print(result["outputs"])
|
| 62 |
```
|
| 63 |
|
| 64 |
+
Only `flux0375` is packaged. Keep `ensemble=False`; the retained upstream
|
| 65 |
+
ensemble descriptor lists five members, but the other four are not included.
|
| 66 |
+
|
| 67 |
+
## Input and output
|
| 68 |
+
|
| 69 |
+
Input is one radiograph: a raster image supported by Pillow or a single-frame
|
| 70 |
+
2D DICOM. The example segments the lungs.
|
| 71 |
+
|
| 72 |
+
Each run writes:
|
| 73 |
+
|
| 74 |
+
- `source_image_label.png` — 0/1 mask at source resolution
|
| 75 |
+
- `source_image.png` — 8-bit grayscale input
|
| 76 |
+
- `probabilities.npy` — float32 probabilities for all 61 labels
|
| 77 |
+
- `prediction.json` — label, threshold and member metadata
|
| 78 |
+
|
| 79 |
+
## Technical details
|
| 80 |
+
|
| 81 |
Native result: **success**. Original-code comparison: **pass**, `minimum_per_label_dice` = `0.9999704176268988`.
|
| 82 |
|
| 83 |
Paper uses flux0375 only; the prepared bundle supports `ensemble=False`. The unchanged upstream ensemble descriptor lists all five members, but only the flagship member is packaged. Original comparison passes. Montgomery radiograph panels are excluded from submission/distribution pending image-sharing clearance.
|
| 84 |
|
| 85 |
+
These are recorded results for one configuration, not a new benchmark or an
|
| 86 |
+
estimate of clinical accuracy. The [native run](https://huggingface.co/MedMLX/flexray-mlx/blob/main/native-run.json)
|
| 87 |
+
and [original-code comparison](https://huggingface.co/MedMLX/flexray-mlx/blob/main/reference-comparison.json)
|
| 88 |
+
retain the commands, precision, geometry and output checks.
|
| 89 |
|
| 90 |
+
<details>
|
| 91 |
+
<summary>Checkpoint provenance and recorded configuration</summary>
|
| 92 |
|
| 93 |
+
Recorded configuration: **FleXray flux0375 single member, label 'lungs', threshold 0.5, no TTA**.
|
|
|
|
| 94 |
|
| 95 |
+
Evaluated package revision: `d768bb15d04ee677ecec0c469fd3170256b345df`.
|
| 96 |
|
| 97 |
+
Recorded input: NLM Montgomery County CXR / MCUCXR_0001_0.
|
| 98 |
|
| 99 |
+
Original publisher: VictorButoi.
|
| 100 |
+
Original implementation: [upstream source](https://github.com/VictorButoi/FleXray).
|
| 101 |
+
Source revision or version: `bf6d01426fd3ae012aff9253ec9c9952c58bc960`.
|
| 102 |
+
Original checkpoint: [pinned checkpoint](https://huggingface.co/VictorButoi/flexray/resolve/6b63ddf09cfdff99aea494e3738cf243a4e22cdb/members/flux0375/model.safetensors).
|
| 103 |
|
| 104 |
+
The released safetensors snapshot is loaded directly, without retraining.
|
| 105 |
+
|
| 106 |
+
The [replay harness](https://github.com/MedMLX/Med-MLX/blob/main/benchmarks/README.md)
|
| 107 |
+
describes how to reproduce the recorded configuration with local paths.
|
| 108 |
|
| 109 |
+
</details>
|
| 110 |
|
| 111 |
+
## Intended use
|
|
|
|
| 112 |
|
| 113 |
+
Research and education. Outputs require human review and are not intended for
|
| 114 |
+
clinical diagnosis or treatment decisions.
|
| 115 |
|
| 116 |
+
## License
|
| 117 |
+
|
| 118 |
+
Weights: **CC-BY-NC-4.0** ([license](https://huggingface.co/MedMLX/flexray-mlx/blob/main/LICENSE)).
|
| 119 |
+
Upstream code: **MIT**. MLX port code:
|
| 120 |
+
[Apache-2.0](https://github.com/MedMLX/flexray-mlx/blob/main/LICENSE).
|
| 121 |
+
|
| 122 |
+
Retain the [attribution and notices](https://huggingface.co/MedMLX/flexray-mlx/blob/main/NOTICE) when redistributing
|
| 123 |
+
the bundle or a conversion:
|
| 124 |
+
|
| 125 |
+
- Retain the applicable license, copyright and attribution notices; identify the upstream checkpoint, authors, and MLX conversion changes.
|
| 126 |
+
- Credit the creator and source, link the applicable CC license, retain supplied notices, and identify conversion changes.
|
| 127 |
+
- Label converted weights noncommercial and preserve the applicable noncommercial limitation.
|