Spaces:
Running on Zero
Running on Zero
File size: 676 Bytes
557677f e893d21 557677f 3c0b878 e893d21 557677f b5a5e6c 8472192 3c0b878 557677f 3c0b878 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | from fastai.vision.all import *
import gradio as gr
import spaces
learn = load_learner('model.pkl')
labels = learn.dls.vocab
@spaces.GPU
def predict(img):
# Wrap the incoming PIL image as a fastai PILImage so the model's
# item/batch transforms (which turn it into a tensor) actually fire.
img = PILImage.create(img)
pred, pred_idx, probs = learn.predict(img)
return {labels[i]: float(probs[i]) for i in range(len(labels))}
gr.Interface(
fn=predict,
inputs=gr.Image(type='pil'),
outputs=gr.Label(num_top_classes=3),
title="Board Classifier",
description="Classifies Arduino, ESP32, and Raspberry Pi boards from a photo.",
).launch()
|