Skip to content

Username1234jj/Cifar-10-image-classification

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 

Repository files navigation

CIFAR-10 Image Classification

Python TensorFlow License Dataset Status

This project trains a deep learning model to classify images from the CIFAR-10 dataset, which contains 60,000 32x32 color images in 10 classes. The goal is to build, train, and evaluate a convolutional neural network (CNN) that can correctly classify these small images into categories such as airplane, automobile, bird, cat, deer, dog, frog, horse, ship, and truck.

Overview

Using the CIFAR-10 dataset, this project demonstrates how to:

  • Load and preprocess image data
  • Perform data augmentation and normalization
  • Define a convolutional neural network architecture
  • Train the model on the training data
  • Evaluate on the unseen test data
  • Visualize results (accuracy/loss curves, confusion matrix)
  • (Optional) Save and reload the trained model for inference

Features

  • Load the CIFAR-10 dataset (or custom image data)
  • Preprocess images (scaling, normalization)
  • Apply data augmentation (flip, crop, rotate) to improve generalization
  • Define and train a CNN model with Keras/TensorFlow
  • Track training history and plot accuracy & loss curves
  • Evaluate model performance with a confusion matrix and classification report
  • Predict class labels for new images and display sample results

Technologies & Libraries Used

  • Python 3.x
  • TensorFlow / Keras
  • NumPy
  • Pandas
  • Matplotlib / Seaborn
  • Jupyter Notebook
  • (Optional) GPU support for faster training

Dataset

The CIFAR-10 dataset consists of 60,000 color images of size 32x32 pixels across 10 classes, with 6,000 images per class. There are 50,000 training images and 10,000 test images.

If you want to download it manually, visit the official CIFAR-10 website: https://www.cs.toronto.edu/~kriz/cifar.html

If using Keras, you can directly load it with:

from tensorflow.keras.datasets import cifar10
(x_train, y_train), (x_test, y_test) = cifar10.load_data()

Project Structure

Cifar-10-image-classification/
│
├── model.py                     # main script for training and testing the model
├── cifar10_classification.ipynb # Jupyter Notebook with step-by-step workflow
├── data/                        # folder for storing data if needed
│   └── cifar-10-batches-py/
├── saved_models/                # trained model weights
│   └── cnn_cifar10.h5
├── requirements.txt             # dependencies file
└── README.md

Installation and Setup

  1. Clone the repository:
    git clone https://github.com/Username1234jj/Cifar-10-image-classification.git
    cd Cifar-10-image-classification
  2. Install dependencies:
    pip install -r requirements.txt
  3. If not downloaded automatically, place the CIFAR-10 dataset in the data/ folder.

How to Run

To run using Python script:

python model.py

To run using Jupyter Notebook:

jupyter notebook cifar10_classification.ipynb

Follow the steps in the notebook to train, evaluate, and visualize the model results.

How It Works

  1. Load and preprocess the CIFAR-10 dataset (normalize pixel values and one-hot encode labels)
  2. Define a CNN model architecture with convolution, pooling, and dense layers
  3. Compile the model using categorical cross-entropy loss and Adam optimizer
  4. Train the model on training data and validate on test data
  5. Evaluate performance metrics like accuracy, loss, and confusion matrix
  6. Visualize training results and predictions
  7. Save the trained model for future use

Example Output

After training for 50 epochs, you might see something like:

Test Accuracy: 84.7%
Test Loss: 0.58

Sample prediction output:

True Label: Cat
Predicted Label: Cat

Graph output includes:

  • Training and validation accuracy curves
  • Confusion matrix of test results

Future Improvements

  • Implement advanced CNN architectures like ResNet, VGG16, or Inception
  • Add dropout, batch normalization, or learning rate schedulers
  • Experiment with more data augmentation techniques
  • Use transfer learning from pre-trained models
  • Build a web app for image upload and classification using Flask or Streamlit
  • Deploy the model using TensorFlow Serving or Docker

Acknowledgements

  • CIFAR-10 dataset by Alex Krizhevsky, Vinod Nair, and Geoffrey Hinton
  • TensorFlow and Keras documentation and tutorials
  • Open-source projects and blogs on CNNs and image classification

License

This project is open-source and free to use for educational purposes.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors