UnpicklingError: STACK_GLOBAL requires str

username: monee_h.a
cooked: <p>I am getting the following error:<br>
UnpicklingError: STACK_GLOBAL requires str</p>
<p>Here is the full error:<br>
<div class="lightbox-wrapper"><a class="lightbox" href="https://discuss.pytorch.org/uploads/default/original/3X/b/3/b39f9a673a51014477f353ba9cdba56418e3ab0c.png" data-download-href="https://discuss.pytorch.org/uploads/default/b39f9a673a51014477f353ba9cdba56418e3ab0c" title="Screen Shot 2021-05-29 at 10.33.53 PM"><img src="https://discuss.pytorch.org/uploads/default/optimized/3X/b/3/b39f9a673a51014477f353ba9cdba56418e3ab0c_2_690x391.png" alt="Screen Shot 2021-05-29 at 10.33.53 PM" data-base62-sha1="pD1pKCTuv5RAilFYwAYz20maQOg" width="690" height="391" srcset="https://discuss.pytorch.org/uploads/default/optimized/3X/b/3/b39f9a673a51014477f353ba9cdba56418e3ab0c_2_690x391.png, https://discuss.pytorch.org/uploads/default/original/3X/b/3/b39f9a673a51014477f353ba9cdba56418e3ab0c.png 1.5x, https://discuss.pytorch.org/uploads/default/original/3X/b/3/b39f9a673a51014477f353ba9cdba56418e3ab0c.png 2x" data-dominant-color="F2F5F6"><div class="meta"><svg class="fa d-icon d-icon-far-image svg-icon" aria-hidden="true"><use href="#far-image"></use></svg><span class="filename">Screen Shot 2021-05-29 at 10.33.53 PM</span><span class="informations">1003×569 104 KB</span><svg class="fa d-icon d-icon-discourse-expand svg-icon" aria-hidden="true"><use href="#discourse-expand"></use></svg></div></a></div></p>
<p>I would appreciate your help.</p>

username: monee_h.a
cooked: <p>Here is my code I am trying to run:</p>
<p>if <strong>name</strong> == “<strong>main</strong>”:<br>
<span class="hashtag">#process</span> &amp; create the dataset files</p>
<pre><code>parser = argparse.ArgumentParser()

# system
parser.add_argument("--feature", type=str, default="glove")
#no use of user_type for now
parser.add_argument("--user_type", type=str, default="hate")
args = parser.parse_args()

egde_index_file = 'processed/data/edgesfinal.txt'
edge_feature_file = 'processed/data/combine_feat.npy'
dataset = RetweetDataset("",feature_type=args.feature)
print(dataset[0].num_nodes)
print(dataset[0])</code></pre>

username: ptrblck
cooked: <p>This error is raised by <code>pickle</code> internally, which seems to fail in loading the passed file.<br>
Could you give us some more information about the file type you are trying to load as well as how it was created?</p>

username: monee_h.a
cooked: <p>Thank you for your reply.</p>

username: Hezhexi2002
cooked: <p>I meet this problem too when I try to train on my custom data in PyTorch_YOLOv4,so how can I fix it?</p>

username: ptrblck
cooked: <p>I don’t know as there wasn’t a follow-up with the root cause or solution, so could you post a minimal and executable code snippet, which would raise the issue?</p>

username: Hezhexi2002
cooked: <p>Using CUDA device0 _CudaDeviceProperties(name=‘GeForce RTX 2060’, total_memory=6144MB)</p>
<p>Namespace(weights=‘weights/yolov4-tiny.weights’, cfg=‘cfg/yolov4-tiny.cfg’, data=’.\data\606.yaml’, hyp=‘data/hyp.scratch.yaml’, epochs=300, batch_size=16, img_size=[640, 640], rect=Fal<br>
se, resume=False, nosave=False, notest=False, noautoanchor=False, evolve=False, bucket=’’, cache_images=False, name=‘yolov4-tiny’, device=‘0’, multi_scale=False, single_cls=False, adam=Fa<br>
lse, sync_bn=False, local_rank=-1, logdir=‘runs/’, total_batch_size=16, world_size=1, global_rank=-1)<br>
Start Tensorboard with “tensorboard --logdir runs/”, view at <a href="http://localhost:6006/" rel="noopener nofollow ugc">http://localhost:6006/</a><br>
Hyperparameters {‘lr0’: 0.01, ‘momentum’: 0.937, ‘weight_decay’: 0.0005, ‘giou’: 0.05, ‘cls’: 0.5, ‘cls_pw’: 1.0, ‘obj’: 1.0, ‘obj_pw’: 1.0, ‘iou_t’: 0.2, ‘anchor_t’: 4.0, ‘fl_gamma’: 0.0<br>
, ‘hsv_h’: 0.015, ‘hsv_s’: 0.7, ‘hsv_v’: 0.4, ‘degrees’: 0.0, ‘translate’: 0.0, ‘scale’: 0.5, ‘shear’: 0.0, ‘perspective’: 0.0, ‘flipud’: 0.0, ‘fliplr’: 0.5, ‘mixup’: 0.0}<br>
WARNING: smart bias initialization failure.<br>
WARNING: smart bias initialization failure.<br>
Model Summary: 61 layers, 5.89029e+06 parameters, 5.89029e+06 gradients<br>
Optimizer groups: 21 .bias, 21 conv.weight, 19 other<br>
Traceback (most recent call last):<br>
File “E:\PyTorch_YOLOv4\train.py”, line 438, in <br>
train(hyp, opt, device, tb_writer)<br>
File “E:\PyTorch_YOLOv4\train.py”, line 145, in train<br>
dataloader, dataset = create_dataloader(train_path, imgsz, batch_size, gs, opt, hyp=hyp, augment=True,<br>
File “E:\PyTorch_YOLOv4\utils\datasets.py”, line 53, in create_dataloader<br>
dataset = LoadImagesAndLabels(path, imgsz, batch_size,<br>
File “E:\PyTorch_YOLOv4\utils\datasets.py”, line 337, in <strong>init</strong><br>
cache = torch.load(cache_path)  # load<br>
File “E:\PyTorch_YOLOv4\venv\lib\site-packages\torch\serialization.py”, line 608, in load<br>
return _legacy_load(opened_file, map_location, pickle_module, **pickle_load_args)<br>
File “E:\PyTorch_YOLOv4\venv\lib\site-packages\torch\serialization.py”, line 777, in _legacy_load<br>
magic_number = pickle_module.load(f, **pickle_load_args)<br>
_pickle.UnpicklingError: STACK_GLOBAL requires str<br>
this is my code and the error,I’m using the <a href="https://github.com/WongKinYiu/PyTorch_YOLOv4" class="inline-onebox" rel="noopener nofollow ugc">GitHub - WongKinYiu/PyTorch_YOLOv4: PyTorch implementation of YOLOv4</a> repository</p>

username: eooz
cooked: <p>Hello, I also encountered the same problem, have you solved this problem?</p>

username: Lucas_Eduardo
cooked: <p>Is that thing you are trying to import a torch tensor on a CUDA device?</p>
<p>I am having a problem like that with a tensor dump. I think that tensor was not exported properly for that usecase.</p>
<p>This error is like a dead end rn, idk what to do unless I ask the guys who exported to cast to a easier format like a recursive thing to transform that to a numpy array</p>

username: peony
cooked: <p>I have solved similar error by saving numpy file as<code> astype(np.float32)</code></p>