Jingkang50 / OpenPSG

Benchmarking Panoptic Scene Graph Generation (PSG), ECCV'22
https://psgdataset.org
MIT License
407 stars 68 forks source link

Getting invalid load key error #72

Closed Chandu-4444 closed 1 year ago

Chandu-4444 commented 1 year ago
load checkpoint from local path: epoch_60.pth
---------------------------------------------------------------------------
UnpicklingError                           Traceback (most recent call last)
/tmp/ipykernel_9716/343802214.py in <module>
    442 model_ckt = "epoch_60.pth"
    443 cfg = Config.fromfile("configs/psgtr/psgtr_r50_psg_inference.py")
--> 444 model = init_detector(cfg, model_ckt, device="gpu")
    445 
    446 image = "messi.jpg"

~/openpsg_env/lib/python3.7/site-packages/mmdet/apis/inference.py in init_detector(config, checkpoint, device, cfg_options)
     40     model = build_detector(config.model, test_cfg=config.get('test_cfg'))
     41     if checkpoint is not None:
---> 42         checkpoint = load_checkpoint(model, checkpoint, map_location='cpu')
     43         if 'CLASSES' in checkpoint.get('meta', {}):
     44             model.CLASSES = checkpoint['meta']['CLASSES']

~/openpsg_env/lib/python3.7/site-packages/mmcv/runner/checkpoint.py in load_checkpoint(model, filename, map_location, strict, logger, revise_keys)
    540         dict or OrderedDict: The loaded checkpoint.
    541     """
--> 542     checkpoint = _load_checkpoint(filename, map_location, logger)
    543     # OrderedDict is a subclass of dict
    544     if not isinstance(checkpoint, dict):

~/openpsg_env/lib/python3.7/site-packages/mmcv/runner/checkpoint.py in _load_checkpoint(filename, map_location, logger)
    479            information, which depends on the checkpoint.
    480     """
--> 481     return CheckpointLoader.load_checkpoint(filename, map_location, logger)
    482 
    483 

~/openpsg_env/lib/python3.7/site-packages/mmcv/runner/checkpoint.py in load_checkpoint(cls, filename, map_location, logger)
    249         mmcv.print_log(
    250             f'load checkpoint from {class_name[10:]} path: {filename}', logger)
--> 251         return checkpoint_loader(filename, map_location)
    252 
    253 

~/openpsg_env/lib/python3.7/site-packages/mmcv/runner/checkpoint.py in load_from_local(filename, map_location)
    266     if not osp.isfile(filename):
    267         raise FileNotFoundError(f'{filename} can not be found.')
--> 268     checkpoint = torch.load(filename, map_location=map_location)
    269     return checkpoint
    270 

~/openpsg_env/lib/python3.7/site-packages/torch/serialization.py in load(f, map_location, pickle_module, **pickle_load_args)
    593                     return torch.jit.load(opened_file)
    594                 return _load(opened_zipfile, map_location, pickle_module, **pickle_load_args)
--> 595         return _legacy_load(opened_file, map_location, pickle_module, **pickle_load_args)
    596 
    597 

~/openpsg_env/lib/python3.7/site-packages/torch/serialization.py in _legacy_load(f, map_location, pickle_module, **pickle_load_args)
    762             "functionality.")
    763 
--> 764     magic_number = pickle_module.load(f, **pickle_load_args)
    765     if magic_number != MAGIC_NUMBER:
    766         raise RuntimeError("Invalid magic number; corrupt file?")

UnpicklingError: invalid load key, 'v'.
Chandu-4444 commented 1 year ago

Solved: Tried using corrupted .pth file.