https://github.com/tahirzia-1/x-ray-bone-fracture-detection
Detects if the bone is fractured or not. Pre-processing includes Image Data generator, Training Data Augmentation, Testing Normalization and Data loading etc.
https://github.com/tahirzia-1/x-ray-bone-fracture-detection
ai binary-classification cnn cnn-classification cnn-keras cnn-model ipynb-jupyter-notebook
Last synced: 8 months ago
JSON representation
Detects if the bone is fractured or not. Pre-processing includes Image Data generator, Training Data Augmentation, Testing Normalization and Data loading etc.
- Host: GitHub
- URL: https://github.com/tahirzia-1/x-ray-bone-fracture-detection
- Owner: TahirZia-1
- Created: 2024-05-08T16:15:32.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2025-02-26T17:47:30.000Z (8 months ago)
- Last Synced: 2025-02-26T18:42:38.241Z (8 months ago)
- Topics: ai, binary-classification, cnn, cnn-classification, cnn-keras, cnn-model, ipynb-jupyter-notebook
- Language: Jupyter Notebook
- Homepage:
- Size: 7.81 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Bone Fracture Classification with CNN
This repository implements a Convolutional Neural Network (CNN) for classifying X-ray images as either "fractured" or "not fractured." Built using TensorFlow/Keras, the model is trained on a dataset of bone X-ray images and deployed via a Gradio interface for easy user interaction. The project demonstrates binary classification with data augmentation, model training, and real-time inference.
## Overview
The goal is to distinguish between fractured and non-fractured bone X-rays using a CNN. The dataset contains 8,863 training images and 600 validation images, split into two classes. The trained model achieves high accuracy and is accessible through a simple web interface powered by Gradio.
### Key Features
- **Dataset**: 8,863 training and 600 validation X-ray images (fractured vs. not fractured).
- **Model**: CNN with convolutional, pooling, and dense layers.
- **Data Augmentation**: Shear, zoom, and horizontal flips for robust training.
- **Deployment**: Gradio interface for uploading and classifying X-ray images.
- **Monitoring**: TensorBoard callbacks for training visualization.## Implementation
### Dataset
- **Source**: [Mega.nz Link](https://mega.nz/file/zcdywLhI#fck4ufXy_o_Uiu0vGqh-cZiKHw5Xe_n4M2qWUWSheAI)
- **Structure**:
- `archive (6)/train`: 8,863 images (2 classes)
- `archive (6)/val`: 600 images (2 classes)
- **Preprocessing**: Images resized to 150x150, normalized to [0,1], and augmented.### Model Architecture
- **Input**: 150x150x3 (RGB images)
- **Layers**:
- Conv2D: 32 filters, 3x3 kernel, ReLU activation
- MaxPooling2D: 2x2 pool size
- Flatten
- Dense: 128 units, ReLU activation
- Dense: 1 unit, sigmoid activation
- **Parameters**: ~22.43M trainable
- **Optimizer**: Adam
- **Loss**: Binary Crossentropy
- **Metrics**: Accuracy### Training
- **Batch Size**: 32
- **Epochs**: 15
- **Results**:
- Epoch 1: 57.29% accuracy, 1.1869 loss
- Epoch 15: 91.80% accuracy, 0.2111 loss
- **Callbacks**: TensorBoard for logging### Deployment
- **Gradio Interface**: Upload an X-ray image, receive "fractured" or "not fractured" prediction.
- **Model File**: Saved as `x_ray.keras`## Installation
### Prerequisites
- Python 3.x
- Required libraries:
- TensorFlow (`pip install tensorflow`)
- NumPy (`pip install numpy`)
- Gradio (`pip install gradio`)
- Keras (`pip install keras`)### Setup
1. **Clone the Repository**:
```bash
git clone https://github.com/TahirZia-1/bone-fracture-classification.git
cd bone-fracture-classification