all = ['learn', 'classify_image', 'categories', 'image', 'label', 'examples', 'intf']
from fastai.vision.all import *
import gradio as gr
learn = load_learner('export.pkl')
categories = ('paved', 'dirt', 'rocky')
def classify_image(img):
pred, idx, probs = learn.predict(img)
return dict(zip(categories, map(float, probs)))
image=gr.Image(height = 192, width = 192)
label = gr.Label()
examples = ['/kaggle/input/gathering-data-for-image-classification/dirt/00b40807-8d22-4521-98cb-e41a0a1c3e2b.jpg',
'/kaggle/input/gathering-data-for-image-classification/paved/5115d001-55f5-43ff-b5f5-ef581ed945e1.jpg',
'/kaggle/input/gathering-data-for-image-classification/rocky/2c3b9423-85b4-40f8-b10d-45a02756e353.jpg']
intf = gr.Interface(fn=classify_image, inputs=image, outputs=label, examples=examples)
intf.launch(inline=False)