STATUS: ABANDONED
Post-mortem: this project has been discontinued. While a functional classification pipeline was established, the model struggled to generalise effectively. The primary blockers were:
- High-variance anatomy — Pokémon designs exhibit extreme morphological diversity within the same type (e.g. Charmander vs. Torkoal), making visual patterns difficult for a standard CNN to capture without massive data.
- Insufficient data — the available dataset provided too few examples per class to overcome the high variance, likely leading to overfitting or poor feature representation.
Project Overview
This project aimed to build a deep learning system to classify Pokémon types from images using PyTorch and Hugging Face's datasets. The goal was to train a custom CNN to predict up to two types for a given Pokémon image.
Implemented Features
1. Data pipeline & analysis
- Integration: integrated the
pranavs28/pokemon_typesdataset. - Distribution analysis: mapped class imbalances using
analyze_distribution.pyto understand the prevalence of types like Water/Normal vs. rarer types like Ice/Ghost. - Normalisation: calculated custom normalisation statistics (mean/std) specifically for this dataset using
normalization_calculator.pyto ensure optimal model convergence.- Mean:
[0.8412, 0.8291, 0.8151] - Std:
[0.2417, 0.2473, 0.2593]
- Mean:
2. Model architecture
- Custom CNN: a 6-layer convolutional neural network with
- adaptive average pooling
(4,4)to handle spatial feature variations, - dropout (
0.5) in fully connected layers to mitigate overfitting.
- adaptive average pooling
- Multi-label support: designed for 18 distinct types using a multi-hot encoding scheme.
3. Training strategy (classifier_training.py)
- Loss function:
BCEWithLogitsLosswith calculated class weights (pos_weights) to counter the significant dataset imbalance (e.g. Water types being much more common than Ice). - Optimiser: SGD with momentum (
0.9) for stable convergence. - Artifacts: saves the best model state to
pokemon_classifier.pth.
4. Inference & visualisation (run_classifier.py)
- Preprocessing: robust pipeline resizing images to 512×512 and applying the calculated normalisation.
- Inference engine: loads the trained model and applies threshold-based prediction logic.
- Visualiser: uses
extract_types()and Matplotlib to display side-by-side comparisons of ground truth vs. predicted types.
Project Structure
Himantes/
├── classifier_training.py # Main training script (model definition + training loop)
├── run_classifier.py # Inference script for visualisation and testing
├── analyze_distribution.py # Utility to analyse dataset class distribution
├── normalization_calculator.py # Script to compute dataset mean/std
├── requirements.txt # Project dependencies
└── README.md # Project documentation
Dependencies
torch(PyTorch)datasets(Hugging Face)torchvisionmatplotlibnumpy
Usage (Historical)
1. Train the model
python classifier_training.py
2. Run inference (visualise results)
python run_classifier.py
3. Utilities
python normalization_calculator.py
python analyze_distribution.py