AI Weather Classification

An implementation of a convolutional neuronal net with pytorch to classify weather conditions from pictures

Overview

This project delivers an end‑to‑end image classification pipeline for detecting 11 distinct weather phenomena (dew, fog/smog, frost, glaze, hail, lightning, rain, rainbow, rime, sandstorm, snow) using a custom convolutional neural network in PyTorch. It provides:

Tech Stack

Getting Started

  1. Clone the repo: git clone https://github.com/Nicolas2912/AI-Weather-Classification.git cd AI-Weather-Classification
  2. Create & activate a Conda environment: conda create -n weather-classification python=3.9.13 conda activate weather-classification
  3. Install dependencies (note the repository’s pip lockfile is requierements.txt): pip install -r requierements.txt

Usage

Training

Train a new model (saves to models/weather-model.pth by default):

python src/training/train_model.py \
    --data dataset \
    --device cuda \
    --epochs 28 \
    --model_path models/my-weather-model.pth \
    --verbose True

Hyperparameter Optimization

Run Optuna study (small or large mode):

python src/training/optimize_hyperparameters.py \
    --data dataset \
    --n_trials 50 \
    --epochs 10 \
    --device cuda \
    --mode small \
    --study_name my-weather-study

View live dashboard:

optuna-dashboard sqlite:///db.sqlite3

Evaluation

Evaluate a trained model on the test split and save confusion matrix:

python src/evaluation/evaluation.py \
    --data dataset \
    --model models/my-weather-model.pth \
    --device cuda

Prediction

Batch‑predict on a folder of images:

python src/prediction/predict.py \
    --model models/my-weather-model.pth \
    --images test_images/test_image_class \
    --dataset dataset \
    --device cuda

Usage Highlights

Architecture & Components

Core Modules

Supporting Artifacts

Tests

There is no formal unit‑test suite yet; instead, a small set of labeled images under test_images/test_image_class can be used to verify end‑to‑end inference correctness.

Challenges

1. Building a CNN from Scratch in PyTorch

Implemented Solution

Why This Approach

Future Improvements

2. Hyperparameter Optimization under Resource Constraints

Implemented Solution

Why This Approach

Future Improvements

What I Learned

Improvements I’d Like to Make

Screenshots

Loss Confusion Matrix

View on GitHub