qurator-spk / sbb_textline_detection

Detect textlines in document images
Apache License 2.0
88 stars 18 forks source link

h5py==3.0.0 causes issues with keras model #50

Closed JKamlah closed 3 years ago

JKamlah commented 3 years ago

It seems that the current version of h5py (3.0.0) causes issues, see: https://github.com/tensorflow/tensorflow/issues/44467 . A workaround, till an official fix is released, could be to specify h5py (e.g., ==2.10) in the requirements files. This problem also affects: https://github.com/qurator-spk/sbb_binarization

mikegerber commented 3 years ago

I have encountered the same problem:

13:07:05.240 INFO processor.OcrdSbbTextlineDetectorRecognize - INPUT FILE 0 / <OcrdFile fileGrp=OCR-D-IMG-BIN, ID=OCR-D-IMG-BIN_00000024, mimetype=application/vnd.prima.page+xml, url=OCR-D-IMG-BIN/OCR-D-IMG-BIN_00000024.xml, local_filename=OCR-D-IMG-BIN/OCR-D-IMG-BIN_00000024.xml]/> 
Traceback (most recent call last):
  File "/usr/local/bin/ocrd-sbb-textline-detector", line 8, in <module>
    sys.exit(ocrd_sbb_textline_detector())
  File "/usr/local/lib/python3.6/dist-packages/click/core.py", line 829, in __call__
    return self.main(*args, **kwargs)
  File "/usr/local/lib/python3.6/dist-packages/click/core.py", line 782, in main
    rv = self.invoke(ctx)
  File "/usr/local/lib/python3.6/dist-packages/click/core.py", line 1066, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/usr/local/lib/python3.6/dist-packages/click/core.py", line 610, in invoke
    return callback(*args, **kwargs)
  File "/usr/local/lib/python3.6/dist-packages/qurator/sbb_textline_detector/ocrd_cli.py", line 32, in ocrd_sbb_textline_detector
    return ocrd_cli_wrap_processor(OcrdSbbTextlineDetectorRecognize, *args, **kwargs)
  File "/usr/local/lib/python3.6/dist-packages/ocrd/decorators/__init__.py", line 81, in ocrd_cli_wrap_processor
    run_processor(processorClass, ocrd_tool, mets, workspace=workspace, **kwargs)
  File "/usr/local/lib/python3.6/dist-packages/ocrd/processor/helpers.py", line 69, in run_processor
    processor.process()
  File "/usr/local/lib/python3.6/dist-packages/qurator/sbb_textline_detector/ocrd_cli.py", line 78, in process
    x.run()
  File "/usr/local/lib/python3.6/dist-packages/qurator/sbb_textline_detector/main.py", line 2061, in run
    image_page,page_coord=self.extract_page()
  File "/usr/local/lib/python3.6/dist-packages/qurator/sbb_textline_detector/main.py", line 386, in extract_page
    model_page, session_page = self.start_new_session_and_model(self.model_page_dir)
  File "/usr/local/lib/python3.6/dist-packages/qurator/sbb_textline_detector/main.py", line 221, in start_new_session_and_model
    model = load_model(model_dir, compile=False)
  File "/usr/local/lib/python3.6/dist-packages/keras/engine/saving.py", line 492, in load_wrapper
    return load_function(*args, **kwargs)
  File "/usr/local/lib/python3.6/dist-packages/keras/engine/saving.py", line 584, in load_model
    model = _deserialize_model(h5dict, custom_objects, compile)
  File "/usr/local/lib/python3.6/dist-packages/keras/engine/saving.py", line 273, in _deserialize_model
    model_config = json.loads(model_config.decode('utf-8'))
AttributeError: 'str' object has no attribute 'decode'

Downgrading to h5py < 3 solves this.

mikegerber commented 3 years ago

https://github.com/qurator-spk/ocrd-galley/commit/2c7304caec6d10ae761134ee30c6c9da0918b237

kba commented 3 years ago

This has been fixed in current master by #51