clovaai / deep-text-recognition-benchmark

Text recognition (optical character recognition) with deep learning methods, ICCV 2019
Apache License 2.0
3.72k stars 1.09k forks source link

UnpicklingError: invalid load key, '<' #357

Open siddika6300 opened 2 years ago

siddika6300 commented 2 years ago
!CUDA_VISIBLE_DEVICES=0 python3 demo.py \
--Transformation TPS --FeatureExtraction ResNet --SequenceModeling BiLSTM --Prediction Attn \
--image_folder demo_image/ --saved_model TPS-ResNet-BiLSTM-Attn.pth

The above cell produces this error.

model input parameters 32 100 20 1 512 256 38 25 TPS ResNet BiLSTM Attn
loading pretrained model from TPS-ResNet-BiLSTM-Attn.pth
Traceback (most recent call last):
  File "demo.py", line 129, in <module>
    demo(opt)
  File "demo.py", line 33, in demo
    model.load_state_dict(torch.load(opt.saved_model, map_location=device))
  File "/usr/local/lib/python3.7/dist-packages/torch/serialization.py", line 713, in load
    return _legacy_load(opened_file, map_location, pickle_module, **pickle_load_args)
  File "/usr/local/lib/python3.7/dist-packages/torch/serialization.py", line 920, in _legacy_load
    magic_number = pickle_module.load(f, **pickle_load_args)
_pickle.UnpicklingError: invalid load key, '<'.

I also tried loading the model using PyTorch

import torch
torch.load('TPS-ResNet-BiLSTM-Attn-case-sensitive.pth')
UnpicklingError                           Traceback (most recent call last)
[<ipython-input-15-8dce171dbc4c>](https://localhost:8080/#) in <module>
      1 import torch
----> 2 torch.load('TPS-ResNet-BiLSTM-Attn-case-sensitive.pth')

1 frames
[/usr/local/lib/python3.7/dist-packages/torch/serialization.py](https://localhost:8080/#) in _legacy_load(f, map_location, pickle_module, **pickle_load_args)
    918             "functionality.")
    919 
--> 920     magic_number = pickle_module.load(f, **pickle_load_args)
    921     if magic_number != MAGIC_NUMBER:
    922         raise RuntimeError("Invalid magic number; corrupt file?")

UnpicklingError: invalid load key, '<'.

it seems like the model files have been curropted

temiwale88 commented 1 year ago

Looks like you need to access the model weights through Google Drive yourself and download it into the expected (root) folder. It could take a while depending on your internet connection. The code to download the models ('deep-text-recognition-benchmark.ipynb') isn't sufficient somehow. Just download the models yourself. If that's not your use case, re-download it again and make sure it has fully been downloaded to your directory.