File size: 596 Bytes
9d477bb
8193f18
 
9d477bb
 
 
 
 
8193f18
9d477bb
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
from fastai.vision.all import *
import gradio as gr

def label_func(x):
  if "Raven" in x.parent.name:
    return "raven"
  else:
    return "crow"

categories = ("raven", "crow")

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

learn = load_learner("model.pkl")

image = gr.inputs.Image(shape=(400, 400))
label = gr.outputs.Label()

examples = ["examples/crow.jpg", "examples/raven.jpg"]

intf = gr.Interface(fn=classify_image, inputs=image, outputs=label, examples=examples)
intf.launch(inline=False)