https://github.com/asadiahmad/100_sports_image_classification
A deep learning project for sport image classification using a custom VGG19-based architecture with integrated Grad-CAM heatmap visualization for model interpretability.
https://github.com/asadiahmad/100_sports_image_classification
computer-vision cuda data-augmentation deep-learning explainable-ai gpu-acceleration grad-cam heatmap-visualization image-classification mixed-precision-training pytorch pytorch-grad-cam sports-analytics sports-classification transfer-learning vgg19
Last synced: 5 months ago
JSON representation
A deep learning project for sport image classification using a custom VGG19-based architecture with integrated Grad-CAM heatmap visualization for model interpretability.
- Host: GitHub
- URL: https://github.com/asadiahmad/100_sports_image_classification
- Owner: AsadiAhmad
- License: mit
- Created: 2025-06-07T09:18:48.000Z (5 months ago)
- Default Branch: main
- Last Pushed: 2025-06-07T21:15:20.000Z (5 months ago)
- Last Synced: 2025-06-07T22:27:59.288Z (5 months ago)
- Topics: computer-vision, cuda, data-augmentation, deep-learning, explainable-ai, gpu-acceleration, grad-cam, heatmap-visualization, image-classification, mixed-precision-training, pytorch, pytorch-grad-cam, sports-analytics, sports-classification, transfer-learning, vgg19
- Language: Jupyter Notebook
- Homepage:
- Size: 4.08 MB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# 100_Sports_Image_Classification
This project performs classification on 100 sports categories using grayscale images. The core architecture is based on a customized VGG19 pretrained CNN with frozen layers and a new classifier head. The model's interpretability is enhanced using Grad-CAM heatmaps. The dataset is from kaggle.
## Tech :hammer_and_wrench: Languages and Tools :
- Python: Popular language for implementing neural networks and AI projects.
- Jupyter Notebook: Best tool for running Python code cell by cell in an interactive environment.
- Google Colab: Free cloud platform for running Jupyter Notebooks with GPU/TPU support and no local setup needed.
- OpenCV: Powerful library for image processing, computer vision, and real-time applications.
- NumPy: Essential library for numerical operations and array-based computing in Python.
- TQDM: Lightweight library for adding smart progress bars to loops and iterable tasks.
- CUDA: NVIDIA's parallel computing platform for accelerating deep learning on GPUs.
- PyTorch: Deep learning framework known for flexibility, dynamic computation graphs, and strong GPU support.
- TorchVision: Companion library to PyTorch for image-related deep learning tasks, datasets, and transforms.
- Kaggle: Online platform for data science competitions, datasets, and collaborative coding.
- Matplotlib: Versatile library for creating static, animated, and interactive plots in Python.
- Pillow: Python Imaging Library (PIL) fork used for opening, editing, and saving images easily.
## 💻 Run the Notebook on Google Colab
You can easily run this code on google colab by just clicking this badge [](https://github.com/AsadiAhmad/100_Sports_Image_Classification/blob/main/Code/100_Sports_Image_Classification.ipynb)
## Structure
We have used VGG19 model. also we freeze the 15th first layer.
| **Model Type / Technique** | **Used in Your Code** | **Library / Source** |
| -------------------------- | ----------------------------------------------- | ------------------------------------------ |
| **CNN (Convolutional NN)** | `VGG19` as the base architecture | `torchvision.models` |
| **Pretrained Model** | `vgg19(weights=VGG19_Weights.DEFAULT)` | `torchvision.models` |
| **Transfer Learning** | Using pretrained VGG19 with partial freezing | `torch.nn`, `torchvision` |
| **Freezing Layers** | First 15 layers of `vgg.features` frozen | `torch.nn.Parameter.requires_grad = False` |
| **Custom NN (Classifier)** | Custom `nn.Sequential` fully connected layers | `torch.nn` |
| **Grayscale Input Conv** | Modified Conv2D to accept grayscale input | `torch.nn.Conv2d` |
| **Dropout** | `nn.Dropout`, `nn.Dropout2d` for regularization | `torch.nn` |
| **Batch Normalization** | `nn.BatchNorm1d` for stable training | `torch.nn` |
| **Activation Function** | `nn.ReLU` used in classifier | `torch.nn` |
| **Weight Initialization** | Xavier (Glorot) init in classifier | `torch.nn.init` |
| **Adaptive Pooling** | `nn.AdaptiveAvgPool2d((7,7))` | `torch.nn` |
| **Flatten Layer** | `nn.Flatten()` | `torch.nn` |
## ⚙️ Training Configuration
- Input Image Size: 512*512
- Optimizer: `Adam`
- Loss Function: `CrossEntropyLoss`
- Epochs: `5`
- Batch Size: `32`
- Drop out: `0.5` (for better Generalization)
- Device: GPU via CUDA (if available)
## 🗂️ Dataset
The dataset contains images of 100 different sports classes from Kaggle.
- Source: [Kaggle Sports Dataset](https://www.kaggle.com/datasets/gpiosenka/sports-classification)
- Format: `.jpg` images in folders by class
## 📊 Results
- Training Accuracy: **88.28%** (can go up into 99.99%)
- Validation Accuracy: **93.20%**
- Test Accuracy: **94.40%**
- Training Time: 150 minutes on Colab GPU (Cuda)
- High Generalization at first epoch (80% test Accuracy)
## 🪪 License
This project is licensed under the MIT License.