WhichWatersport / app.py
Benjamin Coman
app.py fix indentation
393d6df
from fastai.vision.all import *
import gradio as gr
learn = load_learner('watersports.pkl')
categories = learn.dls.vocab
def classify_image(img):
pred,idx,probs = learn.predict(img)
return( dict(zip(categories, map(float,probs))))
title = "Which Watersport?"
description = "Drag an image into the analyser. Try to guess the water sport yourself, before hitting submit. \
You need to clear before dragging next image. You can also drag images directly from a 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, title=title, description=description)
iface.launch(inline=False)