Skip to content

Commit

Permalink
Explicitly set empty lines/regions on Segmentation class
Browse files Browse the repository at this point in the history
  • Loading branch information
mittagessen committed Nov 21, 2023
1 parent e9a699c commit afd39d7
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion kraken/containers.py
Original file line number Diff line number Diff line change
Expand Up @@ -164,9 +164,13 @@ class Segmentation:
line_orders: Optional[List[List[int]]] = None

def __post_init__(self):
if not self.regions:
self.regions = {}
if not self.lines:
self.lines = []
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]
sel.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():
Expand Down

0 comments on commit afd39d7

Please sign in to comment.