Skip to content

Inference not running without entities

Inference does not work properly when there are no entities because of parse_tokens_pattern:

  File "/app/venv/lib/python3.10/site-packages/dan/ocr/predict/inference.py", line 516, in run
    process_batch(
  File "/app/venv/lib/python3.10/site-packages/dan/ocr/predict/inference.py", line 368, in process_batch
    ner_separators = parse_tokens_pattern(tokens.values())
AttributeError: 'NoneType' object has no attribute 'values'

Replacing this line with ner_separators = parse_tokens_pattern(tokens.values()) if tokens.values() else None should fix the bug (this is how it's done in the tests).