Jovian
⭐️
Sign In
In [1]:
%reload_ext autoreload
%autoreload 2
%matplotlib inline
In [2]:
from fastai.vision import *
In [3]:
import os
import shutil
In [4]:
path = Path('data/quick-draw')
In [ ]:
! unzip -q -n {path}/train_dat.zip -d {path}
In [5]:
classes = os.listdir(path/'train')
In [6]:
classes
Out[6]:
['flower', 'bird', 'shoe', 'donut', 'bed']
In [7]:
from random import random
In [9]:
for c in classes:
    !mkdir data/quick-draw/valid/{c}
In [10]:
for c in classes:
    for img in os.listdir(path/'train'/c):
        if random() < 0.2:
            !mv data/quick-draw/train/{c}/{img} data/quick-draw/valid/{c}/{img}
In [11]:
from fastai import *
from fastai.vision import *
bs = 64
In [12]:
path = Path('data/quick-draw')
data = ImageDataBunch.from_folder(path, ds_tfms=get_transforms(), size=224, bs=bs, test = 'test')
data.normalize(imagenet_stats)

#look at class labels ['flower', 'bird', 'shoe', 'donut', 'bed']
print(data.classes)

data.show_batch(rows=3, figsize=(10,20))
['bed', 'bird', 'donut', 'flower', 'shoe']
Notebook Image
In [14]:
learn = cnn_learner(data, models.resnet34, metrics=error_rate)
In [15]:
learn.fit_one_cycle(4)
In [16]:
learn.save('stage-1')
In [17]:
interp = ClassificationInterpretation.from_learner(learn)

losses,idxs = interp.top_losses()

len(data.valid_ds)==len(losses)==len(idxs)
Out[17]:
True
In [18]:
interp.plot_top_losses(9, figsize=(15,11))
Notebook Image
In [19]:
interp.plot_confusion_matrix(figsize=(12,12), dpi=60)
Notebook Image
In [21]:
pip install jovian --upgrade
Collecting jovian Downloading https://files.pythonhosted.org/packages/e3/19/33f9a1b20c3478486ce9dba924c0a0a1f9ac60b2952bdcd93c736c8c8a67/jovian-0.1.43-py3-none-any.whl Collecting uuid (from jovian) Downloading https://files.pythonhosted.org/packages/ce/63/f42f5aa951ebf2c8dac81f77a8edcc1c218640a2a35a03b9ff2d4aa64c3d/uuid-1.30.tar.gz Requirement already satisfied, skipping upgrade: requests in /home/aakanksha_ns/anaconda3/envs/fastai-v1/lib/python3.7/site-packages (from jovian) (2.21.0) Requirement already satisfied, skipping upgrade: certifi>=2017.4.17 in /home/aakanksha_ns/anaconda3/envs/fastai-v1/lib/python3.7/site-packages (from requests->jovian) (2018.11.29) Requirement already satisfied, skipping upgrade: urllib3<1.25,>=1.21.1 in /home/aakanksha_ns/anaconda3/envs/fastai-v1/lib/python3.7/site-packages (from requests->jovian) (1.24.1) Requirement already satisfied, skipping upgrade: chardet<3.1.0,>=3.0.2 in /home/aakanksha_ns/anaconda3/envs/fastai-v1/lib/python3.7/site-packages (from requests->jovian) (3.0.4) Requirement already satisfied, skipping upgrade: idna<2.9,>=2.5 in /home/aakanksha_ns/anaconda3/envs/fastai-v1/lib/python3.7/site-packages (from requests->jovian) (2.8) Building wheels for collected packages: uuid Building wheel for uuid (setup.py) ... done Stored in directory: /home/aakanksha_ns/.cache/pip/wheels/2a/80/9b/015026567c29fdffe31d91edbe7ba1b17728db79194fca1f21 Successfully built uuid Installing collected packages: uuid, jovian Successfully installed jovian-0.1.43 uuid-1.30 Note: you may need to restart the kernel to use updated packages.
In [22]:
import jovian
In [ ]:
jovian.commit()
[jovian] Saving notebook..
In [ ]: