Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -47,39 +47,43 @@ example_prompts = [
|
|
47 |
"I envy people that know love.",
|
48 |
"Nature is so beautiful"]
|
49 |
|
50 |
-
|
51 |
-
|
52 |
-
# Take the message which needs to be processed
|
53 |
-
message = st.text_area("...or paste some text to see the model's predictions", example)
|
54 |
-
# st.title(message)
|
55 |
-
st.text('')
|
56 |
-
models_to_choose = [
|
57 |
-
"amazon-sagemaker-community/xlm-roberta-en-ru-emoji-v2",
|
58 |
-
"AlekseyDorkin/xlm-roberta-en-ru-emoji"
|
59 |
-
]
|
60 |
-
|
61 |
-
model_name = st.selectbox("Choose a model", models_to_choose)
|
62 |
-
if model_name != cur_model_name:
|
63 |
-
print("reloading model")
|
64 |
-
cur_model_name = model_name
|
65 |
-
tokenizer = AutoTokenizer.from_pretrained(cur_model_name)
|
66 |
-
model = AutoModelForSequenceClassification.from_pretrained(cur_model_name)
|
67 |
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
47 |
"I envy people that know love.",
|
48 |
"Nature is so beautiful"]
|
49 |
|
50 |
+
def main():
|
51 |
+
example = st.selectbox("Choose an example", example_prompts)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
52 |
|
53 |
+
# Take the message which needs to be processed
|
54 |
+
message = st.text_area("...or paste some text to see the model's predictions", example)
|
55 |
+
# st.title(message)
|
56 |
+
st.text('')
|
57 |
+
models_to_choose = [
|
58 |
+
"amazon-sagemaker-community/xlm-roberta-en-ru-emoji-v2",
|
59 |
+
"AlekseyDorkin/xlm-roberta-en-ru-emoji"
|
60 |
+
]
|
61 |
+
|
62 |
+
model_name = st.selectbox("Choose a model", models_to_choose)
|
63 |
+
if model_name != cur_model_name:
|
64 |
+
print("reloading model")
|
65 |
+
cur_model_name = model_name
|
66 |
+
tokenizer = AutoTokenizer.from_pretrained(cur_model_name)
|
67 |
+
model = AutoModelForSequenceClassification.from_pretrained(cur_model_name)
|
68 |
+
|
69 |
+
|
70 |
+
# Define function to run when submit is clicked
|
71 |
+
def submit(message):
|
72 |
+
if len(message) > 0:
|
73 |
+
st.header(get_top_emojis(message, tokenizer=tokenizer, model=model))
|
74 |
+
else:
|
75 |
+
st.error("The text can't be empty")
|
76 |
+
|
77 |
+
# Run algo when submit button is clicked
|
78 |
+
if st.button('Submit'):
|
79 |
+
submit(message)
|
80 |
+
|
81 |
+
st.text('')
|
82 |
+
st.markdown(
|
83 |
+
'''<span style="color:blue; font-size:10px">App created by [@AlekseyDorkin](https://huggingface.co/AlekseyDorkin)
|
84 |
+
and [@akshay7](https://huggingface.co/akshay7)</span>''',
|
85 |
+
unsafe_allow_html=True,
|
86 |
+
)
|
87 |
+
|
88 |
+
if __name__ == "__main__":
|
89 |
+
main()
|