WhichWatersport / app.py
bencoman's picture
Update app.py
cf5a0ee
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 ')
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 **\<Submit\>**. \n \
You need to **\<Clear\>** 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)