Moleys commited on
Commit
324df03
·
verified ·
1 Parent(s): b30e98b

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +27 -0
app.py ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from transformers import pipeline
3
+
4
+ # Load translation pipeline
5
+ pipe = pipeline("translation", model="chi-vi/hirashiba-mt-tiny-zh-vi")
6
+
7
+ def translate_text(input_text):
8
+ output_text = pipe(input_text, max_length=512)[0]['translation_text']
9
+ return output_text
10
+
11
+ if __name__ == '__main__':
12
+ with gr.Blocks() as app:
13
+ gr.Markdown('## Chinese to Vietnamese Translation')
14
+
15
+ with gr.Row():
16
+ with gr.Column(scale=1):
17
+ input_text = gr.Textbox(label='Input Chinese Text', lines=5, placeholder='Enter Chinese text here...')
18
+ translate_button = gr.Button('Translate')
19
+ output_text = gr.Textbox(label='Output Vietnamese Text', lines=5, interactive=False)
20
+
21
+ translate_button.click(
22
+ fn=translate_text,
23
+ inputs=input_text,
24
+ outputs=output_text
25
+ )
26
+
27
+ app.launch()