lufficc / SSD

High quality, fast, modular reference implementation of SSD in PyTorch
MIT License
1.52k stars 384 forks source link

Can not load pretrained model in demo.py #165

Closed priteshgohil closed 4 years ago

priteshgohil commented 4 years ago

Hi, I have an error in loading saved weight file in demo.py. To reproduce the error, I tried to load the weight file in terminal directly and it gives exactly the same error.

>>> torch.load("outputs/test_validation_loss_logging/model_001650.pth", map_location="cpu")
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/pgohil2s/anaconda3/envs/pytorch-ssd-lfc/lib/python3.7/site-packages/torch/serialization.py", line 577, in load
    with _open_zipfile_reader(opened_file) as opened_zipfile:
  File "/home/pgohil2s/anaconda3/envs/pytorch-ssd-lfc/lib/python3.7/site-packages/torch/serialization.py", line 241, in __init__
    super(_open_zipfile_reader, self).__init__(torch._C.PyTorchFileReader(name_or_buffer))
RuntimeError: [enforce fail at inline_container.cc:144] . PytorchStreamReader failed reading zip archive: failed finding central directory

I know it is dependent on the project folder structure but I'm trying to load it inside the project folders

priteshgohil commented 4 years ago

See the recommended solution: https://github.com/pytorch/pytorch/issues/31620#issuecomment-600591415

But still not working.

priteshgohil commented 4 years ago

Ok, I'm able to load the model. The problem was with the saved weight file. It wasn't saved properly and the weight file size was smaller (only 90 MB instead of 200 MB).