Spaces:
Running
Running
import gradio as gr | |
from gradio.mix import Parallel, Series | |
from transformers import pipeline | |
summarizer = pipeline("translation", model="VietAI/envit5-mtet_phomt-translation", use_auth_token=True) | |
def translate(inp): | |
text = "en: " + inp | |
res = summarizer( | |
text, | |
max_length=512, | |
early_stopping=True, | |
)[0]['translation_text'] | |
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:heraclex12@gmail.com' 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() |