Spaces:
Runtime error
Runtime error
File size: 608 Bytes
9e2cb0a 53d0d3f 9e2cb0a dce65c7 9e2cb0a |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
import gradio as gr
from fastai.vision.all import *
learn = load_learner("zeroshot/twitter-financial-news-topic")
learn
categories = ('Car in good condition','Damaged Car')
def is_car(x) : return x[0].isupper()
def image_classifier(img):
pred,index,probs = learn.predict(img)
return dict(zip(categories, map(float,probs)))
# image = gr.inputs.Image(shape=(192,192))
image = gr.components.Image(shape=(192,192))
label = gr.components.Label()
examples = ['./car.jpg','./crash.jpg','./carf.jpg']
intf = gr.Interface(fn= image_classifier,inputs=image,outputs=label,examples=examples)
intf.launch() |