Skip to content

JAGAN-JGUN/Image-Classification

Repository files navigation

Image Classification - Model Training

This repository contains the training pipeline for an Intel Image classification system using deep learning. It includes implementations in both TensorFlow and PyTorch, focusing on classifying images into categories such as buildings, forest, mountains etc.


Intel Image Classification Dataset

This dataset used here is provided by Intel and is designed for natural scene classification. It contains RGB images across 6 natural categories:

  • Buildings

  • Forest

  • Glacier

  • Mountain

  • Sea

  • Street


Objective

To build and compare robust CNN models using TensorFlow and PyTorch for classification using image data. This forms part of a portfolio-ready end-to-end ML project including model training, evaluation, and web deployment.


Components

TensorFlow Training

  • Data Augmentation: RandomFlip, RandomZoom, RandomRotation, etc.
  • CNN Layers + BatchNorm + Dropout
  • GlobalAveragePooling2D + Dense layers
  • Regularization with L1L2
  • EarlyStopping and ModelCheckpoint callbacks

PyTorch Training

  • CNN architecture with similar depth and regularization
  • AdaptiveAvgPool2d instead of GAP
  • Dropout and BatchNorm used
  • Best model saved using torch.save

Repository Structure

.
├── TFTrain.py               # TensorFlow training script
├── TFTest.py                # TensorFlow testing script
├── TorchTrain.py            # PyTorch training script
├── TorchTest.py             # PyTorch testing script
├── reports/                 # Confusion matrices and evaluation visuals
├── Data/
│   ├── train/
│   ├── val/
│   └── test/
├── requirements.txt         # Dependencies
├── README.md                
└── LICENSE                  # MIT License


Evaluation Results

  • TensorFlow

    • Best Training Accuracy: 84.25%, Training Loss: 0.5474, Validation Accuracy: 83.0%, Validation Loss: 0.5870
  • PyTorch

    • Best Training Accuracy: 87.01%, Training Loss: 0.3631, Validation Accuracy: 87.1%, Validation Loss: 0.3473

Evaluation Metrics (Seaborn + Matplotlib):

  • Classification Reports
  • Confusion Matrices

TensorFlow Model

TensorFlow Confusion Matrix

PyTorch Model

PyTorch Confusion Matrix

How to Train

TensorFlow

python TFTrain.py
python TFTest.py

PyTorch

python TorchTrain.py
python TorchTest.py

Make sure your dataset is placed in the Data/ directory with subfolders:

Data/
├── train/
├── val/
└── test/
  • Note: If the Data doesn't have Validation or Test Data Sets, you can divide training Data Set using Split.py uploaded within Data folder. Rename the corresponding datasets in the code.

Example:

cd Data
python Split.py ./path # Replace the ./path with your training dataset. Note that you shouldn't name the path as train, val or test to run the code.
cd ..

Dependencies

pip install -r requirements.txt
  • TensorFlow
  • PyTorch
  • matplotlib, seaborn, scikit-learn

GPU acceleration is recommended if available.


Highlights

  • Dual framework training (TF + Torch)
  • Data augmentation and regularization
  • Clean modular design for reproducibility
  • Evaluation visualizations for clarity
  • Ready for deployment in Flask app

Deployment

The trained models from this repository are integrated into a Flask-based Image Prediction API, allowing you to interact with the models via a simple web interface or programmatically.

You can try out the deployed models here:

Image Prediction API Repository

The API supports both TensorFlow and PyTorch models and provides:

  • A web interface for image upload & prediction
  • REST API endpoint for programmatic access
  • Sample usage with unseen images for real-world testing

License

MIT License – see LICENSE for full details.


Author

Created by JAGAN-JGUN for professional portfolio showcasing.


Contact

For queries or collaboration:

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages