onursavas commited on
Commit
513b66c
·
1 Parent(s): d79cab6

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -6
app.py CHANGED
@@ -8,12 +8,11 @@ from paddleocr.ppstructure.recovery.recovery_to_doc import sorted_layout_boxes,
8
  table_engine = PPStructure(recovery=True)
9
  # English image
10
  # table_engine = PPStructure(recovery=True, lang='en')
11
- def find_layout(name):
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
  final_text = ""
19
  for line in result:
@@ -22,9 +21,9 @@ def find_layout(name):
22
  final_text += "\n" + line
23
  h, w, _ = img.shape
24
  res = sorted_layout_boxes(result, w)
25
- convert_info_docx(img, res, save_folder, os.path.basename(img_path).split('.')[0])
26
 
27
  return final_text
28
 
29
- iface = gr.Interface(fn=find_layout, inputs="text", outputs="text")
30
  iface.launch()
 
8
  table_engine = PPStructure(recovery=True)
9
  # English image
10
  # table_engine = PPStructure(recovery=True, lang='en')
11
+ def find_layout(image):
12
  save_folder = './output'
13
+ img = cv2.imread(image)
 
14
  result = table_engine(img)
15
+ save_structure_res(result, save_folder, os.path.basename("result").split('.')[0])
16
 
17
  final_text = ""
18
  for line in result:
 
21
  final_text += "\n" + line
22
  h, w, _ = img.shape
23
  res = sorted_layout_boxes(result, w)
24
+ convert_info_docx(img, res, save_folder, os.path.basename("result").split('.')[0])
25
 
26
  return final_text
27
 
28
+ iface = gr.Interface(fn=find_layout, inputs=[gr.Image()], outputs="text")
29
  iface.launch()