Farid Rener commited on
Commit
7d0dabc
·
1 Parent(s): 6a5f8ce

Use a label

Browse files
Files changed (1) hide show
  1. app.py +15 -2
app.py CHANGED
@@ -6,14 +6,27 @@ from fastai.learner import load_learner
6
 
7
  model = load_learner('./mushrooms.pkl')
8
 
 
 
 
 
 
 
 
 
 
 
 
 
 
9
  def classify_image(image):
10
  prediction, _, probs = model.predict(image)
11
- return f"{prediction}: {max(probs)}"
12
 
13
  iface = gr.Interface(
14
  fn=classify_image,
15
  inputs=gr.Image(type="pil"),
16
- outputs="text",
17
  title="Image Classifier",
18
  description="WHAT IS THE MUSHROOM?"
19
  )
 
6
 
7
  model = load_learner('./mushrooms.pkl')
8
 
9
+
10
+ categories = [
11
+ "Agaricus",
12
+ "Amanita",
13
+ "Boletus",
14
+ "Cortinarius",
15
+ "Entoloma",
16
+ "Hygrocybe",
17
+ "Lactarius",
18
+ "Russula",
19
+ "Suillus",
20
+ ]
21
+
22
  def classify_image(image):
23
  prediction, _, probs = model.predict(image)
24
+ return dict(zip(categories, map(float, probs)))
25
 
26
  iface = gr.Interface(
27
  fn=classify_image,
28
  inputs=gr.Image(type="pil"),
29
+ outputs=gr.Label(),
30
  title="Image Classifier",
31
  description="WHAT IS THE MUSHROOM?"
32
  )