from transformers import MarianMTModel, MarianTokenizer # تحميل نموذج الترجمة model_path = "/content/tst-translation/checkpoint-9" model = MarianMTModel.from_pretrained(model_path) tokenizer = MarianTokenizer.from_pretrained(model_path) # الجملة التي تريد ترجمتها sentence = "Others have dismissed him as a joke." # تحويل الجملة إلى توكنات inputs = tokenizer(sentence, return_tensors="pt", padding=True, truncation=True) # الترجمة translated = model.generate(**inputs) translated_sentence = tokenizer.batch_decode(translated, skip_special_tokens=True)[0] print("الجملة المترجمة:", translated_sentence)