Skip to content

Sukhraj-Singh-2006/AI-Powered-Bone-Fracture-Detection-System-with-Multiclass-Classification

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

12 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

๐Ÿฆด Bone Fracture Detection & Classification using Vision Transformer

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


๐Ÿ“Œ Project Overview

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.


๐Ÿš€ Key Features

  • โœ” 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

๐Ÿ“ธ Demo

alt text alt text


๐Ÿง  Model Architecture

The system uses:

๐Ÿ‘‰ Vision Transformer (ViT-Small Patch16 224) ๐Ÿ‘‰ Trained from scratch (no fracture-pretrained models)

Why ViT?

  • Captures global image relationships
  • Handles complex medical patterns
  • Modern deep learning approach

๐Ÿ”„ System Pipeline

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 Report

๐Ÿ“‚ Project Structure

BONE_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

๐Ÿ“Š Model Performance

๐ŸŸข Binary Fracture Detection

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


๐Ÿ”ต Fracture Type Classification

Metric Value
Validation Accuracy 86.56%
Test Accuracy 84.49%

โœ” Good classification performance โš  Slight overfitting observed


โšก Inference Speed

~14 ms per image


๐Ÿฆด Supported Fracture Types

  • Avulsion
  • Comminuted
  • Compression
  • Fracture
  • Greenstick
  • Hairline
  • Impacted
  • Intra-articular
  • Longitudinal
  • Oblique
  • Pathological
  • Spiral

โš™๏ธ Training Configuration

Parameter Value
Batch Size 32
Epochs 15
Learning Rate 0.0001
Optimizer Adam
Loss Function CrossEntropyLoss
Image Size 224ร—224

๐Ÿ“ˆ Evaluation Metrics

  • Accuracy
  • Precision
  • Recall
  • F1 Score
  • Macro F1 Score
  • Confusion Matrix
  • AUC-ROC
  • Cross-validation

๐Ÿ“ Outputs stored in:

  • final_results.csv
  • model_performance_analysis.csv

๐Ÿ“‚ Dataset

This project uses publicly available datasets:

โš  Dataset is not included due to size limitations.


๐Ÿ’ป Installation

git clone https://github.com/YOUR_USERNAME/bone-fracture-ai.git
cd bone-fracture-ai
pip install -r requirements.txt

โ–ถ๏ธ Run Project

Run Backend

export KMP_DUPLICATE_LIB_OK=TRUE
python predict_pipeline.py

Run Frontend

Open the Frontend/index.html file in your browser.


๐Ÿ“„ Sample Output

AI RADIOLOGY REPORT

Result: Fracture Detected
Confidence: 99.96%

Fracture Type: Pathological
Type Confidence: 35.67%

Recommendation:
Consult an orthopedic specialist

๐Ÿฅ Applications

  • Medical decision support
  • Radiology assistance
  • Remote healthcare diagnostics
  • Medical education

โš ๏ธ Limitations

  • Depends on dataset quality
  • Similar fracture types may confuse model
  • Not a replacement for professional diagnosis

๐Ÿ”ฎ Future Improvements

  • Larger datasets
  • Explainable AI (Grad-CAM)
  • Mobile app deployment
  • Hospital integration

๐Ÿ‘จโ€๐Ÿ’ป Author

Sukhraj Singh AIML Developer


๐Ÿ“œ License

This project is for educational and research purposes only.

About

End-to-end deep learning system for bone fracture detection and multiclass classification using Vision Transformer (ViT), featuring high-accuracy prediction, real-time inference, and AI-generated diagnostic reports for medical imaging applications.

Topics

Resources

License

Stars

1 star

Watchers

1 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors