tomassosorio / OCR_tablenet

TableNet Implementation on Pytorch
144 stars 45 forks source link

Error: invalid load key, '<' #1

Closed SanchiMittal closed 3 years ago

SanchiMittal commented 3 years ago

I am using Google Colab. Upon running python predict.py, I am getting the following error:

Traceback (most recent call last):
  File "predict.py", line 142, in <module>
    predict()
  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 "predict.py", line 135, in predict
    pred = Predict(model_weights, transforms)
  File "predict.py", line 38, in __init__
    self.model = TableNetModule.load_from_checkpoint(checkpoint_path)
  File "/usr/local/lib/python3.6/dist-packages/pytorch_lightning/core/saving.py", line 137, in load_from_checkpoint
    checkpoint = pl_load(checkpoint_path, map_location=lambda storage, loc: storage)
  File "/usr/local/lib/python3.6/dist-packages/pytorch_lightning/utilities/cloud_io.py", line 32, in load
    return torch.load(f, map_location=map_location)
  File "/usr/local/lib/python3.6/dist-packages/torch/serialization.py", line 595, in load
    return _legacy_load(opened_file, map_location, pickle_module, **pickle_load_args)
  File "/usr/local/lib/python3.6/dist-packages/torch/serialization.py", line 764, in _legacy_load
    magic_number = pickle_module.load(f, **pickle_load_args)
_pickle.UnpicklingError: invalid load key, '<'.

Also, I am unable to install many dependencies in the requirements.txt file using pip 21.0.1 For eg. numpy 1.20.0 is not available.

tomassosorio commented 3 years ago

Hi @SanchiMittal,

This code is based on python 3.8 version, so you should check that out regarding the dependencies that you were unable to install.

Regarding the other error, you should download the weights that are on google drive, the link is on ReadMe.

For running the prediction, you should run the following command:

python predict.py --model_weights='./data/best_model.ckpt' --image_path='./data/Marmot_data/10.1.1.1.2006_3.bmp'

By the way, the prediction code is not very computationally intensive, so you might try running locally.