diff --git a/kraken/serialization.py b/kraken/serialization.py index f4fd4432d..e374eeafb 100644 --- a/kraken/serialization.py +++ b/kraken/serialization.py @@ -165,8 +165,8 @@ def serialize(results: 'Segmentation', # addition to bounding boxes line = {'id': record.id, 'bbox': max_bbox([record.boundary]) if record.type == 'baselines' else record.bbox, - 'cuts': [list(x) for x in record.cuts], - 'confidences': record.confidences, + 'cuts': [list(x) for x in getattr(record, 'cuts', [])], + 'confidences': getattr(record, 'confidences', []), 'recognition': [], 'boundary': [list(x) for x in record.boundary] if record.type == 'baselines' else [[record.bbox[0], record.bbox[1]], [record.bbox[2], record.bbox[1]], @@ -179,7 +179,7 @@ def serialize(results: 'Segmentation', if record.type == 'baselines': line['baseline'] = [list(x) for x in record.baseline] - splits = regex.split(r'(\s+)', record.prediction) + splits = regex.split(r'(\s+)', getattr(record, 'prediction', '')) line_offset = 0 logger.debug(f'Record contains {len(splits)} segments') for segment in splits: