Spaces:
Sleeping
Sleeping
File size: 456 Bytes
e0fbd62 8981edf e0fbd62 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
import gradio as gr
from fastai.vision.all import *
import timm.models.convnext
learn = load_learner('pets_model.pkl')
def classify_image(img):
categories = learn.dls.vocab
pred, idx, prob = learn.predict(tensor(img))
d = [(v, k) for k, v in dict(zip(categories, map(float, prob))).items()]
return f'{max(d)[1]}: {max(d)[0]:.04f}'
iface = gr.Interface(fn=classify_image, inputs=gr.inputs.Image(type="pil"), outputs="text")
iface.launch() |