from fastai.vision.all import * import gradio as gr #def is_cat(x): return x[0].isupper() # Cell learn = load_learner('persimmon_model.pkl') # Cell categories = ('persimmon', 'tomato') def classify_image(img): pred,idx,probs = learn.predict(img) return dict(zip(categories, map(float,probs))) image = gr.inputs.Image(shape=(192, 192)) label = gr.outputs.Label() examples = ['persimmon.jpg', 'tomato.jpg', 'persimmontree.jpg', 'tomatoplant.jpg', 'cat.jpg', 'tomatoplant2.jpg'] intf = gr.Interface(fn=classify_image, inputs=image, outputs=label, examples=examples, title="Persimmon or Tomato?", description="Trained on only persimmon and tomato images auto-retrieved from a DDG search using resnet18. Provide an image or select from one below.") intf.launch(inline=False) #def greet(name): # return "Howdy " + name + "!!" #iface = gr.Interface(fn=greet, inputs="text", outputs="text") #iface.launch()