Skip to content

Commit ee56bac

Browse files
authored
fix bug (#3683)
1 parent f94dbab commit ee56bac

File tree

1 file changed

+10
-11
lines changed

1 file changed

+10
-11
lines changed

paddlex/inference/pipelines/layout_parsing/result_v2.py

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -332,31 +332,30 @@ def get_seg_flag(block, prev_block):
332332
prev_block_bbox = prev_block["block_bbox"]
333333
num_of_prev_lines = prev_block.get("num_of_lines")
334334
pre_block_seg_end_coordinate = prev_block.get("seg_end_coordinate")
335+
prev_end_space_small = (
336+
prev_block_bbox[2] - pre_block_seg_end_coordinate < 10
337+
)
338+
prev_lines_more_than_one = num_of_prev_lines > 1
339+
340+
overlap_blocks = context_left_coordinate < prev_block_bbox[2]
335341

336342
# update context_left_coordinate and context_right_coordinate
337-
if context_left_coordinate < prev_block_bbox[2]:
343+
if overlap_blocks:
338344
context_left_coordinate = min(
339345
prev_block_bbox[0], context_left_coordinate
340346
)
341347
context_right_coordinate = max(
342348
prev_block_bbox[2], context_right_coordinate
343349
)
350+
prev_end_space_small = (
351+
context_right_coordinate - pre_block_seg_end_coordinate < 10
352+
)
344353

345-
# 判断是否需要分段
346-
prev_end_space_small = (
347-
prev_block_bbox[2] - pre_block_seg_end_coordinate < 10
348-
)
349354
current_start_space_small = (
350355
seg_start_coordinate - context_left_coordinate < 10
351356
)
352-
overlap_blocks = context_left_coordinate < prev_block_bbox[2]
353-
prev_lines_more_than_one = num_of_prev_lines > 1
354357

355358
if (
356-
overlap_blocks
357-
and current_start_space_small
358-
and prev_lines_more_than_one
359-
) or (
360359
prev_end_space_small
361360
and current_start_space_small
362361
and prev_lines_more_than_one

0 commit comments

Comments
 (0)