drsaikirant88 commited on
Commit
ccb670c
1 Parent(s): 7973875

update: new output and text

Browse files
Files changed (1) hide show
  1. app.py +14 -6
app.py CHANGED
@@ -19,15 +19,23 @@ def predict(img):
19
 
20
  pred_sentiment, pred_sentiment_idx, probs_sentiment = learn_sentiment.predict(img)
21
 
22
- emotions = {f'emotion_{learn_emotion_labels[i]}': float(probs_emotion[i]) for i in range(len(learn_emotion_labels))}
23
- sentiments = {f'sentiment_{learn_sentiment_labels[i]}': float(probs_sentiment[i]) for i in range(len(learn_sentiment_labels))}
 
 
 
24
 
25
- return {**emotions, **sentiments}
26
 
27
  # Gradio
28
  title = "Facial Expression Sentiment Classifier"
29
- description = "A model to detect emotion and sentiment from facial expressions trained on FER2013 dataset using FastAi. Created as a demo for AI Course."
30
- article = 'Sample images are taken from VG & AftenPoften webpages. Copyrights belong to respective brands. All rights reserved.'
 
 
 
 
 
31
  interpretation='default'
32
  enable_queue=True
33
 
@@ -35,7 +43,7 @@ examples = ['happy1.jpg', 'happy2.jpg', 'angry1.png', 'angry2.jpg', 'neutral1.jp
35
 
36
  gr.Interface(fn = predict,
37
  inputs = gr.Image(shape=(48, 48), image_mode='L'),
38
- outputs = gr.Label(),
39
  title = title,
40
  examples = examples,
41
  description = description,
 
19
 
20
  pred_sentiment, pred_sentiment_idx, probs_sentiment = learn_sentiment.predict(img)
21
 
22
+ #emotions = {f'emotion_{learn_emotion_labels[i]}': float(probs_emotion[i]) for i in range(len(learn_emotion_labels))}
23
+ #sentiments = {f'sentiment_{learn_sentiment_labels[i]}': float(probs_sentiment[i]) for i in range(len(learn_sentiment_labels))}
24
+
25
+ emotions = {learn_emotion_labels[i]: float(probs_emotion[i]) for i in range(len(learn_emotion_labels))}
26
+ sentiments = {learn_sentiment_labels[i]: float(probs_sentiment[i]) for i in range(len(learn_sentiment_labels))}
27
 
28
+ return [emotions, sentiments] #{**emotions, **sentiments}
29
 
30
  # Gradio
31
  title = "Facial Expression Sentiment Classifier"
32
+ description = "Ever wondered what a person might be feeling looking at their picture? Well, now you can! Try this fun " + \
33
+ "app - just upload a facial image in jpg or png format. Voila! you can now see what they might have felt when the " + \
34
+ "picture was taken. Be sure to only include face to get best results. Check some sample images at the bottom for " + \
35
+ "inspiration!"
36
+ article = "DISCLAIMER: This model does not reveal the actual emotional state of a person. Use and interpret results at your own risk! " + \
37
+ "It was built as a demo for AI course. The model is trained on FER2013 dataset using FastAI. Sample images are taken " + \
38
+ "from VG & AftenPoften webpages. Copyrights belong to respective brands. All rights reserved."
39
  interpretation='default'
40
  enable_queue=True
41
 
 
43
 
44
  gr.Interface(fn = predict,
45
  inputs = gr.Image(shape=(48, 48), image_mode='L'),
46
+ outputs = [gr.Label(label='Emotion'), gr.Label(label='Sentiment')], #gr.Label(),
47
  title = title,
48
  examples = examples,
49
  description = description,