File size: 670 Bytes
bcd4d22
9593667
881843d
275e28f
881843d
f2f8993
 
4d21bbf
3cb3e7c
 
 
881843d
 
 
 
 
1125ffe
 
881843d
 
14bda20
326f2b4
881843d
f2f8993
9593667
 
881843d
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
__all__=['is_cat','learner','classify_image','categories','image','label','examples','intf']
import gradio as gr
from fastai.vision.all import *
def is_cat(x): return x[0].isupper()

example=['dog.jpg','cat.jpg','cat_dog.jpg']

categories=('dog','cat')
def resize_image(image):
    # Resize the image to 192x192 pixels
    return image.resize((192, 192))

learner=load_learner('model.pkl')


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


image=gr.Image(width=192,height=192)
label=gr.Label()

intf=gr.Interface(fn=classify_image,inputs=image,outputs=label,examples=example)


intf.launch(inline=False)