Spaces:
Running
Running
pragnakalp
commited on
Commit
·
d1fca03
1
Parent(s):
81a7c00
update UI
Browse files
app.py
CHANGED
@@ -1,14 +1,8 @@
|
|
1 |
import gradio as gr
|
2 |
-
from datetime import date
|
3 |
-
import json
|
4 |
-
import csv
|
5 |
-
import datetime
|
6 |
-
import smtplib
|
7 |
-
from email.mime.text import MIMEText
|
8 |
-
import requests
|
9 |
from transformers import AutoTokenizer, AutoModelWithLMHead
|
10 |
import gc
|
11 |
import os
|
|
|
12 |
|
13 |
cwd = os.getcwd()
|
14 |
model_path = os.path.join(cwd)
|
@@ -27,10 +21,10 @@ def get_emotion(text):
|
|
27 |
return label
|
28 |
|
29 |
def generate_emotion(article):
|
30 |
-
print("hello")
|
31 |
sen_list = article
|
32 |
-
sen_list = sen_list.split('\
|
33 |
sen_list_temp = sen_list[0:]
|
|
|
34 |
results_dict = []
|
35 |
results = []
|
36 |
|
@@ -46,16 +40,18 @@ def generate_emotion(article):
|
|
46 |
}
|
47 |
)
|
48 |
|
49 |
-
result = {
|
50 |
-
|
51 |
-
}
|
|
|
52 |
gc.collect()
|
53 |
-
print("LENGTH of results ====> ", results)
|
54 |
|
55 |
-
return result
|
56 |
|
57 |
inputs=gr.Textbox(lines=10, label="Sentences",elem_id="inp_div")
|
58 |
-
outputs=gr.
|
|
|
59 |
|
60 |
demo = gr.Interface(
|
61 |
generate_emotion,
|
@@ -63,6 +59,6 @@ demo = gr.Interface(
|
|
63 |
outputs,
|
64 |
title="Emotion Detection",
|
65 |
description="Feel free to give your feedback",
|
66 |
-
css=".gradio-container {background-color: lightgray} #inp_div {background-color:
|
67 |
)
|
68 |
demo.launch()
|
|
|
1 |
import gradio as gr
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2 |
from transformers import AutoTokenizer, AutoModelWithLMHead
|
3 |
import gc
|
4 |
import os
|
5 |
+
import pandas as pd
|
6 |
|
7 |
cwd = os.getcwd()
|
8 |
model_path = os.path.join(cwd)
|
|
|
21 |
return label
|
22 |
|
23 |
def generate_emotion(article):
|
|
|
24 |
sen_list = article
|
25 |
+
sen_list = sen_list.split('\n')
|
26 |
sen_list_temp = sen_list[0:]
|
27 |
+
print(sen_list_temp)
|
28 |
results_dict = []
|
29 |
results = []
|
30 |
|
|
|
40 |
}
|
41 |
)
|
42 |
|
43 |
+
# result = {
|
44 |
+
# 'result': results_dict,
|
45 |
+
# }
|
46 |
+
result = {'Input':sen_list_temp, 'Detected Emotion':results}
|
47 |
gc.collect()
|
48 |
+
# print("LENGTH of results ====> ", results)
|
49 |
|
50 |
+
return pd.DataFrame(result)
|
51 |
|
52 |
inputs=gr.Textbox(lines=10, label="Sentences",elem_id="inp_div")
|
53 |
+
outputs = [gr.Dataframe(row_count = (1, "dynamic"), col_count=(2, "fixed"), label="Here is the Result", headers=["Input","Detected Emotion"])]
|
54 |
+
|
55 |
|
56 |
demo = gr.Interface(
|
57 |
generate_emotion,
|
|
|
59 |
outputs,
|
60 |
title="Emotion Detection",
|
61 |
description="Feel free to give your feedback",
|
62 |
+
css=".gradio-container {background-color: lightgray} #inp_div {background-color: #FB3D5;}"
|
63 |
)
|
64 |
demo.launch()
|