Spaces:
Sleeping
Sleeping
Yaron Koresh
commited on
Update app.py
Browse files
app.py
CHANGED
@@ -640,13 +640,13 @@ def translate(txt,to_lang="en",from_lang=False):
|
|
640 |
if(from_lang == to_lang):
|
641 |
log(f'RET translate with txt as {txt}')
|
642 |
return txt
|
643 |
-
inputs = tokenizer.encode(f"translate {from_lang} to {to_lang}: " + txt, return_tensors="pt", max_length=float('inf'), truncation=False)
|
644 |
chunks_length = math.ceil(get_tensor_length(inputs) / 512)
|
645 |
ret = ""
|
646 |
for index in range(chunks_length):
|
647 |
ret = ret + ("" if ret == "" else " ") + tokenizer.decode(
|
648 |
model.generate(
|
649 |
-
torch.tensor([list(inputs[0][ index*512:index*512+512 ])])
|
650 |
)[0], skip_special_tokens=True
|
651 |
)
|
652 |
log(f'RET translate with ret as {ret}')
|
|
|
640 |
if(from_lang == to_lang):
|
641 |
log(f'RET translate with txt as {txt}')
|
642 |
return txt
|
643 |
+
inputs = tokenizer.encode(f"translate {from_lang} to {to_lang}: " + txt, return_tensors="pt", max_length=float('inf'), truncation=False).input_ids
|
644 |
chunks_length = math.ceil(get_tensor_length(inputs) / 512)
|
645 |
ret = ""
|
646 |
for index in range(chunks_length):
|
647 |
ret = ret + ("" if ret == "" else " ") + tokenizer.decode(
|
648 |
model.generate(
|
649 |
+
torch.tensor([list(inputs[0][ index*512:index*512+512 ])])
|
650 |
)[0], skip_special_tokens=True
|
651 |
)
|
652 |
log(f'RET translate with ret as {ret}')
|