note: when in doubt about any plant, do not touch! This program is experimental with a 25% error rate! It is trained to classify poison ivy look alikes like the virginia creeper, boston ivy, box elder, and kudzu.

Upload a picture of a plant that you think looks like or is poison ivy!

from fastai.vision.all import *
from fastai.vision.widgets import *
path = Path()
learn_inf = load_learner(path/'export.pkl', cpu=True)
btn_upload = widgets.FileUpload()
out_pl = widgets.Output()
lbl_pred = widgets.Label()


def on_data_change(change):
    lbl_pred.value = ''
    img = PILImage.create(btn_upload.data[-1])
    out_pl.clear_output()
    with out_pl: display(img.to_thumb(128,128))
    pred,pred_idx,probs = learn_inf.predict(img)
    lbl_pred.value = f'Prediction: {pred}; Probability: {probs[pred_idx]:.04f}'
    
btn_upload.observe(on_data_change, names=['data'])
display(VBox([widgets.Label('Select your Plant!'), btn_upload, out_pl, lbl_pred]))

Further Research

The model is limited with the data I trained it with, so for instance if I show it a picture of daisies it will try to fit it into one of the categories it knows. It was also suprising that it tends to mix up Virginia creeper up with poison ivy since by human standards it's easy to tell them apart by counting the number of leaves. Of course it has no notion of what a leaf is so I'm guessing that's why.

If I'm to iterate over this project again I'd probably try to incorporate more transfer learning by finding a model that has been trained to recognize a plant data set such as (https://www.kaggle.com/apollonius/usda-plant-database) or something like this.