File size: 951 Bytes
c9d1ead
b8d542b
 
c9d1ead
b8d542b
c9d1ead
 
 
 
 
 
 
 
 
 
 
 
 
 
 
f4bd31f
4ce072c
c9d1ead
 
 
 
 
 
 
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
from fastai.vision.all import *
import gradio as gr

#def is_cat(x): return x[0].isupper()

# Cell
learn = load_learner('persimmon_model.pkl')

# Cell
categories = ('persimmon', 'tomato')

def classify_image(img):
    pred,idx,probs = learn.predict(img)
    return dict(zip(categories, map(float,probs)))

image = gr.inputs.Image(shape=(192, 192))
label = gr.outputs.Label()
examples = ['persimmon.jpg', 'tomato.jpg', 'persimmontree.jpg',
            'tomatoplant.jpg', 'cat.jpg', 'tomatoplant2.jpg']

intf = gr.Interface(fn=classify_image, inputs=image, outputs=label, examples=examples, 
                    title="Persimmon or Tomato?", description="Trained on only persimmon and tomato images auto-retrieved from a DDG search using resnet18. Provide an image or select from one below.")
intf.launch(inline=False)

#def greet(name):
#    return "Howdy " + name + "!!"

#iface = gr.Interface(fn=greet, inputs="text", outputs="text")
#iface.launch()