import gradio as gr from transformers import M2M100Tokenizer, M2M100ForConditionalGeneration, pipeline model_name = "dsfsi/nr-en-m2m100-gov" tokenizer = M2M100Tokenizer.from_pretrained(model_name) model = M2M100ForConditionalGeneration.from_pretrained(model_name) tokenizer.src_lang = "nr" model.config.forced_bos_token_id = tokenizer.get_lang_id("en") translater_nr_en = pipeline( "translation", model=model, tokenizer=tokenizer, ) def translate(inp): res = translater_nr_en(inp, max_length=512, early_stopping=True)[0]['translation_text'] return res # Update description and article as needed description = """