Spaces:
Runtime error
Runtime error
Onur Savas
commited on
Commit
·
efe1e83
1
Parent(s):
382dd74
add app
Browse files
app.py
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
import os
|
| 3 |
+
import cv2
|
| 4 |
+
from paddleocr import PPStructure,save_structure_res
|
| 5 |
+
from paddleocr.ppstructure.recovery.recovery_to_doc import sorted_layout_boxes, convert_info_docx
|
| 6 |
+
|
| 7 |
+
# Chinese image
|
| 8 |
+
table_engine = PPStructure(recovery=True)
|
| 9 |
+
# English image
|
| 10 |
+
# table_engine = PPStructure(recovery=True, lang='en')
|
| 11 |
+
|
| 12 |
+
save_folder = './output'
|
| 13 |
+
img_path = '0.png'
|
| 14 |
+
img = cv2.imread(img_path)
|
| 15 |
+
result = table_engine(img)
|
| 16 |
+
save_structure_res(result, save_folder, os.path.basename(img_path).split('.')[0])
|
| 17 |
+
|
| 18 |
+
for line in result:
|
| 19 |
+
line.pop('img')
|
| 20 |
+
print(line)
|
| 21 |
+
|
| 22 |
+
h, w, _ = img.shape
|
| 23 |
+
res = sorted_layout_boxes(result, w)
|
| 24 |
+
convert_info_docx(img, res, save_folder, os.path.basename(img_path).split('.')[0])
|
| 25 |
+
|
| 26 |
+
def greet(name):
|
| 27 |
+
return "Hello " + name + "!!"
|
| 28 |
+
|
| 29 |
+
iface = gr.Interface(fn=find_layout, inputs="text", outputs="text")
|
| 30 |
+
iface.launch()
|