from fastai.vision.all import * import gradio as gr import logging learn = load_learner('watersports.pkl') categories = learn.dls.vocab def classify_image(img): logging.warning('Watch out!') # will print a message to the console print('Classifying: ', img) pred,idx,probs = learn.predict(img) return( dict(zip(categories, map(float,probs)))) title = "Which Watersport? Compare your guess to the machine inferencing.x" description = "CLick an image and click submit. Drag an image into the classifier. Take a close look and guess it yourself, before hitting **\**. \n \ You need to **\** before dragging next image. Other images can be dragged directly from google search." image = gr.inputs.Image(shape=(192,192)) label = gr.outputs.Label() examples = './examples' iface = gr.Interface(fn=classify_image, inputs=image, outputs=label, \ examples=examples, examples_per_page=100, title=title, description=description) iface.launch(inline=False)