OCR-D / ocrd_anybaseocr

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

"AttributeError" when running block segmentation #36

Closed wrznr closed 4 years ago

wrznr commented 4 years ago

Pls. help! I receive an AttributeError when trying to run the block segmentation with the models provided lately:

$ ocrd-anybaseocr-block-segmentation -I ORIGINAL -O DFKIBS,DFKIBS-IMG -m mets.xml -p '{"block_segmentation_model" : "/home/kmw/Documents/Work/OCR-D/models/DFKI", "block_segmentation_weights" : "/home/kmw/Documents/Work/OCR-D/models/DFKI/block_segmentation_weights.h5"}'
2020-01-22 12:02:41.627680: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library libnvinfer.so.6
2020-01-22 12:02:41.629185: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library libnvinfer_plugin.so.6
Using TensorFlow backend.
WARNING: Logging before flag parsing goes to stderr.
W0122 12:02:42.263696 139929988376384 deprecation.py:323] From /home/kmw/Documents/Work/OCR-D/env/lib/python3.6/site-packages/tensorflow_core/python/compat/v2_compat.py:88: 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
W0122 12:02:42.310657 139929988376384 deprecation.py:323] From /home/kmw/Documents/Work/OCR-D/env/lib/python3.6/site-packages/ocrd_anybaseocr/cli/ocrd_anybaseocr_block_segmentation.py:68: is_gpu_available (from tensorflow.python.framework.test_util) is deprecated and will be removed in a future version.
Instructions for updating:
Use `tf.config.list_physical_devices('GPU')` instead.
Traceback (most recent call last):
  File "/home/kmw/Documents/Work/OCR-D/env/bin/ocrd-anybaseocr-block-segmentation", line 8, in <module>
    sys.exit(ocrd_anybaseocr_block_segmentation())
  File "/home/kmw/Documents/Work/OCR-D/env/lib/python3.6/site-packages/click/core.py", line 764, in __call__
    return self.main(*args, **kwargs)
  File "/home/kmw/Documents/Work/OCR-D/env/lib/python3.6/site-packages/click/core.py", line 717, in main
    rv = self.invoke(ctx)
  File "/home/kmw/Documents/Work/OCR-D/env/lib/python3.6/site-packages/click/core.py", line 956, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/home/kmw/Documents/Work/OCR-D/env/lib/python3.6/site-packages/click/core.py", line 555, in invoke
    return callback(*args, **kwargs)
  File "/home/kmw/Documents/Work/OCR-D/env/lib/python3.6/site-packages/ocrd_anybaseocr/cli/cli.py", line 54, in ocrd_anybaseocr_block_segmentation
    return ocrd_cli_wrap_processor(OcrdAnybaseocrBlockSegmenter, *args, **kwargs)
  File "/home/kmw/Documents/Work/OCR-D/env/lib/python3.6/site-packages/ocrd/decorators.py", line 54, in ocrd_cli_wrap_processor
    run_processor(processorClass, ocrd_tool, mets, workspace=workspace, **kwargs)
  File "/home/kmw/Documents/Work/OCR-D/env/lib/python3.6/site-packages/ocrd/processor/base.py", line 56, in run_processor
    processor.process()
  File "/home/kmw/Documents/Work/OCR-D/env/lib/python3.6/site-packages/ocrd_anybaseocr/cli/ocrd_anybaseocr_block_segmentation.py", line 93, in process
    mrcnn_model = model.MaskRCNN(mode="inference", model_dir=str(model_path), config=config)
  File "/home/kmw/Documents/Work/OCR-D/env/lib/python3.6/site-packages/ocrd_anybaseocr/mrcnn/model.py", line 1841, in __init__
    self.keras_model = self.build(mode=mode, config=config)
  File "/home/kmw/Documents/Work/OCR-D/env/lib/python3.6/site-packages/ocrd_anybaseocr/mrcnn/model.py", line 1860, in build
    shape=[None, None, config.IMAGE_SHAPE[2]], name="input_image")
  File "/home/kmw/Documents/Work/OCR-D/env/lib/python3.6/site-packages/keras/engine/input_layer.py", line 178, in Input
    input_tensor=tensor)
  File "/home/kmw/Documents/Work/OCR-D/env/lib/python3.6/site-packages/keras/legacy/interfaces.py", line 91, in wrapper
    return func(*args, **kwargs)
  File "/home/kmw/Documents/Work/OCR-D/env/lib/python3.6/site-packages/keras/engine/input_layer.py", line 87, in __init__
    name=self.name)
  File "/home/kmw/Documents/Work/OCR-D/env/lib/python3.6/site-packages/keras/backend/tensorflow_backend.py", line 541, in placeholder
    x = tf.placeholder(dtype, shape=shape, name=name)
AttributeError: module 'tensorflow' has no attribute 'placeholder'
free(): invalid pointer
Aborted (core dumped)
kba commented 4 years ago

https://better-coding.com/solved-attributeerror-module-tensorflow-has-no-attribute-placeholder/ Needs migration for tensorflow >= 2.0

wrznr commented 4 years ago

How can that be? The software has tensorflow >= 2.0 as a requirement.

wrznr commented 4 years ago

A clean install (i.e. fresh virtual environment) did the trick for me.