Spaces:
Runtime error
Runtime error
story model is always indonesian
Browse files
app.py
CHANGED
@@ -158,13 +158,17 @@ session_state.text = st.text_area("Enter text", session_state.prompt_box)
|
|
158 |
|
159 |
if st.button("Run"):
|
160 |
with st.spinner(text="Getting results..."):
|
161 |
-
|
162 |
-
if "__label__id" in lang_predictions:
|
163 |
lang = "id"
|
164 |
text = session_state.text
|
165 |
else:
|
166 |
-
|
167 |
-
|
|
|
|
|
|
|
|
|
|
|
168 |
|
169 |
st.subheader("Result")
|
170 |
result = process(text=text,
|
|
|
158 |
|
159 |
if st.button("Run"):
|
160 |
with st.spinner(text="Getting results..."):
|
161 |
+
if model_name in ["GPT-2 Medium finetuned on Indonesian stories"]:
|
|
|
162 |
lang = "id"
|
163 |
text = session_state.text
|
164 |
else:
|
165 |
+
lang_predictions, lang_probability = ft_model.predict(session_state.text.replace("\n", " "), k=3)
|
166 |
+
if "__label__id" in lang_predictions:
|
167 |
+
lang = "id"
|
168 |
+
text = session_state.text
|
169 |
+
else:
|
170 |
+
lang = lang_predictions[0].replace("__label__", "")
|
171 |
+
text = translate(session_state.text, "id", lang)
|
172 |
|
173 |
st.subheader("Result")
|
174 |
result = process(text=text,
|