Spaces:
Runtime error
Runtime error
File size: 636 Bytes
5ef186d 0ae08c7 5ef186d |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
from transformers import pipeline
from transformers import AutoModelForSeq2SeqLM, AutoTokenizer
max_length = 512
model_id = "ArissBandoss/nllb-200-distilled-600M-finetuned-fr-to-mos-V1"
tokenizer = AutoTokenizer.from_pretrained(model_id)
model = AutoModelForSeq2SeqLM.from_pretrained(model_id)
def goai_traduction(text, src_lang, tgt_lang):
trans_pipe = pipeline("translation",
model=model, tokenizer=tokenizer,
src_lang=src_lang, tgt_lang=tgt_lang,
max_length=max_length
)
return trans_pipe(text)[0]["translation_text"]
|