Translate
Browse files
app.py
CHANGED
@@ -1,15 +1,22 @@
|
|
1 |
import streamlit as st
|
2 |
-
from transformers import pipeline
|
3 |
|
4 |
-
|
5 |
-
|
6 |
-
st.title("Sentiment Analysis")
|
7 |
-
st.write(" Powered by Hugging Face and Streamlit")
|
8 |
|
|
|
|
|
|
|
|
|
9 |
|
10 |
-
|
11 |
-
|
12 |
-
st.write(x, 'squared is', x * x)
|
13 |
-
print("after slider")
|
14 |
|
15 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
import streamlit as st
|
2 |
+
from transformers import pipeline, AutoModelForSeq2SeqLM, AutoTokenizer
|
3 |
|
4 |
+
st.title("Translation App (Kazakh to English)")
|
5 |
+
st.write("Powered by Hugging Face and Streamlit")
|
|
|
|
|
6 |
|
7 |
+
# Load model and tokenizer
|
8 |
+
st.write("Loading the model, please wait...")
|
9 |
+
model = AutoModelForSeq2SeqLM.from_pretrained('issai/tilmash')
|
10 |
+
tokenizer = AutoTokenizer.from_pretrained("issai/tilmash")
|
11 |
|
12 |
+
# Initialize translation pipeline
|
13 |
+
tilmash = pipeline("translation", model=model, tokenizer=tokenizer, src_lang="kaz_Cyrl", tgt_lang="eng_Latn", max_length=1000)
|
|
|
|
|
14 |
|
15 |
+
# Input text
|
16 |
+
input_text = st.text_area("Enter text in Kazakh:")
|
17 |
+
if st.button("Translate"):
|
18 |
+
if input_text.strip():
|
19 |
+
translation = tilmash(input_text)
|
20 |
+
st.write("Translation:", translation[0]['translation_text'])
|
21 |
+
else:
|
22 |
+
st.write("Please enter some text to translate.")
|