Spaces:
Sleeping
Sleeping
File size: 440 Bytes
03a8026 d0c4312 90748dd 9c2c875 90748dd 03a8026 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
from transformers import FSMTForConditionalGeneration, FSMTTokenizer
mname = "facebook/wmt19-en-ru"
tokenizer = FSMTTokenizer.from_pretrained(
mname)
model = FSMTForConditionalGeneration.from_pretrained(
mname)
def translator_en_ru(text):
input_ids = tokenizer.encode(text, return_tensors="pt")
outputs = model.generate(input_ids)
decoded = tokenizer.decode(outputs[0], skip_special_tokens=True)
return decoded
|