harshasurampudi commited on
Commit
d02fd5f
1 Parent(s): 0166ebc

Upload app.py

Browse files
Files changed (1) hide show
  1. app.py +23 -0
app.py ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from fastai.vision.all import *
2
+ import gradio as gr
3
+
4
+ def label_func(fname):
5
+ if int(str(fname)[str(fname).index('_')+1]) == 0:
6
+ return "Male"
7
+ return "Female"
8
+
9
+ learn = load_learner('gender.pkl')
10
+
11
+ categories = ('Male', 'Female')
12
+
13
+ def classify_image(img):
14
+ pred, idx, probs = learn.predict(img)
15
+ return dict(zip(categories, map(float, probs)))
16
+
17
+ image = gr.inputs.Image(shape=(192,192))
18
+ label = gr.outputs.Label()
19
+ examples = ['Male.jpg', 'Female.jpg']
20
+
21
+
22
+ iface = gr.Interface(fn=classify_image, inputs=image, outputs=label, examples=examples)
23
+ iface.launch()