From afd39d772d22f8421d911e5d21ed9983db19a7d9 Mon Sep 17 00:00:00 2001 From: Benjamin Kiessling Date: Tue, 21 Nov 2023 11:43:00 +0100 Subject: [PATCH] Explicitly set empty lines/regions on Segmentation class --- kraken/containers.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/kraken/containers.py b/kraken/containers.py index 445e66bc5..36c3b6721 100644 --- a/kraken/containers.py +++ b/kraken/containers.py @@ -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():