Learn practical skills, build real-world projects, and advance your career
!pip install jovian --upgrade --quiet
|████████████████████████████████| 71kB 3.2MB/s eta 0:00:011 Building wheel for uuid (setup.py) ... done
project_name = 'fruitsfinal'
import numpy as np # linear algebra
import pandas as pd # data processing, CSV file I/O (e.g. pd.read_csv)
import torch
import os
import jovian
import torchvision
import numpy as np
import matplotlib.pyplot as plt
import torch.nn as nn
import torchvision.models as models
import torch.nn.functional as F
from torchvision.datasets import ImageFolder
from torchvision.transforms import ToTensor
from torchvision.utils import make_grid
from torch.utils.data.dataloader import DataLoader
from torch.utils.data import random_split
#from torchvision.datasets import CIFAR10
import torchvision.models as models
%matplotlib inline
from google.colab import drive

drive.mount('/content/drive/')
Mounted at /content/drive/
# Load the directory paths to the dataset

# TRAIN_DIR = '/content/drive/My Drive/Assignment 3/fruits-360/Training/'
# TEST_DIR = '/content/drive/My Drive/Assignment 3/fruits-360/Test/'
data_dir = '/content/drive/My Drive/Assignment 3/fruits-360/'
print('Folders :', os.listdir(data_dir))
types = os.listdir(data_dir + "/Training")
print(len(types), ' types of fruits: ', types)
Folders : ['LICENSE', 'readme.md', 'Test', 'test-multiple_fruits', 'papers', 'Training'] 131 types of fruits: ['Apple Braeburn', 'Apple Pink Lady', 'Apple Granny Smith', 'Apple Golden 3', 'Apple Red 2', 'Apple Crimson Snow', 'Apple Golden 1', 'Apple Red 1', 'Apple Golden 2', 'Apple Red 3', 'Apple Red Delicious', 'Banana Red', 'Avocado ripe', 'Apricot', 'Avocado', 'Banana', 'Banana Lady Finger', 'Apple Red Yellow 2', 'Apple Red Yellow 1', 'Blueberry', 'Beetroot', 'Cantaloupe 1', 'Cactus fruit', 'Cherry Wax Yellow', 'Chestnut', 'Cauliflower', 'Cherry Rainier', 'Cherry Wax Black', 'Cantaloupe 2', 'Cherry 1', 'Cherry 2', 'Carambula', 'Cherry Wax Red', 'Clementine', 'Cocos', 'Eggplant', 'Ginger Root', 'Corn Husk', 'Cucumber Ripe 2', 'Cucumber Ripe', 'Corn', 'Dates', 'Fig', 'Granadilla', 'Grape Blue', 'Grape White', 'Grape Pink', 'Hazelnut', 'Huckleberry', 'Guava', 'Grape White 2', 'Grapefruit Pink', 'Grape White 3', 'Grape White 4', 'Grapefruit White', 'Kiwi', 'Kaki', 'Kumquats', 'Kohlrabi', 'Lychee', 'Lemon', 'Mango Red', 'Mango', 'Limes', 'Mangostan', 'Lemon Meyer', 'Mandarine', 'Melon Piel de Sapo', 'Maracuja', 'Nectarine', 'Mulberry', 'Onion White', 'Orange', 'Papaya', 'Onion Red', 'Nectarine Flat', 'Nut Pecan', 'Nut Forest', 'Onion Red Peeled', 'Passion Fruit', 'Peach', 'Peach Flat', 'Peach 2', 'Pear Stone', 'Pear', 'Pear Forelle', 'Pear Red', 'Pear 2', 'Pear Abate', 'Pear Monster', 'Pear Kaiser', 'Pear Williams', 'Pepino', 'Pepper Orange', 'Pepper Green', 'Pitahaya Red', 'Pineapple Mini', 'Physalis', 'Pepper Red', 'Physalis with Husk', 'Pineapple', 'Pepper Yellow', 'Plum', 'Plum 3', 'Plum 2', 'Pomelo Sweetie', 'Pomegranate', 'Quince', 'Potato Red Washed', 'Potato Red', 'Potato White', 'Redcurrant', 'Raspberry', 'Potato Sweet', 'Rambutan', 'Strawberry', 'Salak', 'Tamarillo', 'Strawberry Wedge', 'Tomato 4', 'Tangelo', 'Tomato Heart', 'Tomato 3', 'Tomato 1', 'Tomato 2', 'Tomato Cherry Red', 'Tomato Maroon', 'Tomato not Ripened', 'Tomato Yellow', 'Walnut', 'Watermelon']
dataset = ImageFolder(data_dir + '/Training', transform=ToTensor())
test = ImageFolder(data_dir + '/Test', transform=ToTensor())
print('Size of raw dataset :', len(dataset))
print('Size of test dataset :', len(test))
Size of raw dataset : 67692 Size of test dataset : 22688