This project presents an AI-powered bone fracture detection and classification system using Vision Transformer (ViT), designed to analyze X-ray images and assist in medical diagnosis.
The system performs both binary fracture detection and multiclass classification across 12 fracture types, delivering real-time predictions along with confidence scores and AI-generated diagnostic reports.
Built as an end-to-end solution with a deep learning model, backend processing pipeline, and interactive frontend interface, this project aims to support radiologists and improve the efficiency of medical decision-making.
๐ Achievement: 2nd Runner-Up โ HackBio (Xpectoโ26), IIT Mandi
Bone fractures are commonly diagnosed through X-ray analysis by radiologists. However, manual diagnosis can be time-consuming and requires expert expertise.
This project presents a deep learning-based fracture detection system that:
โ Detects whether a fracture exists โ Classifies fracture types (12 categories) โ Generates an AI-based diagnostic report
๐ก Impact: Helps reduce manual workload and supports faster medical decision-making.
- โ Binary fracture detection (Fractured / Not Fractured)
- โ Multi-class fracture classification (12 types)
- โ Vision Transformer (ViT-Small Patch16 224)
- โ AI-generated radiology report
- โ Confidence score output
- โ Fast inference (~14 ms per image)
- โ Clean modular pipeline
- โ Frontend using HTML, CSS, JavaScript
The system uses:
๐ Vision Transformer (ViT-Small Patch16 224) ๐ Trained from scratch (no fracture-pretrained models)
- Captures global image relationships
- Handles complex medical patterns
- Modern deep learning approach
X-ray Image Input (User Upload / Test)
โ
Image Preprocessing (Resize 224ร224 โ Tensor)
โ
Stage 1: Fracture Detection (ViT)
โ
If Not Fractured โ Stop
โ
Stage 2: Fracture Type Classification (ViT)
โ
Predicted Fracture Type + Confidence
โ
AI Diagnosis ReportBONE_FRACTURE_AI/
โโโ dataset/ # Binary dataset
โโโ dataset_types/ # Multi-class dataset
โโโ models/
โ โโโ binary_model.pth
โ โโโ type_model.pth
โโโ Frontend/ # HTML/CSS/JS UI
โโโ model.py # ViT model
โโโ train.py # Training script
โโโ evaluate.py # Evaluation metrics
โโโ predict.py # Basic prediction
โโโ predict_pipeline.py # Full pipeline
โโโ data_loader.py # Data preprocessing
โโโ config.yaml
โโโ requirements.txt
โโโ README.md| Metric | Value |
|---|---|
| Accuracy | 91.23% |
| Precision | 91.94% |
| Recall | 90.90% |
| F1 Score | 91.12% |
| Test Accuracy | 97.66% |
โ Excellent generalization โ Very low false positives
| Metric | Value |
|---|---|
| Validation Accuracy | 86.56% |
| Test Accuracy | 84.49% |
โ Good classification performance โ Slight overfitting observed
~14 ms per image
- Avulsion
- Comminuted
- Compression
- Fracture
- Greenstick
- Hairline
- Impacted
- Intra-articular
- Longitudinal
- Oblique
- Pathological
- Spiral
| Parameter | Value |
|---|---|
| Batch Size | 32 |
| Epochs | 15 |
| Learning Rate | 0.0001 |
| Optimizer | Adam |
| Loss Function | CrossEntropyLoss |
| Image Size | 224ร224 |
- Accuracy
- Precision
- Recall
- F1 Score
- Macro F1 Score
- Confusion Matrix
- AUC-ROC
- Cross-validation
๐ Outputs stored in:
final_results.csvmodel_performance_analysis.csv
This project uses publicly available datasets:
- https://www.kaggle.com/datasets/amohankumar/bone-break-classifier-dataset
- https://www.kaggle.com/datasets/bmadushanirodrigo/fracture-multi-region-x-ray-data
โ Dataset is not included due to size limitations.
git clone https://github.com/YOUR_USERNAME/bone-fracture-ai.git
cd bone-fracture-ai
pip install -r requirements.txtexport KMP_DUPLICATE_LIB_OK=TRUE
python predict_pipeline.pyOpen the Frontend/index.html file in your browser.
AI RADIOLOGY REPORT
Result: Fracture Detected
Confidence: 99.96%
Fracture Type: Pathological
Type Confidence: 35.67%
Recommendation:
Consult an orthopedic specialist- Medical decision support
- Radiology assistance
- Remote healthcare diagnostics
- Medical education
- Depends on dataset quality
- Similar fracture types may confuse model
- Not a replacement for professional diagnosis
- Larger datasets
- Explainable AI (Grad-CAM)
- Mobile app deployment
- Hospital integration
Sukhraj Singh AIML Developer
This project is for educational and research purposes only.

