Skip to content
Snippets Groups Projects

Image classification

This project is an image classification program. It is trained and tested using the CIFAR dataset. Two methods are used to perform image classification: k-nearest neighbours and neural networks.

Description

First, the CIFAR dataset is loaded and prepared to be used. Then, the k-nearest neighbours method is used to perform image classification. Finally, neural networks are used to perform image classification.

Prepare the CIFAR dataset

Each image is made 32x32 pixels. Each pixel is in color, and therefore has 3 numbers representing it. For each batch we have the following parameters:

  • batch_size = 10000,
  • data_size = 32x32x3 = 3072. For the entire datasets (5 train batches and 1 test batch), we have the following parameters:
  • batch_size = 60000,
  • data_size = 32x32x3 = 3072. Each batch is unpickled. All batches are concatenated into a matrix data and a list labels. They are then suffled and split to create training and test datasets.

k-nearest neighbours

We develop a knn model to predict the image labels.

mlp

We use the binary cross entropy to train our model.

Usage

We run the jupyter notebook to obtain the results.