inigogab commited on
Commit
c09c37c
1 Parent(s): 78f48b1

Mod interface

Browse files
Files changed (1) hide show
  1. app.py +5 -4
app.py CHANGED
@@ -1,12 +1,13 @@
1
- __all__ = ["is_cat" , "learn", "classify_image", "categories", "image", "label", "examples", "intf"]
2
 
3
  from fastai.vision.all import *
4
  import gradio as gr
 
5
 
6
  def is_cat(x): return x[0].isupper()
7
 
8
  learn = load_learner("model.pkl")
9
-
10
  categories = ("Dog", "Cat")
11
 
12
  def classify_image(img):
@@ -14,8 +15,8 @@ def classify_image(img):
14
  return dict(zip(categories, map(float, probs)))
15
 
16
  image = gr.inputs.Image(shape=(192, 192))
17
- label = gr.outputs.Label()
18
  examples = ["dog.jpg", "cat.jpg", "dunno.jpg"]
19
 
20
- intf = gr.Interface(fn=classify_image, inputs=image, outputs=label, examples=examples, enable_queue=True)
21
  intf.launch()
 
1
+ __all__ = ["is_cat" , "learn", "classify_image", "categories", "image", "labels", "examples", "intf"]
2
 
3
  from fastai.vision.all import *
4
  import gradio as gr
5
+ import skimage
6
 
7
  def is_cat(x): return x[0].isupper()
8
 
9
  learn = load_learner("model.pkl")
10
+ labels = learn.dls.vocab
11
  categories = ("Dog", "Cat")
12
 
13
  def classify_image(img):
 
15
  return dict(zip(categories, map(float, probs)))
16
 
17
  image = gr.inputs.Image(shape=(192, 192))
18
+ outputs = gr.outputs.Label(num_top_classes=3)
19
  examples = ["dog.jpg", "cat.jpg", "dunno.jpg"]
20
 
21
+ intf = gr.Interface(fn=classify_image, inputs=image, outputs=outputs, examples=examples)
22
  intf.launch()