InsightFace_Pytorch
InsightFace_Pytorch copied to clipboard
Object arrays cannot be loaded when allow_pickle=False
I'm having a issue using the test_on_images Jupyter Notebook. I'm running into an issues with the np.load due to in not expecting a pickle object. Is there a workaround for this?
---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
<ipython-input-4-baf688e75413> in <module>
1 img = Image.open('images/office1.jpg')
----> 2 bounding_boxes, landmarks = detect_faces(img)
3 show_bboxes(img, bounding_boxes, landmarks)
~/Documents/šola/diploma/mtcnn-pytorch/src/detector.py in detect_faces(image, min_face_size, thresholds, nms_thresholds)
23
24 # LOAD MODELS
---> 25 pnet = PNet()
26 rnet = RNet()
27 onet = ONet()
~/Documents/šola/diploma/mtcnn-pytorch/src/get_nets.py in __init__(self)
53 self.conv4_2 = nn.Conv2d(32, 4, 1, 1)
54
---> 55 weights = np.load('src/weights/pnet.npy')[()]
56 for n, p in self.named_parameters():
57 p.data = torch.FloatTensor(weights[n])
~/opt/anaconda3/envs/diploma/lib/python3.8/site-packages/numpy/lib/npyio.py in load(file, mmap_mode, allow_pickle, fix_imports, encoding)
450 return format.open_memmap(file, mode=mmap_mode)
451 else:
--> 452 return format.read_array(fid, allow_pickle=allow_pickle,
453 pickle_kwargs=pickle_kwargs)
454 else:
~/opt/anaconda3/envs/diploma/lib/python3.8/site-packages/numpy/lib/format.py in read_array(fp, allow_pickle, pickle_kwargs)
737 # The array contained Python objects. We need to unpickle the data.
738 if not allow_pickle:
--> 739 raise ValueError("Object arrays cannot be loaded when "
740 "allow_pickle=False")
741 if pickle_kwargs is None:
ValueError: Object arrays cannot be loaded when allow_pickle=False
I fixed the issue by adding allow_pickle=True to np.load calls in get_nets.py. I can submit a pull request for this.
weights = np.load('mtcnn_pytorch/src/weights/pnet.npy',allow_pickle=True)[()]
I did the same but still get the error
weights = np.load('mtcnn_pytorch/src/weights/pnet.npy',allow_pickle=True)[()]I did the same but still get the error Maybe you should try to downgrade your numpy version to
conda install numpy=1.16.2or 1.16.1
Thank you for the response knightlibra
I was running the script in Google Colab, I refreshed the runtime and error was gone.
It seems the changes were not reflected in the same session. Closing the session and connecting again solved the issue.
weights = np.load('mtcnn_pytorch/src/weights/pnet.npy',allow_pickle=True)[()]I did the same but still get the error
There are three places you need to modify.