devdatanalytics/irishpotato
0
1import gradio as gr2from fastai.vision.all import *3import skimage4from fastai.vision.all import PILImage5 6learn = load_learner('model.pkl')7 8labels = learn.dls.vocab9 10def predict(img):11 img = PILImage.create(img)12 img = img.resize((512, 512))13 pred,pred_idx,probs = learn.predict(img)14 return {labels[i]: float(probs[i]) for i in range(len(labels))}15 16examples = ['image.jpg']17 18#gr.Interface(fn=predict,inputs=gr.inputs.Image(shape=(512, 512)),outputs=gr.outputs.Label(num_top_classes=3),examples=examples,interpretation=interpretation,enable_queue=enable_queue).launch()19gr.Interface(fn=predict,inputs=gr.components.Image(),outputs=gr.components.Label(num_top_classes=3),examples=examples,).launch()20 