Skip to content

95% accurate weather image classifier with TensorFlow and Grad-CAM. Demonstrates production ready ML skills: transfer learning, data augmentation, interpretability, and error analysis.

Notifications You must be signed in to change notification settings

DavidShableski/weather-image-classification

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

27 Commits
 
 
 
 

Repository files navigation

Weather Image Classifier (TensorFlow + Grad-CAM)

A transfer learning + interpretability project using TensorFlow, achieving 95% accuracy on real world weather imagery.


Highlights

  • Achieved 95% test accuracy classifying 5 weather types using MobileNetV2 with transfer learning.
  • Enhanced model transparency with Grad-CAM visualizations, exposing attention maps for each prediction.
  • Automated image preprocessing pipeline with data augmentation and clean train/test split generation.
  • Tuned model using early stopping and learning rate scheduling to prevent overfitting.
  • Visualized performance with training curves and confusion matrix for multi class error analysis.

Overview

This project simulates a lightweight real world image classifier for weather conditions—potentially applicable to travel, safety, or photo metadata tagging.

Built using TensorFlow/Keras with transfer learning via MobileNetV2, enhanced by real time data augmentation, early stopping, learning rate scheduling, and visual explanations using Grad-CAM.


Results

  • Test Accuracy: 95%
  • Classes: sunny, rainy, cloudy, snowy, sunrise
  • Model: MobileNetV2 (frozen base) + custom dense head
  • Interpretability: Grad-CAM visualizations show model attention
  • Grad-CAM revealed that the model focused on sky textures in cloudy scenes and horizon color gradients in “sunrise” images—aligning with human intuition.

Why this project matters

This project goes beyond basic image classification. It integrates real world techniques transfer learning, data augmentation, interpretability, and evaluation—to reflect what’s expected in production ML workflows. The Grad-CAM heatmaps promote model transparency, a key concern in deploying AI systems responsibly.


Core Features

  • Transfer learning with MobileNetV2 (ImageNet pretraining)
  • Custom dense head with dropout regularization
  • Real time image augmentation: rotation, zoom, brightness, shear, etc.
  • Grad-CAM overlay to interpret predictions
  • Confusion matrix for error analysis
  • EarlyStopping and ReduceLROnPlateau to prevent overfitting

Sample Grad-CAM Output

image

Directory Structure

  weatherimages/ ├── raw/ # Original images by class ├── train/ # 80% training images ├── test/ # 20% test images └── weather_image_classification.ipynb  

Training Performance

  • 20 epochs
  • Early stopping triggered around epoch 19
  • Validation accuracy stabilized above 94%
  • Loss and accuracy trends plotted over epochs
  • Error patterns analyzed using a confusion matrix (scikit-learn)
image image

Dataset

The full training and test dataset (5 weather classes, ~1,000 images) is hosted on Hugging Face:

Download weatherimages.zip This dataset is shared for educational and research purposes only.

After downloading, unzip and place the folder under weatherimages/ in your project root.


Tech Stack

  • Frameworks: TensorFlow, Keras
  • Tools: Google Colab, OpenCV, Matplotlib
  • Languages: Python 3.11.13

Potential Extensions

  • Fine tune deeper layers to boost performance beyond 95%
  • Benchmark against other backbones like ResNet50 or EfficientNet
  • Deploy as an interactive app (e.g., Streamlit) for real time predictions
  • Export to TFLite or ONNX to enable on device inference

Author

David Shableski — GitHub
Project created to demonstrate practical AI engineering skills for portfolio use.

Releases

No releases published

Packages

No packages published