Skip to content

AthanKanavos/Weather-Image-Classification-CNN

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Advancing Weather Image Classification using Deep Convolutional Neural Networks

TensorFlow/Keras implementation of the convolutional neural network architectures presented in the paper:

Advancing Weather Image Classification using Deep Convolutional Neural Networks

This repository accompanies the associated publication and provides a TensorFlow/Keras implementation of the proposed methodology.

Task

Five-class weather image classification:

  • Cloudy
  • Foggy
  • Rainy
  • Shine
  • Sunrise

Dataset

The paper uses the Kaggle Multi-class Weather Dataset:

https://www.kaggle.com/datasets/vijaygiitk/multiclass-weather-dataset

The publication reports approximately 1,500 labeled images, with the following class distribution:

Class Images
Cloudy 300
Foggy 300
Rainy 300
Shine 250
Sunrise 350

An additional alien-test folder contains 30 images, with labels provided in a CSV file.

Expected directory structure:

dataset/
├── Cloudy/
├── Foggy/
├── Rainy/
├── Shine/
├── Sunrise/
├── alien-test/
└── alien-test-labels.csv

The alien-test folder and CSV file are optional for standard train/validation evaluation.

CNN Architectures

Architecture 1

(Conv2D → MaxPooling2D) ×3
→ GlobalAveragePooling2D
→ Flatten
→ Dense(256)
→ Dropout
→ Softmax Output

Architecture 2

(Conv2D ×2 → MaxPooling2D) ×3
→ GlobalAveragePooling2D
→ Flatten
→ Dense(256)
→ Dropout
→ Softmax Output

Architecture 3

(Conv2D ×3 → MaxPooling2D) ×3
→ GlobalAveragePooling2D
→ Flatten
→ Dense(256)
→ Dropout
→ Softmax Output

Implementation Details

The implementation follows the methodology presented in the paper and uses the following configuration:

  • Input size: 224 × 224 × 3
  • Five-class softmax classification
  • Kernel size: 3 × 3
  • Filter progression: 32 → 64 → 128
  • Activation: ReLU
  • Optimizer: Adam
  • Learning rate: 1e-3
  • Loss: Sparse categorical cross-entropy
  • Dense layer: 256 units
  • Dropout: 0.50
  • Default epochs: 50
  • Data augmentation:
    • Rotation
    • Zoom/scaling
    • Horizontal flipping
  • Class weighting to support imbalanced class distributions
  • Random seed: 42

Project Structure

Weather-Image-Classification-CNN/
├── README.md
├── LICENSE
├── requirements.txt
├── train.py
├── evaluate.py
├── predict.py
├── .gitignore
├── outputs/
└── src/
    ├── __init__.py
    ├── data.py
    ├── models.py
    └── utils.py

Installation

python -m venv .venv

Windows:

.venv\Scripts\activate

Linux/macOS:

source .venv/bin/activate
pip install -r requirements.txt

Training

Architecture 1:

python train.py \
  --data-dir "path/to/dataset" \
  --architecture 1 \
  --batch-size 128 \
  --epochs 50

Architecture 2:

python train.py \
  --data-dir "path/to/dataset" \
  --architecture 2 \
  --batch-size 128 \
  --epochs 50

Architecture 3:

python train.py \
  --data-dir "path/to/dataset" \
  --architecture 3 \
  --batch-size 128 \
  --epochs 50

Batch sizes evaluated in the paper:

128, 256, 512, 1024

Evaluation

python evaluate.py \
  --data-dir "path/to/dataset" \
  --model-path "outputs/architecture_1/best_model.keras"

The evaluation script produces:

  • Loss
  • Accuracy
  • Confusion matrix
  • Classification report
  • Per-class precision, recall, and F1-score

Prediction

python predict.py \
  --model-path "outputs/architecture_1/best_model.keras" \
  --image-path "path/to/weather-image.jpg"

Published Results

The first architecture achieved the strongest reported validation accuracy.

Architecture Batch Size Final Loss Final Accuracy
Architecture 1 128 0.0549 98.10%
Architecture 2 128 0.1834 93.43%
Architecture 3 128 0.4064 86.48%

Results may vary depending on the software environment, preprocessing pipeline, random initialization, hyperparameter configuration, and hardware platform.

Citation

If you use this implementation in your research, please cite the original paper.

@inproceedings{DBLP:conf/smap/PapadimitriouKMM23,
  author       = {Orestis Papadimitriou and
                  Athanasios Kanavos and
                  Phivos Mylonas and
                  Manolis Maragoudakis},
  title        = {Advancing Weather Image Classification Using Deep Convolutional Neural
                  Networks},
  booktitle    = {18th International Workshop on Semantic and Social Media Adaptation
                  and Personalization, {SMAP} 2023, Limassol, Cyprus, September 25-26,
                  2023},
  pages        = {1--6},
  publisher    = {{IEEE}},
  year         = {2023},
  url          = {https://doi.org/10.1109/SMAP59435.2023.10255190},
  doi          = {10.1109/SMAP59435.2023.10255190},
  timestamp    = {Mon, 03 Mar 2025 21:22:07 +0100},
  biburl       = {https://dblp.org/rec/conf/smap/PapadimitriouKMM23.bib},
  bibsource    = {dblp computer science bibliography, https://dblp.org}
}

License

This project is released under the MIT License.

Releases

Packages

Contributors

Languages