Skip to content

Commit

Permalink
Add IndexError to catch expression when calculating transcription con…
Browse files Browse the repository at this point in the history
…fidence -- in case when there are no logits (i.e. logits.shape[0] == 0) the confidence cannot be calculated.
  • Loading branch information
ikiss-fit committed Oct 25, 2024
1 parent fa1a897 commit f5f2f42
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion pero_ocr/document_ocr/page_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -587,7 +587,7 @@ def get_line_confidence(self, line):
log_probs = line.get_full_logprobs()[line.logit_coords[0]:line.logit_coords[1]]
confidences = get_line_confidence(line, log_probs=log_probs)
return np.quantile(confidences, .50)
except ValueError as e:
except (ValueError, IndexError) as e:
logger.warning(f'PageOCR is unable to get confidence of line {line.id} due to exception: {e}.')
return self.default_confidence
return self.default_confidence
Expand Down

0 comments on commit f5f2f42

Please sign in to comment.