Simon Salmon
commited on
Commit
β’
ea909ce
1
Parent(s):
7e9cf73
Update app.py
Browse files
app.py
CHANGED
@@ -67,13 +67,6 @@ def main():
|
|
67 |
mlm_model = "BigSalmon/BestMask2"
|
68 |
mask_api = InferenceApi(mlm_model)
|
69 |
|
70 |
-
if analyze == "Emotion":
|
71 |
-
sa_model = "StevenLimcorn/indonesian-roberta-base-emotion-classifier"
|
72 |
-
elif analyze == "Sentiment":
|
73 |
-
sa_model = "w11wo/indonesian-roberta-base-sentiment-classifier"
|
74 |
-
|
75 |
-
sa_pipeline = pipeline("sentiment-analysis", model=sa_model, tokenizer=sa_model)
|
76 |
-
|
77 |
if len(user_input) > 0:
|
78 |
try:
|
79 |
user_input.index(MASK_TOKEN)
|
@@ -97,20 +90,6 @@ def main():
|
|
97 |
)
|
98 |
display_table(mlm_df_styled, "π Top 5 Predictions")
|
99 |
|
100 |
-
# render sentiment analysis table
|
101 |
-
sa_df = pd.DataFrame(columns=["sequence", "label", "score"])
|
102 |
-
for sequence in mlm_df["sequence"].values:
|
103 |
-
sa_output = sa_pipeline(sequence) # predict for every mlm output
|
104 |
-
result_dict = {"sequence": sequence}
|
105 |
-
result_dict.update(sa_output[0])
|
106 |
-
sa_df = sa_df.append(result_dict, ignore_index=True)
|
107 |
-
|
108 |
-
sa_df["label"] = sa_df["label"].apply(lambda x: x + " " + EMOJI_MAP[x])
|
109 |
-
sa_df_styled = sa_df.copy(deep=False)
|
110 |
-
sa_df_styled = sa_df_styled.style.set_properties(
|
111 |
-
subset=["sequence", "label", "score"], **{"text-align": "left"}
|
112 |
-
)
|
113 |
-
display_table(sa_df_styled, "π€ By saying that, I guess you are feeling..")
|
114 |
|
115 |
|
116 |
if __name__ == "__main__":
|
|
|
67 |
mlm_model = "BigSalmon/BestMask2"
|
68 |
mask_api = InferenceApi(mlm_model)
|
69 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
70 |
if len(user_input) > 0:
|
71 |
try:
|
72 |
user_input.index(MASK_TOKEN)
|
|
|
90 |
)
|
91 |
display_table(mlm_df_styled, "π Top 5 Predictions")
|
92 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
93 |
|
94 |
|
95 |
if __name__ == "__main__":
|