Open juliojj opened 5 years ago
What an amazing! I had met almost the same bug with you. And after debugging, I found the original source code is wrong. But my bug is a little different from yours. Your condition shows the edy[i] may be negative.
could not broadcast input array from shape (0,63,3) into shape (58,63,3)
but my bug remind us the edx[i] may also be negative.
could not broadcast input array from shape (65,0,3) into shape (65,51,3)
So I used your bug fixed method and added another judge condition at the same time. My bug is fixed :-)
for i in range(num_box):
if(tmph[i] > 0): # << WARNING (bug fixed)
tmp = np.zeros((tmph[i], tmpw[i], 3), dtype=np.uint8)
if(edy[i] >= 0 and edx[i] >= 0): # << WARNING (bug fixed)
tmp[dy[i]:edy[i]+1, dx[i]:edx[i]+1, :] = img[y[i]:ey[i]+1, x[i]:ex[i]+1, :]
input_buf[i, :, :, :] = adjust_input(cv2.resize(tmp, (24, 24)))
What an amazing! I had met almost the same bug with you. And after debugging, I found the original source code is wrong. But my bug is a little different from yours. Your condition shows the edy[i] may be negative.
could not broadcast input array from shape (0,63,3) into shape (58,63,3)
but my bug remind us the edx[i] may also be negative.
could not broadcast input array from shape (65,0,3) into shape (65,51,3)
So I used your bug fixed method and added another judge condition at the same time. My bug is fixed :-)
for i in range(num_box): if(tmph[i] > 0): # << WARNING (bug fixed) tmp = np.zeros((tmph[i], tmpw[i], 3), dtype=np.uint8) if(edy[i] >= 0 and edx[i] >= 0): # << WARNING (bug fixed) tmp[dy[i]:edy[i]+1, dx[i]:edx[i]+1, :] = img[y[i]:ey[i]+1, x[i]:ex[i]+1, :] input_buf[i, :, :, :] = adjust_input(cv2.resize(tmp, (24, 24)))
thx for the solution
Thanks a lot for sharing your code. I am sharing with you how I managed to fix two errors when running your code. Maybe it can help who face the same problems. For some reason, just two images in my dataset generated these errors, on file mtcnn_detector.py:
error 1) could not broadcast input array from shape (0,63,3) into shape (58,63,3), where "63" can be any other value...
error 2) tmp = np.zeros((tmph[i], tmpw[i], 3), dtype=np.uint8) ValueError: negative dimensions are not allowed.
The two new conditions below fixed (temporary, as I didn't track the source of it) the problem:
(line 280)
pad the bbox