Skip to content

Demonstration of the CIFAR-10 deeplearning task with PyTorch and TensorFlow

License

Notifications You must be signed in to change notification settings

gperdrizet/CIFAR10

Repository files navigation

CIFAR-10 Image Classification Tutorial

Publish to PyPI Deploy Documentation

This repository demonstrates deep learning techniques for image classification using the CIFAR-10 benchmark dataset. Through a series of progressively more sophisticated models, it shows how different neural network architectures and training techniques improve classification performance.

Package: The tools developed for this project are available as image-classification-tools on PyPI for use in your own projects.

Documentation: gperdrizet.github.io/CIFAR10

About the dataset

CIFAR-10 consists of 60,000 32×32 color images across 10 classes:

  • Training set: 50,000 images (40,000 for training, 10,000 for validation)
  • Test set: 10,000 images
  • Classes: airplane, automobile, bird, cat, deer, dog, frog, horse, ship, truck

The models

  1. 01-DNN.ipynb - Baseline fully-connected deep neural network on grayscale images
  2. 02-CNN.ipynb - Convolutional neural network to exploit spatial relationships
  3. 03-RGB-CNN.ipynb - CNN modified to process full RGB color information
  4. 04-optimized-CNN.ipynb - Bayesian hyperparameter optimization with Optuna
  5. 05-augmented-CNN.ipynb - Data augmentation for improved generalization

Getting started

Prerequisites

Setup

  1. Clone the repository:
git clone https://github.com/gperdrizet/CIFAR10.git
cd CIFAR10
  1. Open in VS Code:
code .
  1. When prompted, click "Reopen in Container" or use the command palette (Ctrl+Shift+P / Cmd+Shift+P) and select "Dev Containers: Reopen in Container"

  2. Wait for the container to build and initialize (first time only). The devcontainer will:

    • Set up the Python environment
    • Install all dependencies
    • Download the CIFAR-10 dataset

Running the notebooks

Once the container environment loads, you should be all set - you can start running the notebooks! Note: run them in order - some depend on output generated by earlier notebooks.

Pre-trained models

Models from each experiment are saved in models/pytorch/:

  • dnn.pth - Baseline DNN
  • cnn.pth - Basic CNN
  • rgb_cnn.pth - RGB CNN
  • optimized_cnn.pth - Hyperparameter-optimized CNN
  • augmented_cnn.pth - Optimized CNN trained on augmented data

Environment

All experiments use:

  • Python 3.10+
  • PyTorch 2.0+
  • NVIDIA GPU with CUDA support (when available)

Dependencies

Core requirements:

  • python ≥3.10, <3.13
  • torch ≥2.0
  • torchvision ≥0.15
  • numpy ≥1.24
  • matplotlib ≥3.7
  • optuna ≥3.0
  • scikit-learn ≥1.3

See pyproject.toml for complete dependency specifications.

Citation

If you find this project helpful for your learning or work, feel free to reference it:

@software{cifar10_tutorial,
  author = {Perdrizet, George},
  title = {CIFAR-10 Image Classification Tutorial},
  year = {2024},
  url = {https://github.com/gperdrizet/CIFAR10}
}

License

This project is licensed under the GPLv3 License - see the LICENSE file for details.