razent commited on
Commit
3d4f13a
1 Parent(s): 4f9613b

Create new file

Browse files
Files changed (1) hide show
  1. app.py +37 -0
app.py ADDED
@@ -0,0 +1,37 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from gradio.mix import Parallel, Series
3
+
4
+ from transformers import pipeline
5
+
6
+ summarizer = pipeline("translation", model="VietAI/envit5-mtet_phomt-translation", use_auth_token=True)
7
+
8
+
9
+ def translate(inp):
10
+ text = "en: " + inp
11
+ res = summarizer(
12
+ text,
13
+ max_length=512,
14
+ early_stopping=True,
15
+ )[0]['translation_text']
16
+ return res
17
+
18
+
19
+
20
+ sample_url = [['VietAI is a non-profit organization with the mission of nurturing AI talents and building a community of world-class AI experts in Vietnam.'],]
21
+
22
+ article = "<p style='text-align: center'><a href='https://vietai.org' target='_blank'>by VietAI Research</a> | <a href='https://github.com/vietai/mtet' target='_blank'>Github</a> | Contact: <a href='mailto:[email protected]' target='_blank'>Hieu Tran</a></p></center></p>"
23
+
24
+
25
+ iface = gr.Interface(fn=translate,
26
+ inputs = gr.inputs.Textbox(
27
+ lines = 5,
28
+ label = 'Enter an article...'
29
+ ),
30
+ outputs = 'text',
31
+ title = 'En->Vi MTet Translation',
32
+ theme = 'grass',
33
+ layout = 'horizontal',
34
+ article=article,
35
+ examples=sample_url)
36
+
37
+ iface.launch()