File size: 463 Bytes
9062980
 
 
 
 
 
 
 
 
 
62a69b4
9062980
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
from fastai.vision.all import *
import gradio as gr
import torch as t

t.cuda.is_available()

def is_cat(x): return x[0].isupper()
    
l=load_learner('model.pkl')

cat=('dog','cat')
def classify(img):
    s,i,p=l.predict(img)
    return dict(zip(cat,map(float,p)))

image=gr.inputs.Image(shape=(192,192))
label=gr.outputs.Label()
ex=['cat.jpg','dog.jpg','dunno.jpg']
inf=gr.Interface(fn=classify,inputs=image,outputs=label,examples=ex)
inf.launch(inline=False)