File size: 734 Bytes
3021290
 
dbb31d9
3021290
 
 
d75fde2
ec459c1
3021290
 
 
 
 
5f880db
 
3021290
92cf010
3021290
 
 
 
 
34e4537
92cf010
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
import timm

pat = r'^(.*)_\d+.jpg'

learn = load_learner('model_convnext.plk')

labels = learn.dls.vocab

def classify_image(img):
    img = PILImage.create(img)
    pred, idx, probs = learn.predict(img)
    #return {labels[i] : float(probs[i]) for i in range(len(labels))}
    return dict(zip(labels, map(float,probs)))

image = gr.inputs.Image(shape=(256,256))
label = gr.outputs.Label(num_top_classes=3)
examples = ['Basset-Hound-standing-in-the-garden.jpg']
title = "Cat&Dog Breed Classifier"
description = "A cat and dog breed classifier trained on the Oxford Pets dataset."

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