File size: 1,077 Bytes
3d4f13a
 
 
 
 
501291b
3d4f13a
 
 
 
501291b
3d4f13a
 
 
501291b
3d4f13a
 
 
 
 
 
 
 
 
 
 
 
 
 
 
501291b
3d4f13a
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
import gradio as gr
from gradio.mix import Parallel, Series

from transformers import pipeline

translater = pipeline("translation", model="VietAI/envit5-translation")

 
def translate(inp):
    text = "en: " + inp
    res = translater(
        text,
        max_length=512,
        early_stopping=True,
    )[0]['translation_text'][3:]
    return res



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.'],]

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>"


iface = gr.Interface(fn=translate, 
  inputs = gr.inputs.Textbox(
      lines = 5,
      label = 'Enter an article...'
  ),
  outputs = 'text',
  title = 'En<->Vi MTet Translation',
  theme = 'grass',
  layout = 'horizontal',
  article=article,
  examples=sample_url)

iface.launch()