Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -117,7 +117,10 @@ def up_file(files):
|
|
| 117 |
file_name = '{}-{}-{}.png'.format(str(time.time()), str(i), str(j))
|
| 118 |
with open(file_name, mode='wb') as f:
|
| 119 |
f.write(img['stream'].get_data())
|
| 120 |
-
|
|
|
|
|
|
|
|
|
|
| 121 |
if len(res) > 0:
|
| 122 |
res_list.append(' '.join([re['text'] for re in res]))
|
| 123 |
|
|
@@ -133,9 +136,8 @@ def up_file(files):
|
|
| 133 |
res_list.append(str(df))
|
| 134 |
|
| 135 |
doc_text_list += res_list
|
| 136 |
-
|
| 137 |
-
|
| 138 |
-
print(i)
|
| 139 |
return gr.Textbox.update(value='\n'.join(doc_text_list), visible=True), gr.Button.update(
|
| 140 |
visible=True), gr.Markdown.update(
|
| 141 |
value="操作说明 step 2:确认PDF解析结果(可修正),点击“提交解析结果”,随后进行对话")
|
|
@@ -161,4 +163,4 @@ with gr.Blocks() as demo:
|
|
| 161 |
|
| 162 |
if __name__ == "__main__":
|
| 163 |
demo.queue().launch()
|
| 164 |
-
# demo.queue().launch(share=False, server_name='172.22.2.54', server_port=9191)
|
|
|
|
| 117 |
file_name = '{}-{}-{}.png'.format(str(time.time()), str(i), str(j))
|
| 118 |
with open(file_name, mode='wb') as f:
|
| 119 |
f.write(img['stream'].get_data())
|
| 120 |
+
try:
|
| 121 |
+
res = ocr.ocr(file_name)
|
| 122 |
+
except Exception as e:
|
| 123 |
+
res = []
|
| 124 |
if len(res) > 0:
|
| 125 |
res_list.append(' '.join([re['text'] for re in res]))
|
| 126 |
|
|
|
|
| 136 |
res_list.append(str(df))
|
| 137 |
|
| 138 |
doc_text_list += res_list
|
| 139 |
+
doc_text_list = [str(text).strip() for text in doc_text_list if len(str(text).strip()) > 0]
|
| 140 |
+
print(doc_text_list)
|
|
|
|
| 141 |
return gr.Textbox.update(value='\n'.join(doc_text_list), visible=True), gr.Button.update(
|
| 142 |
visible=True), gr.Markdown.update(
|
| 143 |
value="操作说明 step 2:确认PDF解析结果(可修正),点击“提交解析结果”,随后进行对话")
|
|
|
|
| 163 |
|
| 164 |
if __name__ == "__main__":
|
| 165 |
demo.queue().launch()
|
| 166 |
+
# demo.queue().launch(share=False, server_name='172.22.2.54', server_port=9191)
|