Views
No views yet
1from transformers import pipeline
2
3# Load fine-tuned model
4model_checkpoint = "azherali/MarianMT-english-urdu"
5
6# Create translation pipeline
7translator = pipeline(
8 "translation",
9 model=model_checkpoint,
10 tokenizer=model_checkpoint,
11 src_lang="en_XX",
12 tgt_lang="ur_PK"
13)
14
15# Run example translation
16sentence = "I am very happy today."
17result = translator(sentence)
18
19print("Input:", sentence)
20print("Translation:", result[0]['translation_text'])