ValueError: need at least one array to concatenate

最近研究MTCNN算法,在运行gen_hard_example.py时因为将阈值[0.6,0.7,0.7]修改成[0.5,0.5,0.3]之后,执行某张训练图像时,返回
Traceback (most recent call last):
File “gen_hard_example.py”, line 193, in
main(parse_arguments(sys.argv[1:]))
File “gen_hard_example.py”, line 70, in main
detectors,_=mtcnn_detector.detect_face(test_data)
File “/home/xxx/tensorflow-MTCNN-master/detection/MtcnnDetector.py”, line 87, in detect_face
boxes, boxes_c, landmark = self.detect_rnet(im, boxes_c)
File “/home/xxx/tensorflow-MTCNN-master/detection/MtcnnDetector.py”, line 180, in detect_rnet
cls_scores, reg, _ = self.rnet_detector.predict(cropped_ims)
File “/home/xxx/tensorflow-MTCNN-master/detection/detector.py”, line 63, in predict
return np.concatenate(cls_prob_list, axis=0), np.concatenate(bbox_pred_list, axis=0), np.concatenate(landmark_pred_list, axis=0)
ValueError: need at least one array to concatenate

调试代码之后发现, num_boxes=np.sum(np.where((np.minimum(tmpw,tmph)>=delete_size),ones,zeros))这里返回的num_boxes为0,所以产生了上述错误。
solution:在上述代码下面增加一行
if num_boxes == 0:
return None, None, None
即可。ps:相关代码的缩进要注意修改。

你可能感兴趣的:(人脸检测)