Instructions to use MedMLX/musclemap-mlx with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- MLX
How to use MedMLX/musclemap-mlx with MLX:
# Download the model from the Hub pip install huggingface_hub[hf_xet] hf download MedMLX/musclemap-mlx --local-dir musclemap-mlx
- Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- LM Studio
- Atomic Chat
|
Download README.md from MedMLX/musclemap-mlx: direct link, hf CLI and curl.
- Browser
- Download file 3.16 kB
-
https://huggingface.co/MedMLX/musclemap-mlx/resolve/main/README.md
- Command line
-
hf download hf://MedMLX/musclemap-mlx/README.md
-
curl -L -o README.md https://huggingface.co/MedMLX/musclemap-mlx/resolve/main/README.md
3.16 kB
| license: mit | |
| library_name: mlx | |
| tags: | |
| - medical-imaging | |
| - image-segmentation | |
| - musclemap | |
| - mri | |
| - ct | |
| - mlx | |
| # MuscleMap v1.4 for MLX | |
| Converted weights for [musclemap-mlx](https://pypi.org/project/musclemap-mlx/), | |
| which segments 113 muscle and bone structures in 3D MRI and CT NIfTI images on | |
| Apple Silicon using MLX and Metal. | |
| > **MuscleMap is the work of the MuscleMap consortium (McKay et al.).** The model, its training method and the weights are theirs: see the original repository, [MuscleMap/MuscleMap](https://github.com/MuscleMap/MuscleMap), and the paper, [J Imaging, 2024](https://doi.org/10.3390/jimaging10110262). This repository only repackages their released weights ([Zenodo 21929873](https://zenodo.org/records/21929873)) for MLX on Apple Silicon. Please cite their paper and star their repository if MuscleMap is useful to you. | |
| The 2D MONAI UNet has one input channel and 114 output channels. `config.json` | |
| contains the publisher configuration, and `labels.json` preserves all original | |
| anatomical IDs, names, sides and regions. Output IDs are anatomical IDs, not | |
| consecutive channel indices. | |
| ## Source and terms | |
| [MuscleMap v1.4 publisher checkpoint](https://zenodo.org/records/21929873), | |
| with [source revision 35a2138](https://github.com/MuscleMap/MuscleMap/tree/35a2138a4a3a63be713bae5584632ffc6433b960). | |
| The publisher licenses the checkpoint and configuration under MIT. The complete | |
| license and attribution accompany this bundle in `LICENSE` and `NOTICE`. | |
| Conversion preserves all 46 float32 tensors exactly; no training or quantization | |
| was performed. `conversion.json` records their inventory and source revision. | |
| ## Use | |
| Install `musclemap-mlx>=0.2.0` and run: | |
| ```python | |
| from musclemap_mlx import run | |
| result = run(image_path="scan.nii.gz", output_dir="out") | |
| print(result["outputs"]["mask"]) | |
| ``` | |
| The weights download from this repository on first use. To use a local copy of this bundle, pass its folder as `weights_path`. | |
| The package restores logits to the input grid before argmax, remaps channels to | |
| original anatomical IDs and retains the largest connected component per label. | |
| Chunk size affects normalization, matching upstream's independent chunk passes | |
| and source-header NIfTI round trip. Use the same chunk size for comparisons. | |
| ## Qualification | |
| With MONAI 1.3.2 and PyTorch 2.4.1 as the float32 reference, the native Metal | |
| pipeline matched every final voxel on the complete TotalSegmentator compact CT | |
| (122x101x30) and MRI (117x91x20) test volumes at source revision | |
| `d89e47f73d24f5fba732a715aeb6fdc0ae34526b`. Both used eight-slice chunks and 90% | |
| Gaussian overlap. Maximum restored-logit errors were 9.92e-5 and 1.03e-4, | |
| respectively, within atol=5e-4, rtol=1e-5. These are implementation parity results | |
| on two compact examples. They do not measure anatomical accuracy against manual | |
| segmentations or coverage of every structure. Methods are in the package's | |
| [technical.md](technical.md). | |
| Cite McKay et al., *MuscleMap: An Open-Source, Community-Supported Consortium | |
| for Whole-Body Quantitative MRI of Muscle*, J Imaging 2024, 10(11):262, | |
| [doi:10.3390/jimaging10110262](https://doi.org/10.3390/jimaging10110262). | |