Jovian
Sign In

Stanford Cars

Stanford-cars Image Classification

alt

The objective of this notebook is to showcase the use of Deep Neural Networks in a real life classification project scenario and to display how powerful and applicable pretrained Neural Networks are.

To achieve that we will seek to successfully classify Stanford Cars into their rightful classes. We'll use the Stanford Cars dataset from https://www.kaggle.com/jutrera/stanford-car-dataset-by-classes-folder .We have 16,185 images of 196 classes of cars. The data is split into 8,144 training images and 8,041 testing images, where each class has been split roughly in a 50-50 split. Classes are typically at the level of Make, Model, Year.

In this notebook you will find

  1. Convolutional Neural Networks
  2. Data Augmentation, Regularization and ResNets
  3. The ResNet 9 Model built from scratch
  4. Modification and Utilization of pretrained resnet models i.e. Resnet34

Downloading the Dataset

We can use the opendatasets library to download the dataset from Kaggle. opendatasets uses the Kaggle Official API for downloading datasets from Kaggle.

!pip install opendatasets --upgrade --quiet
import os
import torch
import torchvision
import tarfile
import torch.nn as nn
import numpy as np
import torch.nn.functional as F
from torchvision.datasets.utils import download_url
from torchvision.datasets import ImageFolder
from torch.utils.data import DataLoader
import torchvision.transforms as tt
from torch.utils.data import random_split
from torchvision.utils import make_grid
from torchvision.transforms import ToTensor
import matplotlib
import matplotlib.pyplot as plt
%matplotlib inline

matplotlib.rcParams['figure.facecolor'] = '#ffffff'
import opendatasets as od

dataset_url = 'https://www.kaggle.com/jutrera/stanford-car-dataset-by-classes-folder'
od.download(dataset_url)
Downloading stanford-car-dataset-by-classes-folder.zip to ./stanford-car-dataset-by-classes-folder
100%|██████████| 1.83G/1.83G [00:52<00:00, 37.2MB/s]