dpaliwa commited on
Commit
0c98f9c
·
1 Parent(s): ba68f7a

Added app.py

Browse files
Files changed (1) hide show
  1. app.py +22 -4
app.py CHANGED
@@ -1,7 +1,25 @@
 
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 *
2
  import gradio as gr
3
 
 
 
4
 
5
+ def is_holdingweapon(x):
6
+ return parent_label(x)
7
+
8
+
9
+ learn = load_learner('weapon_finder_model.pkl')
10
+
11
+
12
+ categories = ('Human holding Weapon','Weapon')
13
+
14
+ def classify_image(img):
15
+ pred,idx,probs = learn.predict(img)
16
+ return dict(zip(categories,map(float,probs))) #float because gradio doesnt take tensors
17
+
18
+
19
+ image = gr.inputs.Image(shape=(192,192))
20
+ label = gr.outputs.Label()
21
+
22
+ examples = ['human_weapon1.jpg','weapon22.jpg']
23
+
24
+ intf = gr.Interface(fn = classify_image,inputs = image,outputs=label,examples=examples)
25
+ intf.launch(inline = False)