Skip to content

Commit

Permalink
Improved dict-style region detection in Segmentation
Browse files Browse the repository at this point in the history
Current test would crash if the first type in region dictionary would
not contain any regions. Fixes #592
  • Loading branch information
mittagessen committed Apr 22, 2024
1 parent aca1779 commit 3982aee
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions kraken/containers.py
Original file line number Diff line number Diff line change
Expand Up @@ -194,11 +194,14 @@ def __post_init__(self):
if len(self.lines) and not isinstance(self.lines[0], BBoxLine) and not isinstance(self.lines[0], BaselineLine):
line_cls = BBoxLine if self.type == 'bbox' else BaselineLine
self.lines = [line_cls(**line) for line in self.lines]
if len(self.regions) and not isinstance(next(iter(self.regions.values()))[0], Region):
regs = {}
for k, v in self.regions.items():
regs[k] = [Region(**reg) for reg in v]
self.regions = regs
if len(self.regions):
for regs in self.regions.values():
if regs and not isinstance(regs[0], Region):
regs = {}
for k, v in self.regions.items():
regs[k] = [Region(**reg) for reg in v]
self.regions = regs
break


class ocr_record(ABC):
Expand Down

0 comments on commit 3982aee

Please sign in to comment.