Thanks to visit codestin.com
Credit goes to github.com

Skip to content

AIResearchForge/Weather-Image-Classification

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

38 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

🌦️ Weather Image Classification β€” TensorFlow

A weather-phenomenon classifier based on a single photograph, built on Transfer Learning, Fine Tuning, and Grad-CAM on the EfficientNetB0 architecture (TensorFlow / Keras). A project presenting a full, production-style pipeline: from data, through training, to evaluation, model explainability, and a ready-to-use prediction function for new images.


πŸ“– Project Description

The model recognizes 11 weather phenomena from a single photograph: dew, fogsmog, frost, glaze, hail, lightning, rain, rainbow, rime, sandstorm, snow.

The goal of this project is to demonstrate how TensorFlow/Keras can be used for image classification by covering the entire workflowβ€”from data exploration and augmentation, through two-stage training (transfer learning followed by fine-tuning), comprehensive evaluation using multiple performance metrics, to model explainability with Grad-CAM and a production-ready prediction pipeline for new data.

🧠 Model Architecture

Input (224, 224, 3)
        ↓
Data Augmentation (RandomFlip, RandomRotation, RandomZoom, RandomContrast, RandomBrightness)
        ↓
EfficientNetB0 (base, ImageNet weights)
   Phase 1: fully frozen (transfer learning)
   Phase 2: last 30 layers unfrozen, low learning rate (fine-tuning)
        ↓
GlobalAveragePooling2D
        ↓
Dropout (0.3)
        ↓
Dense (11, softmax)

Training strategy β€” two phases:

Phase Base model Learning rate Goal
1. Transfer Learning frozen 1e-3 training the classification head
2. Fine Tuning last 30 layers unfrozen 1e-5 precise adjustment of high-level features

πŸ› οΈ Technologies Used

  • TensorFlow 2.x / Keras β€” model building and training
  • EfficientNetB0 (tf.keras.applications) β€” transfer learning base
  • Data Augmentation β€” Keras layers (RandomFlip, RandomRotation, RandomZoom, RandomContrast, RandomBrightness)
  • Callbacks: EarlyStopping, ModelCheckpoint, ReduceLROnPlateau, TensorBoard
  • Grad-CAM β€” model decision explainability (Explainable AI)
  • scikit-learn β€” precision, recall, F1-score, confusion matrix, classification report
  • Pandas / Matplotlib / Seaborn β€” data analysis and visualization
  • Kaggle API β€” dataset download

πŸ“Š Results

Metric values are generated automatically in the notebook (Sections 14–20) after training and depend on the specific training run and hardware.

Metric
Test Accuracy
Precision (macro)
Recall (macro)
F1-score (macro)

Full results (confusion matrix, per-class classification report, training curves) are automatically saved to the results/ folder:

  • results/metrics_summary.csv
  • results/classification_report.csv
  • results/confusion_matrix.png
  • results/training_curves.png

Saved predictions on new images (Section 27) go to the predictions/ folder.

πŸš€ Setup Instructions

1. Clone the repository

git clone https://github.com/AIResearchForge/Weather-Image-Classification.git
cd Weather-Image-Classification

2. Virtual environment and dependencies

python -m venv venv
source venv/bin/activate  # Windows: venv\Scripts\activate
pip install -r requirements.txt

3. Kaggle API key (to download the dataset)

  1. Create a free account at kaggle.com.
  2. Account β†’ API β†’ Create New API Token β€” this downloads a kaggle.json file.
  3. The notebook will interactively prompt for KAGGLE_USERNAME and KAGGLE_KEY (getpass) β€” you'll find the values in the downloaded kaggle.json file. They are never hard-coded anywhere.

4. Run the notebook

jupyter notebook notebooks/Weather_Image_Classification_TensorFlow.ipynb

The notebook can also be run directly in Google Colab (recommended β€” free GPU access): just upload the .ipynb file and set Runtime β†’ Change runtime type β†’ GPU.

5. Predict on your own image(Section 27)

A full "file-to-result" inference pipeline β€” with automatic saving of the prediction result (image + label + confidence) to the predictions/ folder, simulating how results might be archived in a real application.

How to actually use this function on your own image β€” three ways:

1. Google Colab (easiest): run the cell below β€” a "Choose Files" button will appear, letting you pick an image from your computer. It will be automatically uploaded to the notebook and classified.

2. Local Jupyter / any environment: upload your image to the images/ folder in the repository, then in a new cell call:
predict_new_image("images/my_photo.jpg", loaded_model, loaded_class_names)
(replacing the filename with your own).

3. Image already present on the server/Colab disk β€” simply provide the full path to it as the first argument of the function.

πŸ“ Repository Structure

Weather-Image-Classification/
β”œβ”€β”€ docs/
β”œβ”€β”€ images/
β”œβ”€β”€ models/
β”œβ”€β”€ notebooks/
β”‚   └── Weather_Image_Classification_TensorFlow.ipynb
|   └── Weather_Image_Classification_TensorFlow_example.ipynb                 
β”œβ”€β”€ predictions/        
β”œβ”€β”€ results/           
β”œβ”€β”€ .gitignore         
β”œβ”€β”€ LICENSE
β”œβ”€β”€ README.md
└── requirements.txt

πŸ—ΊοΈ Development Roadmap

  • Larger EfficientNet variants (B3–B7) or newer architectures (ConvNeXt, ViT)
  • Combine with additional weather datasets (WEAPD and others) β€” a larger, better-balanced data pool
  • Multi-label classification (co-occurrence of several phenomena in one image)
  • Temporal sequence analysis from monitoring cameras (CNN+LSTM, video transformers)
  • Export to TensorFlow Lite / ONNX for edge devices (weather stations)
  • Deployment as a REST API (FastAPI + Docker) with Grad-CAM in the API response
  • Active learning for the least confident predictions
  • Production model monitoring (e.g. MLflow) β€” data drift detection

A full description of the model's limitations and possible development directions can be found in Sections 29–30 of the notebook.

πŸ“„ License

This project is released under the MIT license. The Weather Dataset is subject to the license set by its author β€” see Kaggle β€” jehanbhathena/weather-dataset.

πŸ‘€ Author

AIResearchForge β€” a TensorFlow/Keras-based project for image classification, featuring Transfer Learning, Fine-Tuning, and model explainability using Grad-CAM.

About

Weather phenomenon classifier using EfficientNetB0 Transfer Learning, Fine-Tuning and Grad-CAM (TensorFlow/Keras)

Topics

Resources

License

Stars

0 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors