uhlarlar commited on
Commit
197802a
·
1 Parent(s): dcb2810

added pred categories

Browse files
Files changed (1) hide show
  1. app.py +10 -4
app.py CHANGED
@@ -3,10 +3,16 @@ import gradio as gr
3
 
4
  learn = load_learner('petClassifierModel.pkl')
5
 
6
- categories = ("American Bulldog", "American Pit Bull Terrier", "Basset Hound", "Beagle", "Boxer", "Chihuahua", "English Cocker Spaniel", "English Setter", "German Shorthaired", "Great Pyrenees", "Havanese", "Japanese Chin", "Keeshond", "Leonberger", "Miniature Pinscher", "Newfoundland", "Pomeranian", "Pug", "Saint Bernard", "Samyoed", "Scottish Terrier", "Shiba Inu", "Staffordshire Bull Terrier")
7
 
8
- def greet(name):
9
- return "Hello " + name + "!!"
10
 
11
- iface = gr.Interface(fn=greet, inputs="text", outputs="text")
 
 
 
 
 
 
 
 
12
  iface.launch()
 
3
 
4
  learn = load_learner('petClassifierModel.pkl')
5
 
 
6
 
7
+ categories = learn.dls.vocab
 
8
 
9
+ def classify_image(img):
10
+ pred, idx, probs = learn.predict(img)
11
+ return dict(zip(categories(map(float, probs))))
12
+
13
+ image = gr.inputs.Image(shape=(192,192))
14
+ label = gr.outputs.Label()
15
+
16
+
17
+ iface = gr.Interface(fn=classify_image, inputs="image", outputs="label")
18
  iface.launch()