Update app.py
Browse files
app.py
CHANGED
|
@@ -66,15 +66,16 @@ def ACE(file):
|
|
| 66 |
for seq in all:
|
| 67 |
test_data = tokenizer(seq, max_length=max_len, padding="max_length",truncation=True, return_tensors='pt')
|
| 68 |
out_probability = []
|
| 69 |
-
|
| 70 |
-
|
| 71 |
-
|
| 72 |
-
|
| 73 |
-
|
| 74 |
-
|
| 75 |
-
|
| 76 |
-
|
| 77 |
-
|
|
|
|
| 78 |
|
| 79 |
summary = OrderedDict()
|
| 80 |
summary['Seq'] = seq_all
|
|
|
|
| 66 |
for seq in all:
|
| 67 |
test_data = tokenizer(seq, max_length=max_len, padding="max_length",truncation=True, return_tensors='pt')
|
| 68 |
out_probability = []
|
| 69 |
+
with torch.no_grad():
|
| 70 |
+
predict = model(test_data)
|
| 71 |
+
out_probability.extend(np.max(np.array(predict.cpu()),axis=1).tolist())
|
| 72 |
+
test_argmax = np.argmax(predict.cpu(), axis=1).tolist()
|
| 73 |
+
id2str = {0:"non-ACE", 1:"ACE"}
|
| 74 |
+
output = id2str[test_argmax[0]]
|
| 75 |
+
probability = out_probability[0]
|
| 76 |
+
seq_all.append(seq)
|
| 77 |
+
output_all.append(output)
|
| 78 |
+
probability_all.append(probability)
|
| 79 |
|
| 80 |
summary = OrderedDict()
|
| 81 |
summary['Seq'] = seq_all
|