File size: 529 Bytes
adc1d17
de15b2c
7d480b7
a7f0c79
95bed10
a7f0c79
bca1e03
de15b2c
7d480b7
de15b2c
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
import timm
from fastai.vision.all import PILImage, load_learner
import gradio as gr
import pathlib
import torch
pathlib.WindowsPath = pathlib.PosixPath
learn = load_learner('convnet_final3.pkl')
categories = ('audi', 'bmw', 'mercedes', 'volvo')

def classify_image(img):
    pred, idx, probs = learn.predict(img)
    return dict(zip(categories, map(float, probs)))
image = gr.inputs.Image(shape=(300,300))
label = gr.outputs.Label()
intf = gr.Interface(fn=classify_image, inputs=image, outputs = label)
intf.launch(inline=False)