Spaces:
Running
Running
Commit
·
1743490
1
Parent(s):
9a74e03
Update app.py
Browse files
app.py
CHANGED
@@ -6,9 +6,6 @@ import pandas as pd
|
|
6 |
from tqdm import tqdm
|
7 |
|
8 |
from transformers import AutoTokenizer, AutoConfig, AutoModel, AutoModelForSequenceClassification
|
9 |
-
from transformers import TrainingArguments, Trainer
|
10 |
-
|
11 |
-
from datasets import load_dataset
|
12 |
|
13 |
|
14 |
description_sentence = "<h3>Demo EmotioNL</h3>\nThis demo allows you to analyse the emotion in a sentence."
|
@@ -85,7 +82,7 @@ def inference_dataset(file_object):
|
|
85 |
return output
|
86 |
"""
|
87 |
|
88 |
-
def inference_dataset(file_object):
|
89 |
tokenizer = AutoTokenizer.from_pretrained(inference_modelpath)
|
90 |
model = AutoModelForSequenceClassification.from_pretrained(inference_modelpath)
|
91 |
data_path = open(file_object, 'r')
|
@@ -108,7 +105,17 @@ def inference_dataset(file_object):
|
|
108 |
for line in predictions_content:
|
109 |
f.write(str(line[0]) + '\t' + str(line[1]) + '\t' + str(line[2]) + '\n')
|
110 |
f.close()
|
111 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
112 |
|
113 |
def what_happened(text, file_object, option_list):
|
114 |
if file_object:
|
@@ -180,7 +187,7 @@ iface_sentence = gr.Interface(
|
|
180 |
outputs="text")
|
181 |
|
182 |
iface2 = gr.Interface(
|
183 |
-
fn=
|
184 |
description = description2,
|
185 |
inputs=[
|
186 |
gr.File(
|
|
|
6 |
from tqdm import tqdm
|
7 |
|
8 |
from transformers import AutoTokenizer, AutoConfig, AutoModel, AutoModelForSequenceClassification
|
|
|
|
|
|
|
9 |
|
10 |
|
11 |
description_sentence = "<h3>Demo EmotioNL</h3>\nThis demo allows you to analyse the emotion in a sentence."
|
|
|
82 |
return output
|
83 |
"""
|
84 |
|
85 |
+
def inference_dataset(file_object, option_list):
|
86 |
tokenizer = AutoTokenizer.from_pretrained(inference_modelpath)
|
87 |
model = AutoModelForSequenceClassification.from_pretrained(inference_modelpath)
|
88 |
data_path = open(file_object, 'r')
|
|
|
105 |
for line in predictions_content:
|
106 |
f.write(str(line[0]) + '\t' + str(line[1]) + '\t' + str(line[2]) + '\n')
|
107 |
f.close()
|
108 |
+
output1 = output
|
109 |
+
output2 = output3 = output4 = output5 = "This option was not selected."
|
110 |
+
if "emotion frequencies" in option_list:
|
111 |
+
output2 = "This option was selected."
|
112 |
+
if "emotion distribution over time" in option_list:
|
113 |
+
output3 = "This option was selected."
|
114 |
+
if "peaks" in option_list:
|
115 |
+
output4 = "This option was selected."
|
116 |
+
if "topics" in option_list:
|
117 |
+
output5 = "This option was selected."
|
118 |
+
return [output1, output2, output3, output4, output5]
|
119 |
|
120 |
def what_happened(text, file_object, option_list):
|
121 |
if file_object:
|
|
|
187 |
outputs="text")
|
188 |
|
189 |
iface2 = gr.Interface(
|
190 |
+
fn=inference_dataset,
|
191 |
description = description2,
|
192 |
inputs=[
|
193 |
gr.File(
|