bto00 commited on
Commit
bf82756
·
1 Parent(s): 3dfb1ad
Files changed (1) hide show
  1. app.py +17 -10
app.py CHANGED
@@ -1,15 +1,22 @@
1
  import streamlit as st
2
- from transformers import pipeline
3
 
4
- print("Loading the model.......mm")
5
- print("Hello")
6
- st.title("Sentiment Analysis")
7
- st.write(" Powered by Hugging Face and Streamlit")
8
 
 
 
 
 
9
 
10
- print('before slider')
11
- x = st.slider('Select a value')
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.")