Somoresh commited on
Commit
1fe85fe
1 Parent(s): ed146e0

Upload app.py

Browse files
Files changed (1) hide show
  1. app.py +46 -4
app.py CHANGED
@@ -1,7 +1,49 @@
 
1
  import gradio as gr
2
 
3
- def greet(name):
4
- return "Hello " + name + "!!"
 
 
 
 
 
 
 
 
 
 
 
 
5
 
6
- iface = gr.Interface(fn=greet, inputs="text", outputs="text")
7
- iface.launch()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from fastai.vision.all import load_learner
2
  import gradio as gr
3
 
4
+ snake_labels = {
5
+ "Python",
6
+ "Rattle",
7
+ "Cobra",
8
+ "Anaconda",
9
+ "Black Mamba",
10
+ "King Cobra",
11
+ "Coral Snake",
12
+ "Water Snake",
13
+ "Sea Snake",
14
+ "Bushmaster",
15
+ "Rat Snake",
16
+ "Parot Snake",
17
+ "Lora"
18
 
19
+
20
+ }
21
+ model =load_learner('models/snake-recognizer-v1.pkl')
22
+
23
+
24
+ def recognize_image(image):
25
+ pred, idx, probs = model.predict(image)
26
+ return dict(zip(snake_labels, map(float, probs)))
27
+
28
+
29
+
30
+ image = gr.Image()
31
+ label = gr.Label()
32
+ examples = [
33
+
34
+ 'test_images/test_image1.jpg',
35
+ 'test_images/test_image2.jpg',
36
+ 'test_images/test_image3.jpg',
37
+ 'test_images/test_image4.jpg',
38
+ 'test_images/test_image5.jpg',
39
+ 'test_images/test_image6.jpg',
40
+ 'test_images/test_image7.jpg',
41
+ 'test_images/test_image8.jpg',
42
+ 'test_images/test_image9.png',
43
+ 'test_images/test_image10.jpg',
44
+ 'test_images/test_image11.JPG',
45
+ 'test_images/test_image12.jpg',
46
+
47
+ ]
48
+ iface = gr.Interface(fn=recognize_image, inputs=image, outputs=label, examples=examples)
49
+ iface.launch(inline=False, share=True)