Learn practical skills, build real-world projects, and advance your career
# Jovian Commit Essentials
# Please retain and execute this cell without modifying the contents for `jovian.commit` to work
!pip install jovian --upgrade -q
import jovian
jovian.set_project('05b-cifar10-resnet')
jovian.set_colab_id('11XXGZwNC6WAYL4pNqjwEd4bqbTcBeYLm')
|████████████████████████████████| 71kB 9.5MB/s eta 0:00:01 Building wheel for uuid (setup.py) ... done
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
import matplotlib
import matplotlib.pyplot as plt
%matplotlib inline

matplotlib.rcParams['figure.facecolor'] = '#ffffff'
!pip install opendatasets
import opendatasets as op
op.download_kaggle_dataset("https://www.kaggle.com/moltean/fruits?select=fruits-360", "data/")
Collecting opendatasets Downloading https://files.pythonhosted.org/packages/18/99/aaa3ebec81dc347302e730e0daff61735ed2f3e736129553fb3f9bf67ed3/opendatasets-0.1.10-py3-none-any.whl Requirement already satisfied: click in /usr/local/lib/python3.6/dist-packages (from opendatasets) (7.1.2) Requirement already satisfied: tqdm in /usr/local/lib/python3.6/dist-packages (from opendatasets) (4.41.1) Requirement already satisfied: kaggle in /usr/local/lib/python3.6/dist-packages (from opendatasets) (1.5.10) Requirement already satisfied: six>=1.10 in /usr/local/lib/python3.6/dist-packages (from kaggle->opendatasets) (1.15.0) Requirement already satisfied: certifi in /usr/local/lib/python3.6/dist-packages (from kaggle->opendatasets) (2020.12.5) Requirement already satisfied: requests in /usr/local/lib/python3.6/dist-packages (from kaggle->opendatasets) (2.23.0) Requirement already satisfied: python-dateutil in /usr/local/lib/python3.6/dist-packages (from kaggle->opendatasets) (2.8.1) Requirement already satisfied: urllib3 in /usr/local/lib/python3.6/dist-packages (from kaggle->opendatasets) (1.24.3) Requirement already satisfied: python-slugify in /usr/local/lib/python3.6/dist-packages (from kaggle->opendatasets) (4.0.1) Requirement already satisfied: chardet<4,>=3.0.2 in /usr/local/lib/python3.6/dist-packages (from requests->kaggle->opendatasets) (3.0.4) Requirement already satisfied: idna<3,>=2.5 in /usr/local/lib/python3.6/dist-packages (from requests->kaggle->opendatasets) (2.10) Requirement already satisfied: text-unidecode>=1.3 in /usr/local/lib/python3.6/dist-packages (from python-slugify->kaggle->opendatasets) (1.3) Installing collected packages: opendatasets Successfully installed opendatasets-0.1.10 Please provide your Kaggle credentials to download this dataset. Learn more: http://bit.ly/kaggle-creds Your Kaggle username: ffreller Your Kaggle Key: ··········
2%|▏ | 15.0M/760M [00:00<00:04, 156MB/s]
Downloading fruits.zip to data/fruits
100%|██████████| 760M/760M [00:07<00:00, 107MB/s]
# Look into the data directory
data_dir = './data/fruits/fruits-360'
print(os.listdir(data_dir))
classes = os.listdir(data_dir + "/Training")
print(classes)
['papers', 'LICENSE', 'Training', 'test-multiple_fruits', 'readme.md', 'Test'] ['Grape White 4', 'Nectarine', 'Lemon', 'Onion White', 'Apple Braeburn', 'Eggplant', 'Pineapple', 'Cantaloupe 1', 'Cactus fruit', 'Potato Sweet', 'Grape White 3', 'Plum 3', 'Tangelo', 'Papaya', 'Apple Red 2', 'Cherry Wax Black', 'Apple Red 3', 'Grape White 2', 'Banana Lady Finger', 'Apple Red Yellow 2', 'Onion Red Peeled', 'Pepper Red', 'Tomato 4', 'Cocos', 'Hazelnut', 'Cherry Wax Red', 'Pomegranate', 'Salak', 'Passion Fruit', 'Apple Golden 1', 'Apricot', 'Carambula', 'Mango', 'Peach', 'Clementine', 'Tomato Yellow', 'Dates', 'Banana', 'Tomato 1', 'Raspberry', 'Limes', 'Mulberry', 'Guava', 'Pomelo Sweetie', 'Watermelon', 'Lemon Meyer', 'Melon Piel de Sapo', 'Banana Red', 'Apple Red Delicious', 'Chestnut', 'Fig', 'Pear Stone', 'Nut Pecan', 'Mangostan', 'Apple Granny Smith', 'Tomato 3', 'Plum', 'Pineapple Mini', 'Maracuja', 'Strawberry', 'Tomato Maroon', 'Cucumber Ripe 2', 'Tomato Cherry Red', 'Pear Abate', 'Physalis with Husk', 'Pear Monster', 'Cherry 1', 'Apple Golden 2', 'Blueberry', 'Corn Husk', 'Huckleberry', 'Kaki', 'Nut Forest', 'Pitahaya Red', 'Kumquats', 'Pear Red', 'Grapefruit Pink', 'Pepper Orange', 'Tomato not Ripened', 'Redcurrant', 'Cantaloupe 2', 'Mango Red', 'Cucumber Ripe', 'Strawberry Wedge', 'Avocado ripe', 'Potato White', 'Grape Pink', 'Pepino', 'Physalis', 'Mandarine', 'Potato Red Washed', 'Lychee', 'Walnut', 'Apple Crimson Snow', 'Corn', 'Pear', 'Onion Red', 'Apple Red Yellow 1', 'Kiwi', 'Pear 2', 'Beetroot', 'Tomato 2', 'Grapefruit White', 'Apple Golden 3', 'Ginger Root', 'Cherry Wax Yellow', 'Tamarillo', 'Quince', 'Pepper Green', 'Apple Red 1', 'Nectarine Flat', 'Apple Pink Lady', 'Pear Forelle', 'Kohlrabi', 'Tomato Heart', 'Orange', 'Granadilla', 'Pepper Yellow', 'Cherry 2', 'Cauliflower', 'Pear Kaiser', 'Rambutan', 'Peach 2', 'Peach Flat', 'Cherry Rainier', 'Avocado', 'Grape Blue', 'Plum 2', 'Grape White', 'Pear Williams', 'Potato Red']
num_classes = len(classes)
num_classes
131