Spaces:
Running on Zero
Running on Zero
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,16 +1,18 @@
|
|
| 1 |
from fastai.vision.all import *
|
| 2 |
import gradio as gr
|
| 3 |
-
import spaces
|
| 4 |
|
| 5 |
learn = load_learner('model.pkl')
|
| 6 |
|
| 7 |
-
|
|
|
|
| 8 |
def predict(img):
|
| 9 |
pred, pred_idx, probs = learn.predict(img)
|
| 10 |
-
return
|
| 11 |
|
| 12 |
gr.Interface(
|
| 13 |
fn=predict,
|
| 14 |
inputs=gr.Image(type='pil'),
|
| 15 |
-
outputs=gr.Label(num_top_classes=3)
|
| 16 |
-
|
|
|
|
|
|
|
|
|
| 1 |
from fastai.vision.all import *
|
| 2 |
import gradio as gr
|
|
|
|
| 3 |
|
| 4 |
learn = load_learner('model.pkl')
|
| 5 |
|
| 6 |
+
labels = learn.dls.vocab
|
| 7 |
+
|
| 8 |
def predict(img):
|
| 9 |
pred, pred_idx, probs = learn.predict(img)
|
| 10 |
+
return {labels[i]: float(probs[i]) for i in range(len(labels))}
|
| 11 |
|
| 12 |
gr.Interface(
|
| 13 |
fn=predict,
|
| 14 |
inputs=gr.Image(type='pil'),
|
| 15 |
+
outputs=gr.Label(num_top_classes=3),
|
| 16 |
+
title="Board Classifier",
|
| 17 |
+
description="Classifies Arduino, ESP32, and Raspberry Pi boards from a photo.",
|
| 18 |
+
).launch()
|