OCR-D / ocrd_all

Master repository which includes most other OCR-D repositories as submodules
MIT License
72 stars 17 forks source link

update 2021-05-19 #256

Closed kba closed 3 years ago

kba commented 3 years ago

Build fails because of a Keras/Tensorflow incompatibility:

Traceback (most recent call last):
  File "/usr/local/sub-venv/headless-tf21/bin/ocrd-anybaseocr-block-segmentation", line 5, in <module>
    from ocrd_anybaseocr.cli.ocrd_anybaseocr_block_segmentation import cli
  File "/usr/local/sub-venv/headless-tf21/lib/python3.6/site-packages/ocrd_anybaseocr/cli/ocrd_anybaseocr_block_segmentation.py", line 37, in <module>
    from ..mrcnn import model
  File "/usr/local/sub-venv/headless-tf21/lib/python3.6/site-packages/ocrd_anybaseocr/mrcnn/model.py", line 24, in <module>
    import keras.backend as K
  File "/usr/local/sub-venv/headless-tf21/lib/python3.6/site-packages/keras/__init__.py", line 3, in <module>
    from . import utils
  File "/usr/local/sub-venv/headless-tf21/lib/python3.6/site-packages/keras/utils/__init__.py", line 26, in <module>
    from .vis_utils import model_to_dot
  File "/usr/local/sub-venv/headless-tf21/lib/python3.6/site-packages/keras/utils/vis_utils.py", line 7, in <module>
    from ..models import Model
  File "/usr/local/sub-venv/headless-tf21/lib/python3.6/site-packages/keras/models.py", line 10, in <module>
    from .engine.input_layer import Input
  File "/usr/local/sub-venv/headless-tf21/lib/python3.6/site-packages/keras/engine/__init__.py", line 3, in <module>
    from .input_layer import Input
  File "/usr/local/sub-venv/headless-tf21/lib/python3.6/site-packages/keras/engine/input_layer.py", line 7, in <module>
    from .base_layer import Layer
  File "/usr/local/sub-venv/headless-tf21/lib/python3.6/site-packages/keras/engine/base_layer.py", line 12, in <module>
    from .. import initializers
  File "/usr/local/sub-venv/headless-tf21/lib/python3.6/site-packages/keras/initializers/__init__.py", line 124, in <module>
    populate_deserializable_objects()
  File "/usr/local/sub-venv/headless-tf21/lib/python3.6/site-packages/keras/initializers/__init__.py", line 49, in populate_deserializable_objects
    LOCAL.GENERATED_WITH_V2 = tf.__internal__.tf2.enabled()
AttributeError: module 'tensorflow_core.compat.v2' has no attribute '__internal__'

@bertsky @mikegerber Any ideas on what the problem might be?

bertsky commented 3 years ago

Any ideas on what the problem might be?

The problem is in ocrd-anybaseocr-tiseg: it uses Keras but import it directly instead of from Tensorflow. This is not allowed anymore in TF2. The other Keras processors in that module use from ..tensorflow_importer import tf, keras – that should work here, too.

kba commented 3 years ago

Any ideas on what the problem might be?

The problem is in ocrd-anybaseocr-tiseg: it uses Keras but import it directly instead of from Tensorflow. This is not allowed anymore in TF2. The other Keras processors in that module use from ..tensorflow_importer import tf, keras – that should work here, too.

Thanks, I will try to adapt tiseg.

bertsky commented 3 years ago

The problem is in ocrd-anybaseocr-tiseg: it uses Keras but import it directly instead of from Tensorflow. This is not allowed anymore in TF2. The other Keras processors in that module use from ..tensorflow_importer import tf, keras – that should work here, too.

Strange that I did not see this when attempting to fix tiseg et al (including dependencies) in https://github.com/OCR-D/ocrd_anybaseocr/pull/79. @kba feel free to add it to that PR and merge, or create a new one independently just fixing that one issue.