Spaces:
Runtime error
Runtime error
File size: 827 Bytes
b98a0e2 641fe93 b98a0e2 f7f9f63 25751a2 b98a0e2 f7f9f63 25751a2 ef69052 b98a0e2 |
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 28 29 30 31 32 33 34 35 36 37 |
from fastai.vision.all import *
import torch
import gradio as gr
learn = load_learner("model_tvdesktop.pkl")
labels = learn.dls.vocab
def classify_image(img):
img = PILImage.create(img)
pred, idx, probs = learn.predict(img)
output = dict(zip(labels, map(float, probs)))
print(probs[0].item()*100)
count = 0
for out in output:
val = output[out]
if val*100 < 60:
count += 1
if count == 2:
return {"Not sure/Others": 0}
return output
image = gr.inputs.Image(shape=(224, 224))
label = gr.outputs.Label()
title = "CRT TV and Desktop Monitor Classifier"
description = "A simple image classifier."
intf = gr.Interface(
fn=classify_image,
inputs=image,
outputs=label,
title=title,
description=description
)
intf.launch(inline=False)
|