question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

UnpicklingError: invalid load key, '<'.

See original GitHub issue

When running in the Colab Notebook : model = model_type.model(backbone=backbone(pretrained=True), num_classes=len(parser.class_map), **extra_args)

Getting the following error. Hope you may kindly suggest how to fix this!

load checkpoint from local path: checkpoints/vfnet/vfnet_r50_fpn_mstrain_2x_coco_20201027-7cc75bd2.pth
---------------------------------------------------------------------------
UnpicklingError                           Traceback (most recent call last)
[<ipython-input-10-696c7b7efa47>](https://localhost:8080/#) in <module>()
      1 # Instantiate the model
----> 2 model = model_type.model(backbone=backbone(pretrained=True), num_classes=len(parser.class_map), **extra_args)

7 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)
    775             "functionality.")
    776 
--> 777     magic_number = pickle_module.load(f, **pickle_load_args)
    778     if magic_number != MAGIC_NUMBER:
    779         raise RuntimeError("Invalid magic number; corrupt file?")

UnpicklingError: invalid load key, '<'.

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:7 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
dnthcommented, Jun 13, 2022

Hi @jlvahldiek we are in the process of fixing this on the IceVision repo.

If you’re in a hurry, here is a Colab notebook as a workaround to make VFNet work again.

https://colab.research.google.com/gist/dnth/aea556c86ee3ca2e812ceb5eb8968caa/getting_started_object_detection.ipynb

0reactions
dnthcommented, Aug 16, 2022

This still seems to be an issue.

I was running getting_started_object_detection.ipynb that I just got from git today.

load checkpoint from local path: checkpoints/vfnet/vfnet_r50_fpn_mstrain_2x_coco_20201027-7cc75bd2.pth
---------------------------------------------------------------------------
UnpicklingError                           Traceback (most recent call last)
Input In [29], in <cell line: 2>()
      1 # Instantiate the model
----> 2 model = model_type.model(backbone=backbone(pretrained=True), num_classes=len(parser.class_map), **extra_args)

File /usr/local/lib/python3.9/dist-packages/icevision/models/mmdet/common/bbox/single_stage/model.py:20, in model(backbone, num_classes, checkpoints_path, force_download, cfg_options)
     12 def model(
     13     backbone: MMDetBackboneConfig,
     14     num_classes: int,
   (...)
     17     cfg_options=None,
     18 ) -> nn.Module:
---> 20     return build_model(
     21         model_type="one_stage_detector_bbox",
     22         backbone=backbone,
     23         num_classes=num_classes,
     24         pretrained=backbone.pretrained,
     25         checkpoints_path=checkpoints_path,
     26         force_download=force_download,
     27         cfg_options=cfg_options,
     28     )

File /usr/local/lib/python3.9/dist-packages/icevision/models/mmdet/common/utils.py:79, in build_model(model_type, backbone, num_classes, pretrained, checkpoints_path, force_download, cfg_options)
     76 _model.init_weights()
     78 if pretrained and (weights_path is not None):
---> 79     load_checkpoint(_model, str(weights_path))
     81 _model.param_groups = MethodType(param_groups, _model)
     82 _model.cfg = cfg  # save the config in the model for convenience

File /usr/local/lib/python3.9/dist-packages/mmcv/runner/checkpoint.py:528, in load_checkpoint(model, filename, map_location, strict, logger, revise_keys)
    503 def load_checkpoint(model,
    504                     filename,
    505                     map_location=None,
    506                     strict=False,
    507                     logger=None,
    508                     revise_keys=[(r'^module\.', '')]):
    509     """Load checkpoint from a file or URI.
    510 
    511     Args:
   (...)
    526         dict or OrderedDict: The loaded checkpoint.
    527     """
--> 528     checkpoint = _load_checkpoint(filename, map_location, logger)
    529     # OrderedDict is a subclass of dict
    530     if not isinstance(checkpoint, dict):

