Spaces:
Sleeping
Sleeping
import gradio as gr | |
from transformers import AutoModelForSeq2SeqLM, NllbTokenizer | |
model_name = "sarahai/nllb-ru-uz" | |
model = AutoModelForSeq2SeqLM.from_pretrained(model_name) | |
tokenizer = NllbTokenizer.from_pretrained(model_name) | |
def translate(text, src_lang="rus_Cyrl", tgt_lang="uzn_Latn"): | |
inputs = tokenizer(text, return_tensors="pt") | |
translated = model.generate(**inputs) | |
return tokenizer.batch_decode(translated, skip_special_tokens=True)[0] | |
interface = gr.Interface( | |
fn=translate, | |
inputs=[gr.Textbox(label="Text to Translate")], | |
outputs="textbox", | |
title="Русско-Узбекский Переводчик", | |
description="Перевод русских текстов на узбекский с помощью `sarahai/nllb-ru-uz` model.", | |
) | |
interface.launch(share=True, debug=True) | |