File size: 1,496 Bytes
7469cf1
 
d12c3b5
68b3950
7469cf1
 
 
 
 
d12c3b5
9c0b93e
393d6df
 
7469cf1
68b3950
25e2c14
68b3950
 
5dfa47d
 
68b3950
 
2e7ec5d
68b3950
e5c6c96
7469cf1
68b3950
 
 
 
 
7469cf1
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
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.A",
    "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)