Skip to content

Update detectron2onnx.py #421

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
6 changes: 3 additions & 3 deletions unstructured_inference/models/detectron2onnx.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
from PIL import Image

from unstructured_inference.constants import Source
from unstructured_inference.inference.layoutelement import LayoutElement
from unstructured_inference.inference.layoutelement import LayoutElement, LayoutElements
from unstructured_inference.logger import logger, logger_onnx
from unstructured_inference.models.unstructuredmodel import (
UnstructuredObjectDetectionModel,
Expand Down Expand Up @@ -88,7 +88,7 @@ def predict(self, image: Image.Image) -> List[LayoutElement]:
logger_onnx.debug(
"Ignoring runtime error from onnx (likely due to encountering blank page).",
)
return []
return LayoutElements.from_list([])
input_w, input_h = image.size
regions = self.postprocess(bboxes, labels, confidence_scores, input_w, input_h)

Expand Down Expand Up @@ -174,4 +174,4 @@ def postprocess(
regions.append(region)

regions.sort(key=lambda element: element.bbox.y1)
return cast(List[LayoutElement], regions)
return LayoutElements.from_list(cast(List[LayoutElement], regions))