Skip to content

Left and Right blocks aren't sorted #113

@AnzorGozalishvili

Description

@AnzorGozalishvili

Describe the bug
Bug in the python code while sorting layout blocks.

Checklist

  1. I used python "sorted" function to solve that issue.

To Reproduce
Steps to reproduce the behavior:

  1. What command or script did you run?
h, w = image.shape[:2]

left_interval = lp.Interval(0, w/2*1.05, axis='x').put_on_canvas(image)

left_blocks = text_blocks.filter_by(left_interval, center=True)
left_blocks.sort(key = lambda b:b.coordinates[1])

right_blocks = [b for b in text_blocks if b not in left_blocks]
right_blocks.sort(key = lambda b:b.coordinates[1])

# And finally combine the two list and add the index
# according to the order
text_blocks = lp.Layout([b.set(id = idx) for idx, b in enumerate(left_blocks + right_blocks)])

THIS CODE IS PASTED FROM DOCUMENTATION PAGE: https://layout-parser.readthedocs.io/en/latest/example/deep_layout_parsing/index.html

Environment

  1. Just run on google colab
  2. layoutparser version: 0.3.2
  3. I installed layoutparser using pip and the installed detectron2 from source.

Error traceback
N/A

Screenshots
image

Additional context
Because I am short in time I've created an issue for that instead of PR.
"sorted(left_blocks, key=lambda x:x.coordinates[1]))" use such sorting to fix bug.
image

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions