Skip to content

Commit

Permalink
Fix bug in word segmentation
Browse files Browse the repository at this point in the history
  • Loading branch information
viklofg committed Apr 18, 2024
1 parent 21cf613 commit 19cbd4e
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/htrflow_core/dummies/dummy_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ def randommask(h: int, w: int) -> np.ndarray:


def simple_word_segmentation(nodes) -> list[Result]:
return [_simple_word_segmentation(node.image, node.text, node.mask) for node in nodes]
return [_simple_word_segmentation(node.image, node.text, node.get("segment").mask) for node in nodes]


def _simple_word_segmentation(image, text, mask=None):
Expand All @@ -108,7 +108,7 @@ def _simple_word_segmentation(image, text, mask=None):
bboxes.append((x1, 0, x2, height))
x1 = x2 + int(pixels_per_char * 0.2) # add a "whitespace"

if mask:
if mask is not None:
segments = [Segment(bbox=bbox, mask=crop(mask, bbox), class_label="word") for bbox in bboxes]
else:
segments = [Segment(bbox=bbox, class_label="word") for bbox in bboxes]
Expand Down

0 comments on commit 19cbd4e

Please sign in to comment.