Spaces:
Sleeping
Sleeping
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() |