Spaces:
Runtime error
Runtime error
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 inference.", | |
"description": "Click an image. Click Submit. Click Clear. Other images can be dragged directly from a google search. \nNote, the machine classifier relies purely on vision, of the image pixels - no other info used.", | |
"examples": [f'{EXAMPLES_PATH}/{f.name}' for f in EXAMPLES_PATH.iterdir()], | |
"examples_per_page": "100" | |
} | |
iface = gr.Interface(fn=classify_image, | |
inputs=gr.inputs.Image(shape=(192,192)), | |
outputs=gr.outputs.Label(), | |
**interface_options) | |
iface.launch(inline=False) | |