Spaces:
Sleeping
Sleeping
File size: 852 Bytes
244edee |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
from transformers import pipeline
import torch
# Translator function
translator = pipeline(task="translation",
model="facebook/nllb-200-1.3B",
torch_dtype=torch.bfloat16)
import gradio as gr
def translate(input):
output = translator(input,
src_lang="fin_Latn",
tgt_lang="eng_Latn")
return output[0]['translation_text']
gr.close_all()
demo = gr.Interface(fn=translate,
inputs=[gr.Textbox(label="Text to translate", lines=6)],
outputs=[gr.Textbox(label="Result", lines=3)],
title="Text translation with nllb-200-1.3B",
description="Translate Finnish text using the `facebook/nllb-200-1.3B` model under the hood!"
)
demo.launch() |