benja20029 commited on
Commit
97bdf4b
1 Parent(s): 9b8b54c

Gradio first update

Browse files
.ipynb_checkpoints/emotion-classifier-checkpoint.ipynb ADDED
The diff for this file is too large to render. See raw diff
 
app.py ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import pathlib
2
+ temp = pathlib.PosixPath
3
+ pathlib.PosixPath = pathlib.WindowsPath
4
+
5
+ from fastai.vision.all import *
6
+ import gradio as gr
7
+
8
+ def emotion(x): return x[0].isupper()
9
+
10
+ learn = load_learner('emotion_classifier_model.pkl')
11
+
12
+ categories = ('angry', 'anxious', 'calm', 'disgusted','happy', 'sad', 'scared')
13
+
14
+ def classify_images(img):
15
+ pred,idx,probs = learn.predict(img)
16
+ return dict(zip(categories, map(float,probs)))
17
+
18
+ image = gr.Image(shape=(192,192))
19
+ label = gr.Label()
20
+ examples = ['emotions/scared.jpg', 'emotions/happy.jpg', 'emotions/sad.jpg', 'emotions/angry.jpg']
21
+
22
+ intf = gr.Interface(fn=classify_images, inputs=image, outputs=label, examples=examples)
23
+ intf.launch(inline=False)
emotion-classifier.ipynb ADDED
The diff for this file is too large to render. See raw diff
 
emotion_classifier_model.pkl ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:f50c45b0490880924835de25dcf335be1021de7c71fbcbad77c7d30423fc5995
3
+ size 46983019