File size: 512 Bytes
3da0d62
3eb4884
3da0d62
3eb4884
 
3da0d62
3eb4884
 
 
 
 
 
 
 
 
 
 
 
3da0d62
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
import gradio as gr
from fastai.vision.all import *

learn = load_learner("bird_or_forest.pkl")
classes = ["Bird", "Forest"]

def classify_images(im):
  cat, idx, probs = learn.predict(im)
  return dict(zip(classes, map(float, probs)))

image = gr.Inputs.Image(shape=(192, 192))
label = gr.Outputs.Label()
examples = ["forest.jpg", "bird.jpg"]

iface = gr.Interface(fn=classify_images, 
                    inputs=image, 
                    outputs=label, 
                    examples=examples)
iface.launch()