Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -1,9 +1,33 @@
|
|
1 |
import streamlit as st
|
2 |
-
|
|
|
|
|
3 |
|
4 |
-
|
5 |
-
|
|
|
|
|
|
|
|
|
|
|
6 |
|
7 |
if text:
|
8 |
-
|
9 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
import streamlit as st
|
2 |
+
import torch
|
3 |
+
import numpy as np
|
4 |
+
from transformers import AutoTokenizer, AutoModelForSequenceClassification
|
5 |
|
6 |
+
tokenizer1 = AutoTokenizer.from_pretrained('kitkeat/distilbert-based-uncased-argumentativewriting')
|
7 |
+
tokenizer2 = AutoTokenizer.from_pretrained('kitkeat/bert-large-uncased-sparse-90-unstructured-pruneofa-argumentativewriting')
|
8 |
+
tokenizer3 = AutoTokenizer.from_pretrained('kitkeat/deberta-v3-base-argumentativewriting')
|
9 |
+
model1 = AutoModelForSequenceClassification.from_pretrained('kitkeat/distilbert-based-uncased-argumentativewriting',num_labels=3)
|
10 |
+
model2 = AutoModelForSequenceClassification.from_pretrained('kitkeat/bert-large-uncased-sparse-90-unstructured-pruneofa-argumentativewriting',num_labels=3)
|
11 |
+
model3 = AutoModelForSequenceClassification.from_pretrained('kitkeat/deberta-v3-base-argumentativewriting',num_labels=3)
|
12 |
+
text = st.text_area('Input Here!')
|
13 |
|
14 |
if text:
|
15 |
+
inputs1 = tokenizer1(text, padding=True, truncation=True, return_tensors="pt")
|
16 |
+
inputs2 = tokenizer2(text, padding=True, truncation=True, return_tensors="pt")
|
17 |
+
inputs3 = tokenizer3(text, padding=True, truncation=True, return_tensors="pt")
|
18 |
+
|
19 |
+
outputs1 = model1(**inputs1)
|
20 |
+
outputs2 = model2(**inputs2)
|
21 |
+
outputs3 = model3(**inputs3)
|
22 |
+
|
23 |
+
prediction = outputs1.logits.argmax(dim=-1).item()
|
24 |
+
# model.config.id2label
|
25 |
+
|
26 |
+
if prediction == 0:
|
27 |
+
out = 'Adequate'
|
28 |
+
elif prediction == 1:
|
29 |
+
out = 'Effective'
|
30 |
+
elif prediction == 2:
|
31 |
+
out = 'Ineffective'
|
32 |
+
|
33 |
+
st.json(out)
|