Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -1,37 +1,25 @@
|
|
1 |
import gradio as gr
|
2 |
import os
|
3 |
import cv2
|
4 |
-
|
5 |
-
from paddleocr import PPStructure,save_structure_res
|
6 |
-
from paddleocr.ppstructure.recovery.recovery_to_doc import sorted_layout_boxes, convert_info_docx
|
7 |
-
|
8 |
|
9 |
# Chinese image
|
10 |
-
table_engine = PPStructure(
|
11 |
-
|
12 |
-
# English image
|
13 |
-
# table_engine = PPStructure(recovery=True, lang='en')
|
14 |
|
15 |
examples = ['0.png']
|
16 |
|
17 |
def find_layout(image):
|
18 |
-
|
19 |
-
# img = cv2.imread(image)
|
20 |
-
img = np.array(image)
|
21 |
result = table_engine(img)
|
22 |
-
# save_structure_res(result, save_folder,
|
23 |
|
24 |
-
|
25 |
for line in result:
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
# h, w, _ = img.shape
|
31 |
-
# res = sorted_layout_boxes(result, w)
|
32 |
-
# convert_info_docx(img, res, save_folder, os.path.basename("result").split('.')[0])
|
33 |
-
|
34 |
-
return final_text
|
35 |
|
|
|
|
|
36 |
iface = gr.Interface(fn=find_layout, inputs=[gr.Image(type="pil")], outputs="text", examples=examples)
|
37 |
iface.launch()
|
|
|
1 |
import gradio as gr
|
2 |
import os
|
3 |
import cv2
|
4 |
+
from paddleocr import PPStructure,draw_structure_result,save_structure_res
|
|
|
|
|
|
|
5 |
|
6 |
# Chinese image
|
7 |
+
table_engine = PPStructure(show_log=True)
|
|
|
|
|
|
|
8 |
|
9 |
examples = ['0.png']
|
10 |
|
11 |
def find_layout(image):
|
12 |
+
img = cv2.imread(image)
|
|
|
|
|
13 |
result = table_engine(img)
|
14 |
+
# save_structure_res(result, save_folder,os.path.basename(img_path).split('.')[0])
|
15 |
|
16 |
+
output = []
|
17 |
for line in result:
|
18 |
+
line.pop('img')
|
19 |
+
print(line)
|
20 |
+
output.append(line)
|
|
|
|
|
|
|
|
|
|
|
|
|
21 |
|
22 |
+
return output
|
23 |
+
|
24 |
iface = gr.Interface(fn=find_layout, inputs=[gr.Image(type="pil")], outputs="text", examples=examples)
|
25 |
iface.launch()
|