Skip to content
/ Bonnet Public

[ISBI'26] Bonnet: Ultra-Fast Whole-Body Bone Segmentation from CT Scans

License

Notifications You must be signed in to change notification settings

HINTLab/Bonnet

Repository files navigation

  • Bonnet: Ultra-Fast Whole-Body Bone Segmentation from CT Scans

    Bonnet is an ultra-fast whole-body bone segmentation pipeline for CT scans. It runs in seconds per scan on a single commodity GPU while maintaining reliable segmentation quality across different datasets.


    Contents


    Links: Processed training data & model weights


    Data Preparation

    If you want to train on your own dataset, use the provided preprocessing script to convert CT and segmentation files into sparse voxel formats (.npz).

    1. Organize your raw data

    Ensure your data follows this structure:

    DS_ORIGINAL/
    ├── s0001/
    │   ├── ct.nii.gz
    │   └── segmentations/ 
    │       ├── vertebra_C1.nii.gz
    │       └── ...
    └── s0002/
    

    2. Run Preprocessing

    The script src/preprocess_dataset.py extracts voxels within the [200, 3000] HU range and maps labels according to conf/classes.yaml.

    Bash

    python src/preprocess_dataset.py
    
    • Input: Defined by INPUT_ROOT in the script.
    • Output: Generates sparse_voxel.npz for each case in the OUTPUT_ROOT.

    Training

    1. Configure Paths:
      • Open Bonnet/conf/data/totalseg_hu200_3000.yaml.
      • Set dataset_path and cache_path to your preprocessed data folder.
    2. Run Training:
    python main.py
    

    Inference

    Option A: Single Case Inference (End-to-End)

    Use inference_single.py to segment a raw .nii.gz CT scan directly. This script handles preprocessing, windowed inference, and volume reconstruction automatically.

    Bash

    python inference_single.py --ct /path/to/ct.nii.gz --out ./prediction.nii.gz --device cuda
    

    Note: Ensure the CHECKPOINT_PATH and CONFIG_PATH inside the script point to your actual local files.

    Option B: Evaluation with Sample Data

    To run evaluation on the provided sample test set:

    1. Open Bonnet/conf/eval/eval_on_test.yaml and set eval_only: True.
    2. Point your data config to the sample data path.
    3. Run: python main.py

About

[ISBI'26] Bonnet: Ultra-Fast Whole-Body Bone Segmentation from CT Scans

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •