Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Failed to load weights #33

Closed
vBLFTePebWNi6c opened this issue Apr 25, 2019 · 2 comments
Closed

Failed to load weights #33

vBLFTePebWNi6c opened this issue Apr 25, 2019 · 2 comments

Comments

@vBLFTePebWNi6c
Copy link

When I tried to create an instance of MTCNN detector, something went wrong:

---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
<ipython-input-7-be16e7eec9f4> in <module>
      3 
      4 img = cv2.imread("ivan.jpg")
----> 5 detector = MTCNN()
      6 
      7 for i in range(len(images)):

.../lib/python3.5/site-packages/mtcnn/mtcnn.py in __init__(self, weights_file, min_face_size, steps_threshold, scale_factor)
    193             self.__session = tf.Session(config=config, graph=self.__graph)
    194 
--> 195             weights = np.load(weights_file).item()
    196             self.__pnet = PNet(self.__session, False)
    197             self.__pnet.set_weights(weights['PNet'])

.../lib/python3.5/site-packages/numpy/lib/npyio.py in load(file, mmap_mode, allow_pickle, fix_imports, encoding)
    445             else:
    446                 return format.read_array(fid, allow_pickle=allow_pickle,
--> 447                                          pickle_kwargs=pickle_kwargs)
    448         else:
    449             # Try a pickle

.../lib/python3.5/site-packages/numpy/lib/format.py in read_array(fp, allow_pickle, pickle_kwargs)
    690         # The array contained Python objects. We need to unpickle the data.
    691         if not allow_pickle:
--> 692             raise ValueError("Object arrays cannot be loaded when "
    693                              "allow_pickle=False")
    694         if pickle_kwargs is None:

ValueError: Object arrays cannot be loaded when allow_pickle=False

I googled a bit and now think that problem causes due to new versions of numpy (see this issue: tensorflow/tensorflow#28102).

@elmahyai
Copy link
Contributor

Exactly. It works after adding allow_pickle=True
#32

@togelian
Copy link

togelian commented May 6, 2019

I fixed it by changing line 195 in mtcnn.py to:
weights = np.load(weights_file, allow_pickle=True).item()

Just in case any others have the same problem

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants