Update app.py
Browse filesUpdated app.py
app.py
CHANGED
@@ -1,25 +1,18 @@
|
|
1 |
-
|
2 |
from transformers import pipeline
|
3 |
|
4 |
-
# Load translation model
|
5 |
translator = pipeline('translation_en_to_uk', model='Helsinki-NLP/opus-mt-en-uk')
|
6 |
|
7 |
-
#
|
8 |
-
|
9 |
|
10 |
-
|
11 |
-
def home():
|
12 |
-
return open("index.html").read()
|
13 |
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
translated_text = translator(text, max_length=100)[0]['translation_text']
|
22 |
-
return jsonify({"translation": translated_text})
|
23 |
-
|
24 |
-
if __name__ == "__main__":
|
25 |
-
app.run(host="0.0.0.0", port=8080)
|
|
|
1 |
+
import streamlit as st
|
2 |
from transformers import pipeline
|
3 |
|
4 |
+
# Load the translation model
|
5 |
translator = pipeline('translation_en_to_uk', model='Helsinki-NLP/opus-mt-en-uk')
|
6 |
|
7 |
+
# Streamlit UI
|
8 |
+
st.title("English to Ukrainian Translator")
|
9 |
|
10 |
+
text = st.text_area("Enter English text:")
|
|
|
|
|
11 |
|
12 |
+
if st.button("Translate"):
|
13 |
+
if text:
|
14 |
+
translated_text = translator(text, max_length=100)[0]['translation_text']
|
15 |
+
st.subheader("Translation:")
|
16 |
+
st.write(translated_text)
|
17 |
+
else:
|
18 |
+
st.warning("Please enter text to translate.")
|
|
|
|
|
|
|
|
|
|