davidsandberg / facenet

Face recognition using Tensorflow
MIT License
13.77k stars 4.81k forks source link

Negative dimensions in detect_face.py when running separate align processes in separate threads #395

Closed avikj closed 6 years ago

avikj commented 7 years ago
Exception in thread Thread-105:
Traceback (most recent call last):
  File "/usr/lib/python2.7/threading.py", line 810, in __bootstrap_inner
    self.run()
  File "/usr/lib/python2.7/threading.py", line 763, in run
    self.__target(*self.__args, **self.__kwargs)
  File "/data/shot-annotate/annotation/main.py", line 48, in main
    align_data_mtcnn.align_frames(extracted_frame_dir, aligned_faces_dir)
  File "/data/shot-annotate/annotation/align/align_data_mtcnn.py", line 99, in align_frames
    bounding_boxes, _ = detect_face.detect_face(img, minsize, pnet, rnet, onet, threshold, factor)
  File "/data/shot-annotate/annotation/align/detect_face.py", line 319, in detect_face
    tmp = np.zeros((int(tmph[k]), int(tmpw[k]), 3))
ValueError: negative dimensions are not allowed

I get this exception when running align_dataset_mtcnn on two separate datasets, on separate threads, simultaneously (I wrapped them in functions and am starting threads with the threading module). Some of the values in the tmpw and tmph arrays are negative, causing this error. It works fine when only one thread is running at a time, but when I start another programmatically it fails. Anyone know how to fix this?

avikj commented 7 years ago

Part of the problem was GPU fractions, which were set to 1.0 for both threads. I reduced them to 0.4 each, and got a new error. On line 365 of detect_face.py, np.empty() is called and returned without parameters. It has a required parameter shape. What is this supposed to return?

davidsandberg commented 6 years ago

Reopen if this is still a problem.