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
Simplify model card with concise usage and MedMLX branding
Browse files- README.md +17 -82
- banner.png +0 -0
- banner.svg +1 -0
README.md
CHANGED
|
@@ -17,38 +17,35 @@ pipeline_tag: image-segmentation
|
|
| 17 |
base_model: VictorButoi/flexray
|
| 18 |
---
|
| 19 |
|
| 20 |
-
|
| 21 |
|
| 22 |
-
|
| 23 |
-
Segment anatomical structures in radiographs locally on Apple Silicon.
|
| 24 |
|
| 25 |
-
|
| 26 |
-
- Lung segmentation in the quick start
|
| 27 |
-
- Single-member inference; noncommercial weights
|
| 28 |
|
| 29 |
-
|
| 30 |
-
[GitHub](https://github.com/MedMLX/flexray-mlx) · [Usage](https://github.com/MedMLX/flexray-mlx#quick-start) · [Upstream](https://github.com/VictorButoi/FleXray)
|
| 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/flexray-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 flexray_mlx.medmlx import run
|
|
@@ -63,72 +60,10 @@ result = run(
|
|
| 63 |
print(result["outputs"])
|
| 64 |
```
|
| 65 |
|
| 66 |
-
|
| 67 |
-
ensemble descriptor lists five members, but the other four are not included.
|
| 68 |
-
|
| 69 |
-
## Input and output
|
| 70 |
-
|
| 71 |
-
Input is one radiograph: a raster image supported by Pillow or a single-frame
|
| 72 |
-
2D DICOM. The example segments the lungs.
|
| 73 |
-
|
| 74 |
-
Each run writes:
|
| 75 |
-
|
| 76 |
-
- `source_image_label.png` — 0/1 mask at source resolution
|
| 77 |
-
- `source_image.png` — 8-bit grayscale input
|
| 78 |
-
- `probabilities.npy` — float32 probabilities for all 61 labels
|
| 79 |
-
- `prediction.json` — label, threshold and member metadata
|
| 80 |
-
|
| 81 |
-
## Technical details
|
| 82 |
-
|
| 83 |
-
The companion runtime is [v0.2.1](https://github.com/MedMLX/flexray-mlx/releases/tag/v0.2.1), source `5a0ef5f36f40ef606819a48b5869d381386909a2`, with `medmlx-core==0.2.3`. All 206 flagship tensors exactly match the original publisher's pinned `6b63ddf09cfdff99aea494e3738cf243a4e22cdb` bundle used for that release. The ensemble descriptor, flagship configuration, label schema and preprocessing metadata are also byte-identical. The installed public bundle admission accepts this Hub layout with `ensemble=False`, without loading MLX. No weights or runtime assets were changed by this card update.
|
| 84 |
-
|
| 85 |
-
The current fresh installed-wheel suite passed 122 tests with zero skips using independently recorded, seeded upstream numerical fixtures. Separate real released-weight API runs checked flagship execution and the complete external five-member ensemble with TTA; the latter does not imply the missing four members are included here. Those execution/output checks are separate from released-checkpoint cross-framework agreement and clinical accuracy. The following one-case reference comparison is historical and retains its original revision and settings.
|
| 86 |
-
|
| 87 |
-
Historical native result: **success**. Original-code comparison: **pass**, `minimum_per_label_dice` = `0.9999704176268988`.
|
| 88 |
-
|
| 89 |
-
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.
|
| 90 |
-
|
| 91 |
-
These are recorded results for one configuration, not a new benchmark or an
|
| 92 |
-
estimate of clinical accuracy. The [native run](https://huggingface.co/MedMLX/flexray-mlx/blob/main/native-run.json)
|
| 93 |
-
and [original-code comparison](https://huggingface.co/MedMLX/flexray-mlx/blob/main/reference-comparison.json)
|
| 94 |
-
retain the commands, precision, geometry and output checks.
|
| 95 |
-
|
| 96 |
-
<details>
|
| 97 |
-
<summary>Checkpoint provenance and recorded configuration</summary>
|
| 98 |
-
|
| 99 |
-
Recorded configuration: **FleXray flux0375 single member, label 'lungs', threshold 0.5, no TTA**.
|
| 100 |
-
|
| 101 |
-
Evaluated package revision: `d768bb15d04ee677ecec0c469fd3170256b345df`.
|
| 102 |
-
|
| 103 |
-
Recorded input: NLM Montgomery County CXR / MCUCXR_0001_0.
|
| 104 |
-
|
| 105 |
-
Original publisher: VictorButoi.
|
| 106 |
-
Original implementation: [upstream source](https://github.com/VictorButoi/FleXray).
|
| 107 |
-
Source revision or version: `bf6d01426fd3ae012aff9253ec9c9952c58bc960`.
|
| 108 |
-
Original checkpoint: [pinned checkpoint](https://huggingface.co/VictorButoi/flexray/resolve/6b63ddf09cfdff99aea494e3738cf243a4e22cdb/members/flux0375/model.safetensors).
|
| 109 |
-
|
| 110 |
-
The released safetensors snapshot is loaded directly, without retraining.
|
| 111 |
-
|
| 112 |
-
The [replay harness](https://github.com/MedMLX/Med-MLX/blob/main/benchmarks/README.md)
|
| 113 |
-
describes how to reproduce the recorded configuration with local paths.
|
| 114 |
-
|
| 115 |
-
</details>
|
| 116 |
-
|
| 117 |
-
## Intended use
|
| 118 |
-
|
| 119 |
-
Research and education. Outputs require human review and are not intended for
|
| 120 |
-
clinical diagnosis or treatment decisions.
|
| 121 |
-
|
| 122 |
-
## License
|
| 123 |
|
| 124 |
-
|
| 125 |
-
Upstream FleXray code is **MIT**. Original MLX port contributions are
|
| 126 |
-
[Apache-2.0](https://github.com/MedMLX/flexray-mlx/blob/main/LICENSE), with retained MIT and BSD notices for FleXray, PyTorch and TorchVision adaptations in
|
| 127 |
-
[THIRD_PARTY_NOTICES.md](https://github.com/MedMLX/flexray-mlx/blob/main/THIRD_PARTY_NOTICES.md). These code terms do not replace the noncommercial weight license above.
|
| 128 |
|
| 129 |
-
|
| 130 |
-
the bundle or a conversion:
|
| 131 |
|
| 132 |
-
-
|
| 133 |
-
- Credit the creator and source, link the applicable CC license, retain supplied notices, and identify conversion changes.
|
| 134 |
-
- Label converted weights noncommercial and preserve the applicable noncommercial limitation.
|
|
|
|
| 17 |
base_model: VictorButoi/flexray
|
| 18 |
---
|
| 19 |
|
| 20 |
+
<img src="https://huggingface.co/MedMLX/flexray-mlx/resolve/main/banner.png" alt="MedMLX — Segment. RADIOGRAPHS / FLEXRAY" width="100%">
|
| 21 |
|
| 22 |
+
# FleXray · Radiographs
|
|
|
|
| 23 |
|
| 24 |
+
Segment anatomical structures in radiographs with the released FleXray flux0375 member.
|
|
|
|
|
|
|
| 25 |
|
| 26 |
+
[GitHub](https://github.com/MedMLX/flexray-mlx) · [Files](https://huggingface.co/MedMLX/flexray-mlx/tree/main) · [Docs](https://github.com/MedMLX/flexray-mlx/blob/main/README.md#quick-start)
|
|
|
|
| 27 |
|
| 28 |
+
| Input | Output |
|
| 29 |
+
| :--- | :--- |
|
| 30 |
+
| Radiograph | Anatomical segmentation |
|
| 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/flexray-mlx"
|
| 41 |
+
release="$repo/releases/download/v0.2.1"
|
| 42 |
+
uv pip install "$release/flexray_mlx-0.2.1-py3-none-any.whl"
|
| 43 |
uv tool install huggingface-hub
|
| 44 |
|
| 45 |
hf download MedMLX/flexray-mlx --local-dir models
|
| 46 |
```
|
| 47 |
|
| 48 |
+
Replace the example input paths with your own files.
|
|
|
|
| 49 |
|
| 50 |
```python
|
| 51 |
from flexray_mlx.medmlx import run
|
|
|
|
| 60 |
print(result["outputs"])
|
| 61 |
```
|
| 62 |
|
| 63 |
+
Includes the `flux0375` member. Keep `ensemble=False`.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 64 |
|
| 65 |
+
## Use & license
|
|
|
|
|
|
|
|
|
|
| 66 |
|
| 67 |
+
For research and education. Not validated for clinical use.
|
|
|
|
| 68 |
|
| 69 |
+
Weights: [CC-BY-NC-4.0 · noncommercial](https://huggingface.co/MedMLX/flexray-mlx/blob/main/LICENSE). [Notices](https://huggingface.co/MedMLX/flexray-mlx/blob/main/NOTICE).
|
|
|
|
|
|
banner.png
ADDED
|
banner.svg
ADDED
|
|