WhichWatersport / app.py
bencoman's picture
debugging
5dfa47d
from fastai.vision.all import *
import gradio as gr
import logging
EXAMPLES_PATH = Path('./examples')
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))))
interface_options = {
"title": "Which Watersport? Compare your guess to the machine inferencing.z",
"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.",
"examples": [f'{EXAMPLES_PATH}/{f.name}' for f in EXAMPLES_PATH.iterdir()],
"examples_per_page": "100"
}
title = "Which Watersport? Compare your guess to the machine inferencing.y"
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."
iface = gr.Interface(fn=classify_image,
inputs=gr.inputs.Image(shape=(192,192)),
outputs=gr.outputs.Label(),
**interface_options)
iface.launch(inline=False)