在使用YOLOv5进行训练时,可能会出现_pickle.UnpicklingError: STACK_GLOBAL requires str 这样的错误,解决办法是,将数据集中的labels.cache文件删掉,如下图:

Transferred 500/506 items from yolov5m.pt
Scaled weight_decay = 0.0005
Optimizer groups: 86 .bias, 86 conv.weight, 83 other
Traceback (most recent call last):
  File "train.py", line 545, in <module>
    train(hyp, opt, device, tb_writer)
  File "train.py", line 189, in train
    dataloader, dataset = create_dataloader(train_path, imgsz, batch_size, gs, opt,
  File "/home/kevin_xie/yifeinfs/jianming_ge/code/shapan_alg/yolov5_fire_shapan/utils/datasets.py", line 63, in create_dataloader
    dataset = LoadImagesAndLabels(path, imgsz, batch_size,
  File "/home/kevin_xie/yifeinfs/jianming_ge/code/shapan_alg/yolov5_fire_shapan/utils/datasets.py", line 385, in __init__
    cache, exists = torch.load(cache_path), True  # load
  File "/home/kevin_xie/yifeinfs/jianming_ge/miniconda3/envs/py38_18/lib/python3.8/site-packages/torch/serialization.py", line 593, in load
    return _legacy_load(opened_file, map_location, pickle_module, **pickle_load_args)
  File "/home/kevin_xie/yifeinfs/jianming_ge/miniconda3/envs/py38_18/lib/python3.8/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
 

Logo

华为开发者空间,是为全球开发者打造的专属开发空间,汇聚了华为优质开发资源及工具,致力于让每一位开发者拥有一台云主机,基于华为根生态开发、创新。

更多推荐