alyxx
added requirements and app.py
c35181d
raw
history blame
837 Bytes
from transformers import pipeline
import gradio as gr
# Alternatoive model
# Helsinki-NLP/opus-mt-en-tl
# the translator pipeline
translator = pipeline(
"translation",
model="kaiku03/open_subtitles-finetuned-opus-mt-en-tl-accelerate"
)
# function for the gradio app
def fn_translator(prompt):
return translator(prompt)[0]['translation_text']
# gradio app
# Define example inputs and outputs
examples = [
"your such an idiot",
"lightning fast",
"no one likes me",
]
iface = gr.Interface(
fn=fn_translator,
inputs='text',
outputs=gr.Label(label="translation"),
examples=[
[ex] for ex in examples
],
title='English to Tagalog translator',
description='This demo performs language translation from English to Tagalog.',
article='All done by Kaiku',
)
iface.launch()