How can I run the model in python?

by Sohaib36 - opened

How can I run the model ?

Check this link:

from transformers import MarianMTModel, MarianTokenizer

src_text = [

model_name = "Helsinki-NLP/opus-mt-zh-en"
tokenizer = MarianTokenizer.from_pretrained(model_name)
model = MarianMTModel.from_pretrained(model_name)
translated = model.generate(**tokenizer(src_text, return_tensors="pt", padding=True))
res = [tokenizer.decode(t, skip_special_tokens=True) for t in translated]

the result is:

['Hello.', "It's a beautiful day!", 'Good moods are the most important.']

Sign up or log in to comment