total-feet-seg
This repository contains an nnU-Net v2 model that segments 56 bones of both feet and ankles in CT scans: the distal tibia and fibula, the tarsals, the metatarsals and the phalanges. Left and right bones get separate labels.

It also contains the scripts that trained the model (training/), so the training can be repeated step by step.
Model
| Network | Residual encoder U-Net, preset M (nnUNetResEncUNetMPlans) |
| Configuration | 3d_fullres, patch 64 × 160 × 96 voxels at 1.09 × 0.5 × 1.09 mm |
| Trainer | nnUNetTrainerNoMirroring (no mirroring, so left and right are never swapped) |
| Folds | 5-fold cross-validation (0 1 2 3 4); a prediction averages all 5 networks |
| Checkpoint | checkpoint_final.pth (end of the full 1000-epoch schedule) |
| Postprocessing | keep only the largest connected component, for the bones where this improved the Dice |
| Size | 5 × 785 MB |
Accuracy
Five-fold cross-validation on the 30 training scans: each scan was segmented by the network that did not see it during training. This estimates the accuracy on new scans of the same kind. It is not a test on an independent dataset.
| Bone group | Dice | Dice after postprocessing |
|---|---|---|
| Tibia and fibula | 0.955 | 0.963 |
| Tarsals | 0.959 | 0.962 |
| Metatarsals | 0.953 | 0.956 |
| Phalanges | 0.898 | 0.899 |
| All bones | 0.927 | 0.930 |
| Bone | Left | Right |
|---|---|---|
| Tibia | 0.983 | 0.952 |
| Fibula | 0.974 | 0.943 |
| Talus | 0.972 | 0.950 |
| Calcaneus | 0.986 | 0.953 |
| Navicular | 0.974 | 0.940 |
| Cuboid | 0.976 | 0.945 |
| Medial cuneiform | 0.974 | 0.968 |
| Intermediate cuneiform | 0.960 | 0.951 |
| Lateral cuneiform | 0.965 | 0.953 |
| Metatarsal 1 | 0.971 | 0.972 |
| Metatarsal 2 | 0.958 | 0.947 |
| Metatarsal 3 | 0.959 | 0.945 |
| Metatarsal 4 | 0.958 | 0.939 |
| Metatarsal 5 | 0.964 | 0.944 |
| Toe 1: proximal, distal phalanx | 0.962, 0.911 | 0.965, 0.915 |
| Toe 2: proximal, middle, distal | 0.952, 0.926, 0.906 | 0.948, 0.904, 0.880 |
| Toe 3: proximal, middle, distal | 0.945, 0.905, 0.898 | 0.942, 0.904, 0.864 |
| Toe 4: proximal, middle, distal | 0.941, 0.896, 0.895 | 0.909, 0.855, 0.822 |
| Toe 5: proximal, middle, distal | 0.910, 0.864, 0.844 | 0.874, 0.845, 0.805 |
Mean Dice per scan: 28 of the 30 scans score between 0.89 and 0.96. Two scans score lower:
- Scan 018 (0.62): left and right swapped. The network labelled the right tibia, fibula, talus and calcaneus as the left bones. The shapes were correct, only the side was wrong. Postprocessing then removed these bones, because each left label had two parts and only the largest was kept. This one scan pulls down the right-side Dice of the hindfoot bones in the table above.
- Scan 030 (0.82): the scan ends in the metatarsals, so the toes are outside the image.
The phalanges have the lowest Dice. They are small, so an error of one voxel layer at the surface already costs a lot of Dice.
Training curves
Loss and pseudo-Dice per epoch of the 5 folds (top panel of each fold's progress.png):
| Fold 0 | Fold 1 | Fold 2 | Fold 3 | Fold 4 |
|---|---|---|---|---|
![]() | ![]() | ![]() | ![]() | ![]() |
In all folds, the train loss (blue) and validation loss (red) fall together and then stay level, so the networks did not overfit. Fold 3 has a higher validation loss and a lower pseudo-Dice than the other folds. Its 6 validation scans include scan 018, where left and right were swapped, and scans 026 and 030, which end in the toes or metatarsals.
Labels
| Left | Right | |
|---|---|---|
| Tibia | 1 | 2 |
| Fibula | 3 | 4 |
| Talus | 5 | 6 |
| Calcaneus | 7 | 8 |
| Navicular | 9 | 10 |
| Cuboid | 11 | 12 |
| Medial / Intermediate / Lateral cuneiform | 13 / 15 / 17 | 14 / 16 / 18 |
| Metatarsals 1–5 | 19, 21, 23, 25, 27 | 20, 22, 24, 26, 28 |
| Phalanges of toe 1 (proximal, distal) | 29, 31 | 30, 32 |
| Phalanges of toes 2–5 (proximal, middle, distal) | 33–55, odd | 34–56, even |
The full list of label names is in the model's dataset.json. In a name like Phalange_Foot_<toe>_<phalanx>_<side>:
- Toe: 1 is the big toe.
- Phalanx: counted from proximal to distal.
Prediction
1. Install
Install PyTorch for your CUDA version, then:
pip install nnunetv2 huggingface_hub
2. Download the model
models/ is an nnU-Net results folder:
hf download BoneHub/total-feet-seg --include "models/*" --local-dir ./total-feet-seg
export nnUNet_results="$PWD/total-feet-seg/models"
M="$nnUNet_results/Dataset002_vsd-feet-seg/nnUNetTrainerNoMirroring__nnUNetResEncUNetMPlans__3d_fullres"
3. Prepare the input
Put the CT scans (in Hounsfield units, .nii.gz) in one folder, named <name>_0000.nii.gz (nnU-Net's channel suffix).
- Crop the scans to both feet. The training scans contain both feet, the ankles and the lower end of the tibia and fibula: the box around the foot bones plus about 5 cm along the leg and 11–13 cm across (typically 35 × 23 × 23 cm). The model has not seen other anatomy, such as the knees, and may label it as foot bones.
- The orientation must be correct, because the model predicts left and right labels.
4. Predict and postprocess
nnUNetv2_predict -i ./scans -o ./segmentations_raw -d Dataset002_vsd-feet-seg -c 3d_fullres \
-tr nnUNetTrainerNoMirroring -p nnUNetResEncUNetMPlans -f 0 1 2 3 4 -npp 1 -nps 1
nnUNetv2_apply_postprocessing -i ./segmentations_raw -o ./segmentations \
-pp_pkl_file "$M/crossval_results_folds_0_1_2_3_4/postprocessing.pkl" \
-plans_json "$M/plans.json" -dataset_json "$M/dataset.json" -np 2
-f 0 1 2 3 4 averages the 5 networks. -npp 1 -nps 1 processes one scan at a time, because a large scan can need tens of GB of RAM.
Each file in ./segmentations/ is a label map with the same size and position as its input scan.
Training
The model was trained with the scripts in training/, one Python script per step. Each script prints the nnU-Net commands it runs. All settings are in training/common.py.
| Step | Script | What it does | Time |
|---|---|---|---|
| 1 | 01_create_nnunet_raw.py | builds the dataset in nnUNet_raw/ | seconds |
| 2 | 02_check_dataset.py | checks orientation, left/right and missing labels | 30 s |
| 3 | 03_plan_and_preprocess.py | nnUNetv2_plan_and_preprocess, 5-fold split | 7 min |
| 4 | 04_train.py | trains the folds, without the final validation | 35 h per fold |
| 5 | 05_validate.py | nnUNetv2_train --val for each fold | 30 min |
| 6 | 06_evaluate.py | nnUNetv2_find_best_configuration, Dice tables | 40 min |
Times are for an RTX 4000 Ada (20 GB).
pip install torch nnunetv2 huggingface_hub # used here: torch 2.15, nnunetv2 2.8.1
git clone https://huggingface.co/BoneHub/total-feet-seg
cd total-feet-seg
hf download BoneHub/vsd-feet-seg --repo-type dataset --local-dir vsd-feet-seg
python training/01_create_nnunet_raw.py
python training/02_check_dataset.py
python training/03_plan_and_preprocess.py
python training/04_train.py --gpu 0 --folds 0 1 2 3 4 # or one process per GPU, each with some folds
python training/05_validate.py
python training/06_evaluate.py
The scripts can be re-run: finished work is skipped and an interrupted fold continues from its last checkpoint. nnU-Net's folders are created in nnUNet_data/.
Choices
- 5-fold cross-validation. Every scan is predicted once by a network that did not train on it, so the Dice above estimates the accuracy on new scans. The released model is the ensemble of the 5 folds.
- No mirroring (
nnUNetTrainerNoMirroring). A left foot flipped left-right looks like a right foot but keeps its "left" labels, so the default mirroring augmentation would teach the network the wrong side. - Default schedule and final checkpoint. 1000 epochs with a learning rate decreasing from 0.01 to 0.
checkpoint_best.pthis chosen by the noisy pseudo-Dice and is not used. - ResEnc M (presets), the preset that fits a 20 GB GPU. ResEnc L with a 16 GB budget has a larger patch but takes 77 h per fold instead of 35 h.
- Only
3d_fullres. The3d_lowres/cascade configurations were not trained, so step 6 has nothing to choose between. The cascade sees more of the scan at once and might avoid left/right swaps like the one in scan 018. - Validation is a separate step (step 5, one fold at a time), because validating one fold needed up to 47 GB of RAM.
Dataset findings (step 2)
- All 30 scans have the same orientation (LPS), with the left bones on the patient's left.
- Scans 026 and 030 lack some phalanx labels because the image ends in the toes (026) or the metatarsals (030). The labels are not wrong, and the scans are used as they are.
Fine-tuning on your own data
This starts from the released weights.
-
Prepare your data. Create your own dataset in
$nnUNet_raw, e.g.Dataset004_my-feet, in the nnU-Net format (imagesTr/,labelsTr/,dataset.json). Use the same labels as above if possible. -
Reuse the released plans and preprocess. Copy the model's plans to
$nnUNet_preprocessed, transfer them to your dataset, and preprocess:mkdir -p "$nnUNet_preprocessed/Dataset002_vsd-feet-seg" cp "$M/plans.json" "$nnUNet_preprocessed/Dataset002_vsd-feet-seg/nnUNetResEncUNetMPlans.json" nnUNetv2_extract_fingerprint -d 4 nnUNetv2_move_plans_between_datasets -s Dataset002_vsd-feet-seg -t 4 -sp nnUNetResEncUNetMPlans -tp nnUNetResEncUNetMPlans nnUNetv2_preprocess -d 4 -plans_name nnUNetResEncUNetMPlans -c 3d_fullres -
Train from the released weights, here from the network of fold 0:
nnUNetv2_train 4 3d_fullres 0 -tr nnUNetTrainerNoMirroring -p nnUNetResEncUNetMPlans \ -pretrained_weights "$M/fold_0/checkpoint_final.pth"
See nnU-Net's fine-tuning guide for details.
Training data
The model was trained on 30 CT scans of the feet. The images come from VSDFullBodyBoneReconstruction. The labels were created from the bone meshes of VSDFullBodyBoneModels, with the fused foot bones split into individual bones.
The training data is published as BoneHub/vsd-feet-seg.
Earlier versions
Earlier versions of this repository had two models (ResEnc L and plain U-Net) trained on fold all, stopped before the end of the schedule (epochs 681 and 179) and with a lower learning rate than nnU-Net's default. Their reported pseudo-Dice was measured on training data and is not comparable with the cross-validation Dice above. They are still in the git history.
Limitations
- The model was trained on only 30 subjects and not tested on an independent dataset.
- The model was trained only on scans cropped to both feet (see Prepare the input). Scans of a single foot or with a much larger field of view were not tested.
- Results may be worse on other scanners, fields of view, implants or pathologies.
- Left and right can be swapped (see scan 018). Check the side labels.
- For research use only. The model is not for clinical use.
License
Citation
If you use this model, please cite nnU-Net and the used datasets:
@article{isensee2021nnunet,
title = {nnU-Net: a self-configuring method for deep learning-based biomedical image segmentation},
author = {Isensee, Fabian and Jaeger, Paul F. and Kohl, Simon A. A. and Petersen, Jens and Maier-Hein, Klaus H.},
journal = {Nature Methods},
volume = {18},
number = {2},
pages = {203--211},
year = {2021}
}
@inproceedings{isensee2024nnunetrevisited,
title = {nnU-Net Revisited: A Call for Rigorous Validation in 3D Medical Image Segmentation},
author = {Isensee, Fabian and Wald, Tassilo and Ulrich, Constantin and Baumgartner, Michael and Roy, Saikat and Maier-Hein, Klaus and J{\"a}ger, Paul F.},
booktitle = {Medical Image Computing and Computer Assisted Intervention (MICCAI)},
year = {2024}
}
@misc{seyedhamidrezaalaviVsdfeetseg,
title = {Vsd-Feet-Seg},
author = {Seyed Hamidreza Alavi and Malte Asseln},
year = {2026},
publisher = {Hugging Face},
doi = {10.57967/HF/10470},
url = {https://huggingface.co/datasets/BoneHub/vsd-feet-seg},
urldate = {2026-09-16}
}
@article{fischerDatabaseSegmentationsSurface2023,
title = {Database of Segmentations and Surface Models of Bones of the Entire Lower Body Created from Cadaver {{CT}} Scans},
author = {Fischer, M.C.M.},
year = 2023,
journal = {Scientific Data},
volume = {10},
number = {1},
pages = {763},
publisher = {Nature Publishing Group},
issn = {2052-4463},
doi = {10.1038/s41597-023-02669-z},
}




