FracFormer: Semi-supervised Learning for Vertebrae and Fracture Classification on 3D Radiographs with Transformers
This repository is the official implementation of FracFormer: Semi-supervised Learning for Vertebrae and Fracture Classification on 3D Radiographs with Transformers. Our framework applies transformer-based models to detect vertebrae fractures, incorporating a Vision Transformer for spine detection and a Swin Transformer for fracture identification. This approach leverages the strengths of transformers in medical imaging to advance vertebral and fracture classification accuracy on 3D radiographic data.
The architecture consists of:
- Vertebrae Network: Predicts vertebra visibility labels (C1–C7).
- Fracture Network: Predicts fracture probabilities using pseudo-labels from the Vertebrae Network.
- Uses Vision Transformers (ViT) for vertebra visibility prediction.
- Employs Swin Transformers for detecting fractures.
-
Clone the repository:
git clone https://github.com/seonokkim/FracFormer.git cd FracFormer
-
Install dependencies:
pip install -r requirements.txt
-
Set up directories:
mkdir dataset models figures utils
-
Download the dataset from the RSNA Cervical Spine Fracture Detection. Place the dataset into the
dataset
directory with the following structure:dataset/ ├── train_images/ ├── test_images/ ├── train.csv ├── test.csv
-
Preprocess the dataset:
python dataset/dataset.py
The first stage predicts vertebra visibility using Vision Transformers:
python models/fracformer.py
This step:
- Trains the VertebraeNet.
- Generates pseudo-labels for vertebra visibility (C1–C7).
The second stage detects fractures using Swin Transformers:
python models/fracformer.py
This step:
- Trains the FractureNet using the Vertebrae Network predictions.
-
Ensure trained models are saved in the
models/checkpoints
directory:models/checkpoints/ ├── vertebraenet_fold0.tph ├── vertebraenet_fold1.tph ├── fracturenet_fold0.tph ├── fracturenet_fold1.tph
-
Run the inference script:
python test.py
-
Results:
- Generates predictions for fractures.
- Outputs classification reports and metrics like AUC-ROC.
This project is licensed under the MIT License. See the LICENSE file for details.
This work builds upon the RSNA Cervical Spine Fracture Detection dataset and leverages cutting-edge Transformer architectures (ViT and Swin Transformers).