Learn practical skills, build real-world projects, and advance your career

#Image classification with the Coil-100 dataset

COIL-100 was collected by the Center for Research on Intelligent Systems at the Department of Computer Science , Columbia University. The database contains color images of 100 objects. The objects were placed on a motorized turntable against a black background and images were taken at pose internals of 5 degrees. This dataset was used in a real-time 100 object recognition system whereby a system sensor could identify the object and display its angular pose.

In this example, I will utilize transfer learning with the VGG-11 pre-trained convolutional network. I will add a custom classification layer to it and train it on GPU.

Downloading data from Kaggle...

import opendatasets as od
dataset_url = 'https://www.kaggle.com/jessicali9530/coil100'
Please provide your Kaggle credentials to download this dataset. Learn more: http://bit.ly/kaggle-creds Your Kaggle username: triaprima Your Kaggle Key: ··········
21%|██▏ | 27.0M/127M [00:00<00:00, 276MB/s]
Downloading coil100.zip to ./coil100
100%|██████████| 127M/127M [00:00<00:00, 297MB/s]
import os, glob
import torch
import pandas as pd
import numpy as np
from torch.utils.data import Dataset, random_split, DataLoader
from PIL import Image, ImageStat
import torchvision.models as models
from torch import optim
import matplotlib.pyplot as plt
import torchvision.transforms as transforms
from torchvision.utils import make_grid
import torch.nn.functional as F
import torch.nn as nn
from torchvision.utils import make_grid
from collections import OrderedDict
%matplotlib inline
DATA_DIR = './coil100/coil-100/coil-100'
file_list = glob.glob(f'{DATA_DIR}/*.png')
# extracting file names and related labels
f_names_labels = [(f.split('/')[-1], int(f.split('/')[-1].split('__')[0].split('obj')[1]))   for f in file_list]