troer / app.py
lgrobol's picture
Use the BetterTransformer pipeline for faster inference (#5)
b4140e0
raw
history blame contribute delete
No virus
723 Bytes
import gradio as gr
from optimum.pipelines import pipeline
pipeline = pipeline(task="translation", model="lgrobol/m2m100_418M_br_fr", accelerator="bettertransformer")
def predict(texts):
predictions = pipeline(texts.splitlines(), src_lang="br", tgt_lang="fr")
return "\n".join(p["translation_text"] for p in predictions)
gr.Interface(
predict,
inputs=gr.Textbox(label="Breton", placeholder="Entrez des phrases en Breton. Une phrase par ligne, une ligne par phrase."),
outputs=gr.Textbox(label="Français"),
title="Traduction Breton-Français",
article="Cette interface utilse le modèle de traduction automatique [m2m100_418M_br_fr](https://huggingface.co/lgrobol/m2m100_418M_br_fr).",
).launch()