Facenet: ValueError while training triplet loss

Created on 24 Apr 2019  路  10Comments  路  Source: davidsandberg/facenet

@davidsandberg I am facing the ValueError when I am training the triplet loss. Please can you suggest the solution?

python src/align/align_dataset_mtcnn.py /home/poonam/Downloads/Bright_IMG /home/poonam/Downloads/Bright_IMG1 --image_size 182 --margin 44
Creating networks and loading parameters
Traceback (most recent call last):
File "src/align/align_dataset_mtcnn.py", line 161, in
main(parse_arguments(sys.argv[1:]))
File "src/align/align_dataset_mtcnn.py", line 57, in main
pnet, rnet, onet = align.detect_face.create_mtcnn(sess, None)
File "/home/poonam/projects/facenet/src/align/detect_face.py", line 283, in create_mtcnn
pnet.load(os.path.join(model_path, 'det1.npy'), sess)
File "/home/poonam/projects/facenet/src/align/detect_face.py", line 85, in load
data_dict = np.load(data_path, encoding='latin1').item() #pylint: disable=no-member
File "/home/poonam/.virtualenvs/facenet/lib/python3.6/site-packages/numpy/lib/npyio.py", line 447, in load
pickle_kwargs=pickle_kwargs)
File "/home/poonam/.virtualenvs/facenet/lib/python3.6/site-packages/numpy/lib/format.py", line 692, in read_array
raise ValueError("Object arrays cannot be loaded when "
ValueError: Object arrays cannot be loaded when allow_pickle=False

Most helpful comment

They didn't give a specific version of package so these are broke.
Please try install this versions. Problem will solved.

pip install numpy==1.16
pip install scipy==1.1.0

All 10 comments

check if your model_path is correct and det1.npy exists in directory
It seems your mtcnn face detection model is not loaded correctly in line pnet.load(os.path.join(model_path, 'det1.npy'), sess)

@thelastfunction Thanks.

@PoonamZ How You Solve that??

I have the same issue on line 283 of the file detect_face.py,
I also add a print before to confirm is the model_path is correct, it is OK.
the det1.npy, det2.npy, det2.npy just right in the folder of /src/align/

There are also many warnings, indicating some useage of code is deprecated!

`W0622 18:15:39.963512 139750941083392 deprecation_wrapper.py:119] From src/align/align_dataset_mtcnn.py:52: The name tf.GPUOptions is deprecated. Please use tf.compat.v1.GPUOptions instead.

W0622 18:15:39.964641 139750941083392 deprecation_wrapper.py:119] From src/align/align_dataset_mtcnn.py:53: The name tf.Session is deprecated. Please use tf.compat.v1.Session instead.

W0622 18:15:39.964763 139750941083392 deprecation_wrapper.py:119] From src/align/align_dataset_mtcnn.py:53: The name tf.ConfigProto is deprecated. Please use tf.compat.v1.ConfigProto instead.

2019-06-22 18:15:39.965052: I tensorflow/core/platform/cpu_feature_guard.cc:142] Your CPU supports instructions that this TensorFlow binary was not compiled to use: AVX2 FMA
WARNING: Logging before flag parsing goes to stderr.
W0622 18:15:39.969522 139792992794368 deprecation_wrapper.py:119] From src/align/align_dataset_mtcnn.py:52: The name tf.GPUOptions is deprecated. Please use tf.compat.v1.GPUOptions instead.

W0622 18:15:39.971852 139792992794368 deprecation_wrapper.py:119] From src/align/align_dataset_mtcnn.py:53: The name tf.Session is deprecated. Please use tf.compat.v1.Session instead.

W0622 18:15:39.973070 139792992794368 deprecation_wrapper.py:119] From src/align/align_dataset_mtcnn.py:53: The name tf.ConfigProto is deprecated. Please use tf.compat.v1.ConfigProto instead.

2019-06-22 18:15:39.973934: I tensorflow/core/platform/cpu_feature_guard.cc:142] Your CPU supports instructions that this TensorFlow binary was not compiled to use: AVX2 FMA
WARNING: Logging before flag parsing goes to stderr.
W0622 18:15:39.978578 139680673736448 deprecation_wrapper.py:119] From src/align/align_dataset_mtcnn.py:52: The name tf.GPUOptions is deprecated. Please use tf.compat.v1.GPUOptions instead.

WARNING: Logging before flag parsing goes to stderr.
W0622 18:15:39.979246 139680673736448 deprecation_wrapper.py:119] From src/align/align_dataset_mtcnn.py:53: The name tf.Session is deprecated. Please use tf.compat.v1.Session instead.

W0622 18:15:39.979369 139680673736448 deprecation_wrapper.py:119] From src/align/align_dataset_mtcnn.py:53: The name tf.ConfigProto is deprecated. Please use tf.compat.v1.ConfigProto instead.

2019-06-22 18:15:39.979740: I tensorflow/core/platform/cpu_feature_guard.cc:142] Your CPU supports instructions that this TensorFlow binary was not compiled to use: AVX2 FMA
2019-06-22 18:15:39.980931: I tensorflow/core/platform/profile_utils/cpu_utils.cc:94] CPU Frequency: 2112000000 Hz
W0622 18:15:39.977033 140020089046784 deprecation_wrapper.py:119] From src/align/align_dataset_mtcnn.py:52: The name tf.GPUOptions is deprecated. Please use tf.compat.v1.GPUOptions instead.

W0622 18:15:39.982066 140020089046784 deprecation_wrapper.py:119] From src/align/align_dataset_mtcnn.py:53: The name tf.Session is deprecated. Please use tf.compat.v1.Session instead.

W0622 18:15:39.982222 140020089046784 deprecation_wrapper.py:119] From src/align/align_dataset_mtcnn.py:53: The name tf.ConfigProto is deprecated. Please use tf.compat.v1.ConfigProto instead.
.....
`

@doyanger you may be using tensorflow 2.0 version, thats why you are getting these warnings ......you can ignore them ... or you can downgrade it to tensorflow 1.8

Hi Guys can someone help me with this I get the same error
detect_face.py
print("this is data path="+os.path.join(model_path, 'det1.npy')) pnet.load(os.path.join(model_path, 'det1.npy'), sess)

the det1.npy file is existed in the directory, still I get this error

this is data path=/Users/mohammadkhaleghi/AI/facenet/src/align/det1.npy Traceback (most recent call last): File "align_dataset_mtcnn.py", line 160, in <module> main(parse_arguments(sys.argv[1:])) File "align_dataset_mtcnn.py", line 56, in main pnet, rnet, onet = detect_face.create_mtcnn(sess, None) File "/Users/mohammadkhaleghi/AI/facenet/src/align/detect_face.py", line 284, in create_mtcnn pnet.load(os.path.join(model_path, 'det1.npy'), sess) File "/Users/mohammadkhaleghi/AI/facenet/src/align/detect_face.py", line 85, in load data_dict = np.load(data_path, encoding='latin1').item() #pylint: disable=no-member File "/opt/anaconda3/lib/python3.7/site-packages/numpy/lib/npyio.py", line 453, in load pickle_kwargs=pickle_kwargs) File "/opt/anaconda3/lib/python3.7/site-packages/numpy/lib/format.py", line 722, in read_array raise ValueError("Object arrays cannot be loaded when " ValueError: Object arrays cannot be loaded when allow_pickle=False

File "alignalign_dataset_mtcnn.py", line 170, in
main(args)
File "alignalign_dataset_mtcnn.py", line 53, in main
pnet, rnet, onet = align.detect_face.create_mtcnn(sess, None)
File "C:UsersRitesh's LaptopDesktopfacial-recognition-video-facenetsrcaligndetect_face.py", line 283, in create_mtcnn
pnet.load(os.path.join(model_path, 'det1.npy'), sess)
File "C:UsersRitesh's LaptopDesktopfacial-recognition-video-facenetsrcaligndetect_face.py", line 85, in load
data_dict = np.load(data_path, encoding='latin1').item() #pylint: disable=no-member
File "C:UsersRitesh's LaptopAppDataLocalProgramsPythonPython36libsite-packagesnumpylibnpyio.py", line 447, in load
pickle_kwargs=pickle_kwargs)
File "C:UsersRitesh's LaptopAppDataLocalProgramsPythonPython36libsite-packagesnumpylibformat.py", line 692, in read_array
raise ValueError("Object arrays cannot be loaded when "
ValueError: Object arrays cannot be loaded when allow_pickle=False

@soniritesh124 This may due do the version complexity in numpy, what numpy version are you using?

They didn't give a specific version of package so these are broke.
Please try install this versions. Problem will solved.

pip install numpy==1.16
pip install scipy==1.1.0

@us
Thank you, it works now

Was this page helpful?
0 / 5 - 0 ratings

Related issues

patienceFromZhou picture patienceFromZhou  路  3Comments

MaartenBloemen picture MaartenBloemen  路  3Comments

arunxz98 picture arunxz98  路  3Comments

xvdehao picture xvdehao  路  4Comments

RaviRaaja picture RaviRaaja  路  3Comments