Skip to content

Commit

Permalink
Update layout.py
Browse files Browse the repository at this point in the history
  • Loading branch information
michal-hradis authored Nov 5, 2024
1 parent f5f2f42 commit 747e491
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions pero_ocr/core/layout.py
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ def to_altoxml_text(self, text_line, arabic_helper,
except (ValueError, IndexError, TypeError) as e:
logger.warning(f'Error: Alto export, unable to align line {self.id} due to exception: {e}.')

if logits is not None:
if logits is not None and logits.shape[0] > 0:
max_val = np.max(logits, axis=1)
logits = logits - max_val[:, np.newaxis]
probs = np.exp(logits)
Expand Down Expand Up @@ -1147,4 +1147,4 @@ def create_ocr_processing_element(id: str = "IdOcr",

def normalize_text(text: str) -> str:
"""Normalize text to ASCII characters. (e.g. Obrázek -> Obrazek)"""
return unicodedata.normalize('NFD', text).encode('ascii', 'ignore').decode('ascii')
return unicodedata.normalize('NFD', text).encode('ascii', 'ignore').decode('ascii')

0 comments on commit 747e491

Please sign in to comment.