<jupyter_start><jupyter_text>The Amazing Product Color Classifier!You need to know the color of the product you choose and you need an answer fast?Then you've come to the right place. Take a pic of product, and click 'upload' to classify it.<jupyter_code># load model
path = Path().absolute()
learn = load_learner(path/'export.pkl')
from fastai.vision.widgets import *
btn_upload = widgets.FileUpload()

btn_run = widgets.Button(description='Classify')

lbl_pred = widgets.Label()
out_pl = widgets.Output()

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.predict(img)
    lbl_pred.value = f'Prediction: {pred}; Probability: {probs[pred_idx]:.02f}'

btn_run.on_click(on_click_classify)
VBox([widgets.Label("Select your product!"), btn_upload, btn_run, out_pl, lbl_pred])<jupyter_output><empty_output>
StarcoderdataJupyterStructuredCleanDedup