File /usr/local/lib/python3.9/dist-packages/mmcv/runner/checkpoint.py:467, in _load_checkpoint(filename, map_location, logger)
    450 def _load_checkpoint(filename, map_location=None, logger=None):
    451     """Load checkpoint from somewhere (modelzoo, file, url).
    452 
    453     Args:
   (...)
    465            information, which depends on the checkpoint.
    466     """
--> 467     return CheckpointLoader.load_checkpoint(filename, map_location, logger)

File /usr/local/lib/python3.9/dist-packages/mmcv/runner/checkpoint.py:245, in CheckpointLoader.load_checkpoint(cls, filename, map_location, logger)
    242 class_name = checkpoint_loader.__name__
    243 mmcv.print_log(
    244     f'load checkpoint from {class_name[10:]} path: {filename}', logger)
--> 245 return checkpoint_loader(filename, map_location)

File /usr/local/lib/python3.9/dist-packages/mmcv/runner/checkpoint.py:262, in load_from_local(filename, map_location)
    260 if not osp.isfile(filename):
    261     raise IOError(f'{filename} is not a checkpoint file')
--> 262 checkpoint = torch.load(filename, map_location=map_location)
    263 return checkpoint

File /usr/local/lib/python3.9/dist-packages/torch/serialization.py:608, in load(f, map_location, pickle_module, **pickle_load_args)
    606             return torch.jit.load(opened_file)
    607         return _load(opened_zipfile, map_location, pickle_module, **pickle_load_args)
--> 608 return _legacy_load(opened_file, map_location, pickle_module, **pickle_load_args)

File /usr/local/lib/python3.9/dist-packages/torch/serialization.py:777, in _legacy_load(f, map_location, pickle_module, **pickle_load_args)
    771 if not hasattr(f, 'readinto') and (3, 8, 0) <= sys.version_info < (3, 8, 2):
    772     raise RuntimeError(
    773         "torch.load does not work with file-like objects that do not implement readinto on Python 3.8.0 and 3.8.1. "
    774         f"Received object of type \"{type(f)}\". Please update to Python 3.8.2 or newer to restore this "
    775         "functionality.")
--> 777 magic_number = pickle_module.load(f, **pickle_load_args)
    778 if magic_number != MAGIC_NUMBER:
    779     raise RuntimeError("Invalid magic number; corrupt file?")

UnpicklingError: invalid load key, '<'.


cat checkpoints/vfnet/vfnet_r50_fpn_mstrain_2x_coco_20201027-7cc75bd2.pth
<?xml version="1.0" encoding="UTF-8"?>
<Error>
  <Code>AccessDenied</Code>
  <Message>Access denied by bucket policy.</Message>
  <RequestId>62FAB855D4FE7D31395A743C</RequestId>
  <HostId>openmmlab.oss-cn-hangzhou.aliyuncs.com</HostId>
  <Bucket>openmmlab</Bucket>
  <User>nosuchuser</User>
</Error>

Which version of IceVision are you running on? Try installing IceVision from the master branch and see if this still happens.

Read more comments on GitHub >

github_iconTop Results From Across the Web

What causes the error "_pickle.UnpicklingError: invalid load ...
UnpicklingError : invalid load key, ''. ... I received a similar error while loading a pickled sklearn model. The problem was that the...
Read more >
_pickle.UnpicklingError: invalid load key, '<' · Issue #49 ...
Hi all! while running run_placesCNN_basic.py, this error comes up Traceback (most recent call last): File "run_placesCNN_basic.py", line 31, ...
Read more >
_pickle.UnpicklingError: invalid load key, '\x00' - Google Groups
I am using Similarity class to calculate similarity between two sets of documents, but get a pickle issue which I have no idea...
Read more >
(Solved) Running test_submission.py runs into _pickle ...
UnpicklingError : invalid load key, 'v'. This is the docker log: (venv) master@wx-87:~/PycharmProjects/justpaulsai$ docker run -it -v ...
Read more >
_pickle.unpicklingerror: invalid load key, 'v'. - You.com - You.com
I have deployed a ML model in Heroku. But i am getting application error. I am getting the below error from the logs....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found