X-RAI is a deep learning project that automatically detects bone fractures from musculoskeletal X-ray images using the MURA v1.1 dataset. The project employs a lightweight convolutional neural network (MobileNetV2) to classify each image as "Fractured" or "Not Fractured."
Google colabnis located at: Google Colab
- Fracture Classification: Achieves up to ~80% accuracy on the validation subset.
- Fast Training: Utilizes MobileNetV2 with resized images for efficient training.
- Model Interpretability: Includes Grad-CAM visualizations to highlight regions influencing the model's decisions.
- Label Overlays: Displays predictions with probabilities for better interpretation.
- Dataset: MURA v1.1 (Stanford ML Group)
- Model: MobileNetV2 (pretrained on ImageNet)
- Frameworks: PyTorch, Torchvision
- Visualization: Grad-CAM, Matplotlib
- Environment: Google Colab (T4 GPU) / Kaggle (GPU)
To ensure optimal performance, use a T4 GPU on Google Colab:
- Open the notebook in Google Colab.
- Navigate to Runtime → Change runtime type.
- Select T4 GPU under Hardware Accelerator.
- Click Save.
Verify GPU availability by running:
import torch
print("GPU Enabled:", torch.cuda.is_available())Install dependencies in Colab:
!pip install kagglehub torch torchvision matplotlib scikit-learn tqdm grad-cam- Dataset Download: The notebook automatically downloads the MURA v1.1 dataset using KaggleHub.
- Body Part Selection: Modify the
bodypartvariable (e.g.,"humerus","wrist") to analyze specific body parts. - Training: Execute the training loop (5 epochs by default). Adjust
num_epochsfor extended training. - Evaluation: Validation metrics (precision, recall, F1-score) are printed post-training.
- Visualization: Grad-CAM highlights model focus areas on a random validation sample.
The notebook displays:
- A classification report with precision, recall, and F1-score.
- Side-by-side images of the original X-ray and Grad-CAM heatmap, annotated with actual and predicted labels.
- The T4 GPU accelerates training significantly compared to CPU-only mode.
- Free Colab tiers may occasionally assign other GPUs, but T4 is prioritized in most sessions.
This project is open-source and available for educational and research purposes. Cite the MURA dataset and relevant libraries if used in your work.
- MURA Dataset: Stanford ML Group
- Libraries: PyTorch, Torchvision, Grad-CAM, Matplotlib
For questions or contributions, open an issue or contact the author.