OCR-D / ocrd_anybaseocr

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

tiseg: weights model not found even though it exists #65

Closed ghost closed 4 years ago

ghost commented 4 years ago
(d2) home@home-lnx:~/programs/ocrd_anybaseocr$ ocrd-anybaseocr-tiseg -m ./data/mets.xml -I OCR-D-PAGE-CROP -O OCR-D-PAGE-TISEG -p ./models/seg_model.hdf5
Using TensorFlow backend.
2020-08-04 16:20:51.720748: W tensorflow/stream_executor/platform/default/dso_loader.cc:55] Could not load dynamic library 'libnvinfer.so.6'; dlerror: libnvinfer.so.6: cannot open shared object file: No such file or directory
2020-08-04 16:20:51.720804: W tensorflow/stream_executor/platform/default/dso_loader.cc:55] Could not load dynamic library 'libnvinfer_plugin.so.6'; dlerror: libnvinfer_plugin.so.6: cannot open shared object file: No such file or directory
2020-08-04 16:20:51.720811: W tensorflow/compiler/tf2tensorrt/utils/py_utils.cc:30] Cannot dlopen some TensorRT libraries. If you would like to use Nvidia GPU with TensorRT, please make sure the missing libraries mentioned above are installed properly.
Traceback (most recent call last):
  File "/home/home/anaconda3/envs/d2/bin/ocrd-anybaseocr-tiseg", line 8, in <module>
    sys.exit(cli())
  File "/home/home/anaconda3/envs/d2/lib/python3.6/site-packages/click/core.py", line 829, in __call__
    return self.main(*args, **kwargs)
  File "/home/home/anaconda3/envs/d2/lib/python3.6/site-packages/click/core.py", line 781, in main
    with self.make_context(prog_name, args, **extra) as ctx:
  File "/home/home/anaconda3/envs/d2/lib/python3.6/site-packages/click/core.py", line 700, in make_context
    self.parse_args(ctx, args)
  File "/home/home/anaconda3/envs/d2/lib/python3.6/site-packages/click/core.py", line 1048, in parse_args
    value, args = param.handle_parse_result(ctx, opts, args)
  File "/home/home/anaconda3/envs/d2/lib/python3.6/site-packages/click/core.py", line 1630, in handle_parse_result
    value = invoke_param_callback(self.callback, ctx, self, value)
  File "/home/home/anaconda3/envs/d2/lib/python3.6/site-packages/click/core.py", line 123, in invoke_param_callback
    return callback(ctx, param, value)
  File "/home/home/anaconda3/envs/d2/lib/python3.6/site-packages/ocrd/decorators.py", line 28, in _handle_param_option
    return parse_json_string_or_file(*list(value))
  File "/home/home/anaconda3/envs/d2/lib/python3.6/site-packages/ocrd_utils/str.py", line 151, in parse_json_string_or_file
    value_parsed = parse_json_string_with_comments(f.read())
  File "/home/home/anaconda3/envs/d2/lib/python3.6/codecs.py", line 321, in decode
    (result, consumed) = self._buffer_decode(data, self.errors, final)
UnicodeDecodeError: 'utf-8' codec can't decode byte 0x89 in position 0: invalid start byte
kba commented 4 years ago

Invocation should be

home@home-lnx:~/programs/ocrd_anybaseocr$ ocrd-anybaseocr-tiseg -m ./data/mets.xml -I OCR-D-PAGE-CROP -O OCR-D-PAGE-TISEG -P seg_weights models/seg_model.hdf5

(replace -p models/seg_model.hdf5 by -P seg_weights models/seg_model.hdf5)

Or, since the default value for seg_weights is models/seg_model.hdf5, just

home@home-lnx:~/programs/ocrd_anybaseocr$ ocrd-anybaseocr-tiseg -m ./data/mets.xml -I OCR-D-PAGE-CROP -O OCR-D-PAGE-TISEG
ghost commented 4 years ago

@kba Nope, re-open this issue i keep finding some weird bugs in this project, it's either this repo dependencies need re-checking, or the code needs re-testing. Further details of how i am testing are here.

(ocrd) home@home-lnx:~/programs/ocrd_anybaseocr$ ocrd-anybaseocr-tiseg -m ./data/mets.xml -I OCR-D-PAGE-CROP -O OCR-D-PAGE-TISEG -P seg_weights ./models/seg_model.hdf5
Using TensorFlow backend.
2020-08-04 17:59:51.096741: W tensorflow/stream_executor/platform/default/dso_loader.cc:55] Could not load dynamic library 'libnvinfer.so.6'; dlerror: libnvinfer.so.6: cannot open shared object file: No such file or directory
2020-08-04 17:59:51.096800: W tensorflow/stream_executor/platform/default/dso_loader.cc:55] Could not load dynamic library 'libnvinfer_plugin.so.6'; dlerror: libnvinfer_plugin.so.6: cannot open shared object file: No such file or directory
2020-08-04 17:59:51.096811: W tensorflow/compiler/tf2tensorrt/utils/py_utils.cc:30] Cannot dlopen some TensorRT libraries. If you would like to use Nvidia GPU with TensorRT, please make sure the missing libraries mentioned above are installed properly.
17:59:51.681 INFO OcrdAnybaseocrTiseg - No output file group for images specified, falling back to 'OCR-D-IMG-TISEG'
17:59:51.682 ERROR OcrdAnybaseocrTiseg -                     Segementation model weights file was not found at './models/seg_model.hdf5'. Make sure the `seg_weights` parameter
                    points to the local model weights path.              
kba commented 4 years ago

Segementation model weights file was not found at './models/seg_model.hdf5'

Is the model at this location?

ghost commented 4 years ago
home@home-lnx:~/programs/ocrd_anybaseocr/models$ tree
.
├── latest_net_G.pth
└── seg_model.hdf5

0 directories, 2 files
ghost commented 4 years ago
home@home-lnx:~/programs/ocrd_anybaseocr$ tree -d
.
├── data
│   ├── OCR-D-GT-SEG-BLOCK
│   ├── OCR-D-GT-SEG-LINE
│   ├── OCR-D-GT-SEG-PAGE
│   ├── OCR-D-IMG
│   ├── OCR-D-IMG-BIN
│   ├── OCR-D-IMG-CROP
│   ├── OCR-D-IMG-DESKEW
│   ├── OCR-D-PAGE-BIN
│   ├── OCR-D-PAGE-CROP
│   └── OCR-D-PAGE-DESKEW
├── models
├── ocrd_anybaseocr
│   ├── cli
│   ├── models
│   ├── mrcnn
│   └── pix2pixhd
│       ├── data
│       ├── datasets
│       │   └── cityscapes
│       │       ├── test_inst
│       │       ├── test_label
│       │       ├── train_img
│       │       ├── train_inst
│       │       └── train_label
│       ├── imgs
│       ├── models
│       ├── options
│       ├── scripts
│       └── util
└── tests

31 directories
ghost commented 4 years ago

.

kba commented 4 years ago

@deepseek can you try again with the latest release? The tiseg test call succeeds so it is probably an issue, where the code is changing directories somewhere - can you try with an absolute path to the model? If that fixes the problem, I can dig into the code to see where os.getcwd() changes.

ghost commented 4 years ago

sure, let me have a look

ghost commented 4 years ago

i tested in a new environment with latest master. Both issues that i opened are still not solved.

You have done a great job in creating this project along with your contributions to the open-source community, thank you. and i am sure that you can solve these issues. kindly, leave this issue closed, i am just passing by.