在跑YOLOv7的官方代码时,出现了这个错误:_pickle.UnpicklingError: STACK_GLOBAL requires str

1问题描述

_pickle.UnpicklingError: STACK_GLOBAL requires str

具体描述如下图所示:

Transferred 39/440 items from yolov5s.pt
Scaled weight_decay = 0.0005
Optimizer groups: 75 .bias, 75 conv.weight, 72 other
Traceback (most recent call last):
  File "train.py", line 541, in 
    train(hyp, opt, device, tb_writer)
  File "train.py", line 192, in train
    image_weights=opt.image_weights, quad=opt.quad, prefix=colorstr('train: '))
  File "/home/zzk/project/yolov3-master/utils/datasets.py", line 76, in create_dataloader
    prefix=prefix)
  File "/home/zzk/project/yolov3-master/utils/datasets.py", line 389, in __init__
    cache, exists = torch.load(cache_path), True  # load
  File "/root/anaconda3/envs/pytorch19/lib/python3.7/site-packages/torch/serialization.py", line 593, in load
    return _legacy_load(opened_file, map_location, pickle_module, **pickle_load_args)
  File "/root/anaconda3/envs/pytorch19/lib/python3.7/site-packages/torch/serialization.py", line 762, in _legacy_load
    magic_number = pickle_module.load(f, **pickle_load_args)
_pickle.UnpicklingError: STACK_GLOBAL requires str

2具体原因:未知

3解决办法:

数据集labels文件中产生了.cache文件,需要先把这个文件删掉。(就是下图中的labels.cache文件)

在跑YOLOv7的官方代码时,出现了这个错误:_pickle.UnpicklingError: STACK_GLOBAL requires str_第1张图片

你可能感兴趣的:(Python入门知识,python)