Spaces:
Sleeping
Sleeping
Zengyf-CVer
commited on
Commit
•
755ce29
1
Parent(s):
db4ed1a
app update
Browse files
app.py
CHANGED
@@ -76,16 +76,20 @@ def translate(input_text):
|
|
76 |
translate_text = ""
|
77 |
input_text_list = input_text.split("\n\n")
|
78 |
|
|
|
79 |
for i in range(len(input_text_list)):
|
|
|
|
|
|
|
|
|
80 |
translated_sub = model.generate(
|
81 |
-
**tokenizer(sent_tokenize(
|
82 |
tgt_text_sub = [tokenizer.decode(t, skip_special_tokens=True) for t in translated_sub]
|
83 |
translate_text_sub = "".join(tgt_text_sub)
|
84 |
translate_text = translate_text + "\n\n" + translate_text_sub
|
85 |
|
86 |
return translate_text[2:]
|
87 |
|
88 |
-
|
89 |
def main():
|
90 |
|
91 |
with gr.Blocks(css='style.css') as ocr_tr:
|
|
|
76 |
translate_text = ""
|
77 |
input_text_list = input_text.split("\n\n")
|
78 |
|
79 |
+
translate_text_list_tmp = []
|
80 |
for i in range(len(input_text_list)):
|
81 |
+
if input_text_list[i] != "":
|
82 |
+
translate_text_list_tmp.append(input_text_list[i])
|
83 |
+
|
84 |
+
for i in range(len(translate_text_list_tmp)):
|
85 |
translated_sub = model.generate(
|
86 |
+
**tokenizer(sent_tokenize(translate_text_list_tmp[i]), return_tensors="pt", truncation=True, padding=True))
|
87 |
tgt_text_sub = [tokenizer.decode(t, skip_special_tokens=True) for t in translated_sub]
|
88 |
translate_text_sub = "".join(tgt_text_sub)
|
89 |
translate_text = translate_text + "\n\n" + translate_text_sub
|
90 |
|
91 |
return translate_text[2:]
|
92 |
|
|
|
93 |
def main():
|
94 |
|
95 |
with gr.Blocks(css='style.css') as ocr_tr:
|