Update app.py
Browse files
app.py
CHANGED
@@ -22,15 +22,13 @@ def visualize(text):
|
|
22 |
@st.cache
|
23 |
def load_model(text):
|
24 |
|
25 |
-
|
26 |
checkpoint = 'mlkorra/OGBV-gender-bert-hi-en'
|
27 |
|
28 |
tokenizer = AutoTokenizer.from_pretrained(checkpoint)
|
29 |
model = AutoModelForSequenceClassification.from_pretrained(checkpoint)
|
30 |
|
31 |
nlp = pipeline('sentiment-analysis',model=model,tokenizer=tokenizer)
|
32 |
-
|
33 |
-
|
34 |
results = nlp(text)
|
35 |
|
36 |
return results
|
@@ -42,11 +40,20 @@ def load_model(text):
|
|
42 |
import re
|
43 |
def app():
|
44 |
st.title("OGBV-BERT")
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
50 |
|
51 |
pick_random = st.sidebar.checkbox("Pick any random text")
|
52 |
|
|
|
22 |
@st.cache
|
23 |
def load_model(text):
|
24 |
|
|
|
25 |
checkpoint = 'mlkorra/OGBV-gender-bert-hi-en'
|
26 |
|
27 |
tokenizer = AutoTokenizer.from_pretrained(checkpoint)
|
28 |
model = AutoModelForSequenceClassification.from_pretrained(checkpoint)
|
29 |
|
30 |
nlp = pipeline('sentiment-analysis',model=model,tokenizer=tokenizer)
|
31 |
+
|
|
|
32 |
results = nlp(text)
|
33 |
|
34 |
return results
|
|
|
40 |
import re
|
41 |
def app():
|
42 |
st.title("OGBV-BERT")
|
43 |
+
|
44 |
+
data = st.sidebar.radio("Pick the evaluation data :",('Twitter','Trac2020'))
|
45 |
+
|
46 |
+
if data=="Twitter":
|
47 |
+
|
48 |
+
target_text_path = "./input/tweet_list.csv"
|
49 |
+
target_text_df = pd.read_csv(target_text_path)
|
50 |
+
texts = target_text_df["text"]
|
51 |
+
|
52 |
+
else:
|
53 |
+
|
54 |
+
target_text_path = "./input/trac2_hin_test.csv"
|
55 |
+
target_text_df = pd.read_csv(target_text_path)
|
56 |
+
texts = target_text_df["Text"]
|
57 |
|
58 |
pick_random = st.sidebar.checkbox("Pick any random text")
|
59 |
|