Gallek / app.py
amurienne's picture
Create app.py
19d9370 verified
raw
history blame
776 Bytes
import gradio as gr
from transformers import AutoTokenizer, AutoModelForSeq2SeqLM, pipeline
modelcard = "amurienne/gallek-m2m100"
model = AutoModelForSeq2SeqLM.from_pretrained(modelcard)
tokenizer = AutoTokenizer.from_pretrained(modelcard)
def translate(text):
"""
Translate the text from source lang fr to target lang br
"""
translation_pipeline = pipeline("translation", model=model, tokenizer=tokenizer, src_lang='fr', tgt_lang='br', max_length=400, device="cuda")
result = translation_pipeline(text)
return result[0]['translation_text']
demo = gr.Interface(
fn=translate,
inputs=[
gr.components.Textbox(label="Text"),
],
outputs=["text"],
cache_examples=False,
title="Gallek Translation Demo",
)
demo.launch()