Spaces:
Running
Running
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() |