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

Classifying Fruits And Vegetables Images

This is a task of classification upon a set of images of fruits and vegetables. The idea is that given a color image, tell at which class of fruit or vegetable it belongs between a total of 131 different classes.
To reach that purpose with good accuracy, we'll use Convolutional Neural Networks.

!pip install jovian --upgrade --quiet
import os
import torch
import torchvision
import torch.nn as nn
import torch.nn.functional as F
from torchvision.datasets.utils import download_url
from torch.utils.data import random_split
project_name='Classifying Fruits and Vegetables'

#Downloading and Exploring the Data

We can use the opendatasets library to download the dataset from Kaggle. opendatasets uses the Kaggle Official API for downloading datasets from Kaggle. Follow these steps to find your API credentials:

Sign in to https://kaggle.com/, then click on your profile picture on the top right and select "My Account" from the menu.

Scroll down to the "API" section and click "Create New API Token". This will download a file kaggle.json with the following contents:

{"username":"YOUR_KAGGLE_USERNAME","key":"YOUR_KAGGLE_KEY"}
When you run opendatsets.download, you will be asked to enter your username & Kaggle API, which you can get from the file downloaded in step 2.
Note that you need to download the kaggle.json file only once. On Google Colab, you can also upload the kaggle.json file using the files tab, and the credentials will be read automatically.