Skip to content

Commit

Permalink
don't die if box is None in try_draw_boxes (#1060)
Browse files Browse the repository at this point in the history
* don't die if box is None in try_draw_boxes

Signed-off-by: Henry Lindeman <[email protected]>

* fix ruff

Signed-off-by: Henry Lindeman <[email protected]>

---------

Signed-off-by: Henry Lindeman <[email protected]>
  • Loading branch information
HenryL27 authored Dec 5, 2024
1 parent d2beb55 commit 86b6ed1
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion lib/sycamore/sycamore/utils/image_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from packaging.version import InvalidVersion, Version
from pathlib import Path
from typing import Any, Callable, Optional, TypeVar, Union
import logging
import PIL
from PIL import Image, ImageDraw, ImageFont
from sycamore.data import Document
Expand Down Expand Up @@ -198,7 +199,11 @@ def try_draw_boxes(
font = ImageFont.load_default()

for i, box in enumerate(boxes):
raw_coords = coord_fn(box)
try:
raw_coords = coord_fn(box)
except Exception:
logging.warn(f"Could not extract bbox coords from {box}")
continue

# If the coordinates are all less than or equal to 1.0, then we treat them
# as relative coordinates, and we convert them to absolute coordinates.
Expand Down

0 comments on commit 86b6ed1

Please sign in to comment.