OCR-D / ocrd_anybaseocr

DFKI Layout Detection for OCR-D
Apache License 2.0
48 stars 12 forks source link

`ocrd-anybaseocr-block-segmentation --help` fails #57

Closed stweil closed 4 years ago

stweil commented 4 years ago

Command output:

% ocrd-anybaseocr-block-segmentation --help
Using TensorFlow backend.
17:59:25.728 WARNING tensorflow - From /OCR-D/venv-20200509/lib/python3.7/site-packages/tensorflow/python/compat/v2_compat.py:96: disable_resource_variables (from tensorflow.python.ops.variable_scope) is deprecated and will be removed in a future version.
Instructions for updating:
non-resource variables are not supported in the long term
Traceback (most recent call last):
  File "/OCR-D/venv-20200509/bin/ocrd-anybaseocr-block-segmentation", line 8, in <module>
    sys.exit(ocrd_anybaseocr_block_segmentation())
  File "/OCR-D/venv-20200509/lib/python3.7/site-packages/click/core.py", line 829, in __call__
    return self.main(*args, **kwargs)
  File "/OCR-D/venv-20200509/lib/python3.7/site-packages/click/core.py", line 782, in main
    rv = self.invoke(ctx)
  File "/OCR-D/venv-20200509/lib/python3.7/site-packages/click/core.py", line 1066, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/OCR-D/venv-20200509/lib/python3.7/site-packages/click/core.py", line 610, in invoke
    return callback(*args, **kwargs)
  File "/OCR-D/venv-20200509/lib/python3.7/site-packages/ocrd_anybaseocr/cli/cli.py", line 54, in ocrd_anybaseocr_block_segmentation
    return ocrd_cli_wrap_processor(OcrdAnybaseocrBlockSegmenter, *args, **kwargs)
  File "/OCR-D/venv-20200509/lib/python3.7/site-packages/ocrd/decorators.py", line 35, in ocrd_cli_wrap_processor
    processorClass(workspace=None, show_help=True)
  File "/OCR-D/venv-20200509/lib/python3.7/site-packages/ocrd_anybaseocr/cli/ocrd_anybaseocr_block_segmentation.py", line 71, in __init__
    super(OcrdAnybaseocrBlockSegmenter, self).__init__(*args, **kwargs) 
  File "/OCR-D/venv-20200509/lib/python3.7/site-packages/ocrd/processor/base.py", line 185, in __init__
    self.show_help()
  File "/OCR-D/venv-20200509/lib/python3.7/site-packages/ocrd/processor/base.py", line 207, in show_help
    print(generate_processor_help(self.ocrd_tool))
  File "/OCR-D/venv-20200509/lib/python3.7/site-packages/ocrd/processor/base.py", line 121, in generate_processor_help
    param['description'],
KeyError: 'description'
stweil commented 4 years ago

All help outputs for the processors ocrd-anybaseocr-* show the first four lines with the TensorFlow related warnings. Loading TensorFlow also takes several seconds. That should not be needed for the help. Maybe TensorFlow can be loaded only when it is really used.

stweil commented 4 years ago

Notes for other repositories:

Other processors with a similar problem:

Other processors with different help problems:

kba commented 4 years ago

Likely that they are doing too much in the constructor which will always be invoked, even if just version, ocrd-tool.json or help is requested.

bertsky commented 4 years ago

Likely that they are doing too much in the constructor which will always be invoked, even if just version, ocrd-tool.json or help is requested.

The problem is with Tensorflow itself. The import time even used to be worse. The messages appear as soon as you import it. (And I think we all agree that imports should not be in member functions or conditionals.) I recommend this recipe against the misplaced messages.