ABAAS1 commited on
Commit
3c0b878
·
verified ·
1 Parent(s): 23d634f

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -5
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
- @spaces.GPU
 
8
  def predict(img):
9
  pred, pred_idx, probs = learn.predict(img)
10
- return dict(zip(learn.dls.vocab, map(float, probs)))
11
 
12
  gr.Interface(
13
  fn=predict,
14
  inputs=gr.Image(type='pil'),
15
- outputs=gr.Label(num_top_classes=3)
16
- ).launch()
 
 
 
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()