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.
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
- 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
- Python 3.x
- TensorFlow / Keras
- NumPy
- Pandas
- Matplotlib / Seaborn
- Jupyter Notebook
- (Optional) GPU support for faster training
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()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
- Clone the repository:
git clone https://github.com/Username1234jj/Cifar-10-image-classification.git cd Cifar-10-image-classification - Install dependencies:
pip install -r requirements.txt
- If not downloaded automatically, place the CIFAR-10 dataset in the
data/folder.
To run using Python script:
python model.pyTo run using Jupyter Notebook:
jupyter notebook cifar10_classification.ipynbFollow the steps in the notebook to train, evaluate, and visualize the model results.
- Load and preprocess the CIFAR-10 dataset (normalize pixel values and one-hot encode labels)
- Define a CNN model architecture with convolution, pooling, and dense layers
- Compile the model using categorical cross-entropy loss and Adam optimizer
- Train the model on training data and validate on test data
- Evaluate performance metrics like accuracy, loss, and confusion matrix
- Visualize training results and predictions
- Save the trained model for future use
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
- 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
- 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
This project is open-source and free to use for educational purposes.