-
Notifications
You must be signed in to change notification settings - Fork 72
Closed
Description
Error
File "../unstructured-inference/inference/ordering.py", line 32, in order_layout
layout.sort(
File "../unstructured-inference/inference/ordering.py", line 33, in <lambda>
key=lambda element: (element.bbox.y1, element.bbox.x1, element.bbox.y2, element.bbox.x2),
AttributeError: 'NoneType' object has no attribute 'y1'
Debugging
When running chipperv1 on a document, output for a page had the following element in the layout
LayoutElement(bbox=None, text='', source=<Source.CHIPPERV1: 'chipperv1'>, type='Picture', prob=None, image_path=None, parent=LayoutElement(bbox=Rectangle(x1=101.26530612244898, y1=87.20068027210884, x2=1654, y2=1675.0969387755104), text='', source=<Source.CHIPPERV1: 'chipperv1'>, type='Picture', prob=None, image_path=None, parent=None))
Possible Fix
Change unstructured_inference/inference/ordering.py line 33 from
layout.sort(
key=lambda element: (element.bbox.y1, element.bbox.x1, element.bbox.y2, element.bbox.x2),
)
to
layout.sort(
key=lambda element: (
float('inf') if element.bbox is None else element.bbox.y1,
float('inf') if element.bbox is None else element.bbox.x1,
float('inf') if element.bbox is None else element.bbox.y2,
float('inf') if element.bbox is None else element.bbox.x2
)
)
Metadata
Metadata
Assignees
Labels
No labels