Spaces:
Runtime error
Runtime error
j-hartmann
commited on
Commit
•
6f38f2e
1
Parent(s):
6a48f6a
Update app.py
Browse files
app.py
CHANGED
@@ -18,7 +18,7 @@ def bulk_function(filename):
|
|
18 |
return {k: v[idx] for k, v in self.tokenized_texts.items()}
|
19 |
|
20 |
# load tokenizer and model, create trainer
|
21 |
-
model_name = "j-hartmann/
|
22 |
tokenizer = AutoTokenizer.from_pretrained(model_name)
|
23 |
model = AutoModelForSequenceClassification.from_pretrained(model_name)
|
24 |
trainer = Trainer(model=model)
|
@@ -78,29 +78,20 @@ def bulk_function(filename):
|
|
78 |
temp = (np.exp(predictions[0])/np.exp(predictions[0]).sum(-1,keepdims=True))
|
79 |
|
80 |
# container
|
81 |
-
|
82 |
-
|
83 |
-
fear = []
|
84 |
-
joy = []
|
85 |
-
neutral = []
|
86 |
-
sadness = []
|
87 |
-
surprise = []
|
88 |
|
89 |
# extract scores (as many entries as exist in pred_texts)
|
90 |
for i in range(len(lines_s)):
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
joy.append(round(temp[i][3], 3))
|
95 |
-
neutral.append(round(temp[i][4], 3))
|
96 |
-
sadness.append(round(temp[i][5], 3))
|
97 |
-
surprise.append(round(temp[i][6], 3))
|
98 |
|
99 |
# define df
|
100 |
-
df = pd.DataFrame(list(zip(ids,lines_s,labels,scores_rounded,
|
101 |
print(df)
|
102 |
# save results to csv
|
103 |
-
YOUR_FILENAME = filename.name.split(".")[0] + "
|
104 |
df.to_csv(YOUR_FILENAME, index=False)
|
105 |
|
106 |
# return dataframe for space output
|
|
|
18 |
return {k: v[idx] for k, v in self.tokenized_texts.items()}
|
19 |
|
20 |
# load tokenizer and model, create trainer
|
21 |
+
model_name = "j-hartmann/MindMiner-Binary"
|
22 |
tokenizer = AutoTokenizer.from_pretrained(model_name)
|
23 |
model = AutoModelForSequenceClassification.from_pretrained(model_name)
|
24 |
trainer = Trainer(model=model)
|
|
|
78 |
temp = (np.exp(predictions[0])/np.exp(predictions[0]).sum(-1,keepdims=True))
|
79 |
|
80 |
# container
|
81 |
+
high = []
|
82 |
+
low = []
|
|
|
|
|
|
|
|
|
|
|
83 |
|
84 |
# extract scores (as many entries as exist in pred_texts)
|
85 |
for i in range(len(lines_s)):
|
86 |
+
high.append(round(temp[i][0], 3))
|
87 |
+
low.append(round(temp[i][1], 3))
|
88 |
+
|
|
|
|
|
|
|
|
|
89 |
|
90 |
# define df
|
91 |
+
df = pd.DataFrame(list(zip(ids,lines_s,labels,scores_rounded, high, low)), columns=[df_input.columns[0], df_input.columns[1],'max_label','max_score', 'high', 'low'])
|
92 |
print(df)
|
93 |
# save results to csv
|
94 |
+
YOUR_FILENAME = filename.name.split(".")[0] + "_MindMiner_Predictions" + ".csv" # name your output file
|
95 |
df.to_csv(YOUR_FILENAME, index=False)
|
96 |
|
97 |
# return dataframe for space output
|