Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 0.3.2

* Allow extracting tables from higher level functions

## 0.3.1

* Pin protobuf version to avoid errors
Expand Down
2 changes: 1 addition & 1 deletion unstructured_inference/__version__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "0.3.1" # pragma: no cover
__version__ = "0.3.2" # pragma: no cover
15 changes: 12 additions & 3 deletions unstructured_inference/inference/layout.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ class PageLayout:
def __init__(
self,
number: int,
image: Image,
image: Image.Image,
layout: Optional[List[TextRegion]],
model: Optional[UnstructuredModel] = None,
ocr_strategy: str = "auto",
Expand Down Expand Up @@ -202,6 +202,7 @@ def process_data_with_model(
is_image: bool = False,
ocr_strategy: str = "auto",
fixed_layouts: Optional[List[Optional[List[TextRegion]]]] = None,
extract_tables: bool = False,
) -> DocumentLayout:
"""Processes pdf file in the form of a file handler (supporting a read method) into a
DocumentLayout by using a model identified by model_name."""
Expand All @@ -213,6 +214,7 @@ def process_data_with_model(
is_image=is_image,
ocr_strategy=ocr_strategy,
fixed_layouts=fixed_layouts,
extract_tables=extract_tables,
)

return layout
Expand All @@ -224,15 +226,22 @@ def process_file_with_model(
is_image: bool = False,
ocr_strategy: str = "auto",
fixed_layouts: Optional[List[Optional[List[TextRegion]]]] = None,
extract_tables: bool = False,
) -> DocumentLayout:
"""Processes pdf file with name filename into a DocumentLayout by using a model identified by
model_name."""
model = get_model(model_name)
layout = (
DocumentLayout.from_image_file(filename, model=model, ocr_strategy=ocr_strategy)
DocumentLayout.from_image_file(
filename, model=model, ocr_strategy=ocr_strategy, extract_tables=extract_tables
)
if is_image
else DocumentLayout.from_file(
filename, model=model, ocr_strategy=ocr_strategy, fixed_layouts=fixed_layouts
filename,
model=model,
ocr_strategy=ocr_strategy,
fixed_layouts=fixed_layouts,
extract_tables=extract_tables,
)
)
return layout
Expand Down