diff --git a/dan/ocr/predict/attention.py b/dan/ocr/predict/attention.py index 07b8c5cca0cd30cda844c9313eba2e37a8ae2e07..6d94a4d462d686a2e2adcbdf42c67da1fbbc3159 100644 --- a/dan/ocr/predict/attention.py +++ b/dan/ocr/predict/attention.py @@ -44,7 +44,8 @@ def compute_offsets_by_level(full_text: str, level: Level, text_list: List[str]) """ # offsets[idx] = number of characters between text_list[idx-1] and text_list[idx] offsets = [int(level != Level.Char)] * (len(text_list) - 1) - if level == Level.NER: + # Take entities into account if there are any + if level == Level.NER and text_list: # Start after the first entity cursor = len(text_list[0]) for idx, split in enumerate(text_list[1:]):