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.
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.
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 |
- 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
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.csvresults/classification_report.csvresults/confusion_matrix.pngresults/training_curves.png
Saved predictions on new images (Section 27) go to the predictions/ folder.
git clone https://github.com/AIResearchForge/Weather-Image-Classification.git
cd Weather-Image-Classificationpython -m venv venv
source venv/bin/activate # Windows: venv\Scripts\activate
pip install -r requirements.txt- Create a free account at kaggle.com.
- Account β API β Create New API Token β this downloads a
kaggle.jsonfile. - The notebook will interactively prompt for
KAGGLE_USERNAMEandKAGGLE_KEY(getpass) β you'll find the values in the downloadedkaggle.jsonfile. They are never hard-coded anywhere.
jupyter notebook notebooks/Weather_Image_Classification_TensorFlow.ipynbThe 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.
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.
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
- 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.
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.
AIResearchForge β a TensorFlow/Keras-based project for image classification, featuring Transfer Learning, Fine-Tuning, and model explainability using Grad-CAM.