Spaces:
Sleeping
Sleeping
Commit
·
c2483bf
1
Parent(s):
d0dc5fc
Update app.py
Browse files
app.py
CHANGED
@@ -11,11 +11,11 @@ import torch
|
|
11 |
|
12 |
tokenizer = AutoTokenizer.from_pretrained("Helsinki-NLP/opus-mt-en-ar")
|
13 |
model = torch.load("helsinki_fineTuned.pt", map_location=torch.device('cpu'))
|
14 |
-
translation_pipeline = pipeline(model)
|
15 |
|
16 |
|
17 |
def translate_gradio(input):
|
18 |
-
encode =
|
19 |
text_ar = tokenizer.batch_decode(encode,skip_special_tokens=True)[0]
|
20 |
return text_ar
|
21 |
|
|
|
11 |
|
12 |
tokenizer = AutoTokenizer.from_pretrained("Helsinki-NLP/opus-mt-en-ar")
|
13 |
model = torch.load("helsinki_fineTuned.pt", map_location=torch.device('cpu'))
|
14 |
+
#translation_pipeline = pipeline(model)
|
15 |
|
16 |
|
17 |
def translate_gradio(input):
|
18 |
+
encode = model.generate(**tokenizer.prepare_seq2seq_batch(input,return_tensors='pt').to('cuda'))
|
19 |
text_ar = tokenizer.batch_decode(encode,skip_special_tokens=True)[0]
|
20 |
return text_ar
|
21 |
|