In [1]:
from google.colab import drive
Go to this URL in a browser:

Enter your authorization code:
Mounted at /content/gdrive
In [2]:
from pathlib import Path
drive_path = Path('/content/gdrive/My Drive/leafsnap')
base_path = Path('/content/leafsnap-dataset')
In [3]:
!pip install "torch==1.4" "torchvision==0.5.0"
Collecting torch==1.4
  Downloading (753.4MB)
     |████████████████████████████████| 753.4MB 18kB/s 
Collecting torchvision==0.5.0
  Downloading (4.0MB)
     |████████████████████████████████| 4.0MB 21.1MB/s 
Requirement already satisfied: six in /usr/local/lib/python3.6/dist-packages (from torchvision==0.5.0) (1.15.0)
Requirement already satisfied: numpy in /usr/local/lib/python3.6/dist-packages (from torchvision==0.5.0) (1.18.5)
Requirement already satisfied: pillow>=4.1.1 in /usr/local/lib/python3.6/dist-packages (from torchvision==0.5.0) (7.0.0)
Installing collected packages: torch, torchvision
  Found existing installation: torch 1.6.0+cu101
    Uninstalling torch-1.6.0+cu101:
      Successfully uninstalled torch-1.6.0+cu101
  Found existing installation: torchvision 0.7.0+cu101
    Uninstalling torchvision-0.7.0+cu101:
      Successfully uninstalled torchvision-0.7.0+cu101
Successfully installed torch-1.4.0 torchvision-0.5.0
In [4]:
%reload_ext autoreload
%autoreload 2
%matplotlib inline
In [5]:
from import *
from fastai.metrics import error_rate
In [19]:
img = open_image(drive_path/'maple.jpg')
Output hidden; open in to view.
In [9]:
model_rn34 = load_learner(drive_path, 'leafsnap-rn34-4e-ft1-ft8.pkl')
In [20]:
pred_class, pred_idx, outputs = model_rn34.predict(img)
In [34]:
def predict_file(file_name):
  img = open_image(drive_path/file_name)
  pred_class, pred_idx, outputs = model_rn34.predict(img)'Prediction: {pred_class.obj}, with {outputs.max()*100:2.0f}% confidence', figsize=(10,10))
In [35]:
In [36]: