<jupyter_start><jupyter_text><jupyter_code>from fastai2.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_click_classify(change):
  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_click, names=['data'])
display(VBox([widgets.Label('Select your cat or dog'), btn_upload, out_pl, lbl,pred]))<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.15242165242165243, 'fraction_numerical': 0.014245014245014245, 'mean_word_length': 7.270588235294118, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '482994', 'license': 'Apache-2.0', 'n_tokens_mistral': 276, 'n_tokens_neox': 268, 'n_words': 44, 'path': 'catvsdog.ipynb', 'repo_name': 'nicocrozier/catsvsdogs', 'size': '702'}