lilsha commited on
Commit
b5b57b6
1 Parent(s): 3c81895

Upload 2 files

Browse files
Files changed (2) hide show
  1. app.py +26 -0
  2. requirements.txt +4 -0
app.py ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ from transformers import pipeline
3
+
4
+ # Create a translation pipeline
5
+ translator = pipeline("translation", model="lilsha/transentoch")
6
+
7
+ def main():
8
+ st.title("Translate English to Chinese")
9
+
10
+ with st.form("text_field"):
11
+ text = st.text_area('Enter text:')
12
+ clicked = st.form_submit_button("Translate")
13
+
14
+ if clicked:
15
+ # Translate the input text
16
+ translation = translator(text, src_lang="en", tgt_lang="ch")
17
+
18
+ # Display the translated text
19
+ if translation:
20
+ st.write("Translation :")
21
+ st.write(translation[0]["translation_text"])
22
+ else:
23
+ st.write("Translation failed. Please check your input.")
24
+
25
+ if __name__ == "__main__":
26
+ main()
requirements.txt ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ torch
2
+ transformers
3
+ altair<5
4
+ sentencepiece