MasleK commited on
Commit
ca567b7
·
1 Parent(s): f312d12

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -2
app.py CHANGED
@@ -8,11 +8,13 @@ repo_id = "MasleK/snails_snakes_slugs"
8
 
9
  learner = from_pretrained_fastai(repo_id)
10
 
 
11
 
12
  def predict(image):
13
- label, index, scores = learner.predict(image)
14
 
15
- return {l: scores[i].item() for i,l in enumerate(learner.dls.vocab)}
 
16
  title = "Snail, snake, slug Classifier"
17
  description = f"""<h1> Slug, snake or snail<h1>
18
  <p>A classifier trained on about 300 images. Created as a demo for Gradio and HuggingFace Spaces."""
 
8
 
9
  learner = from_pretrained_fastai(repo_id)
10
 
11
+ categories = learner.learn.dls.vocab
12
 
13
  def predict(image):
14
+ label, index, probs = learner.predict(image)
15
 
16
+ return dict(zip(categories, map(float,probs)))
17
+
18
  title = "Snail, snake, slug Classifier"
19
  description = f"""<h1> Slug, snake or snail<h1>
20
  <p>A classifier trained on about 300 images. Created as a demo for Gradio and HuggingFace Spaces."""