Open cverzq opened 4 years ago
One of the image you're trying to pass as an input is grayscale. When given as an input it becomes (1,416,416), there's a resize of the image to (416,416) and 1 reprensents the number of input image in that case.
The model expect inputs to have the shape (?,416, 416, 3) which means RGB images.
img=np.array(Image.open(PATH_TO_IMG))
if len(img.shape)<3 :
w, h = img.shape
ret = np.empty((w, h, 3), dtype=np.uint8)
ret[:, :, 2] = ret[:, :, 1] = ret[:, :, 0] = img
img=ret
One of the image you're trying to pass as an input is grayscale. When given as an input it becomes (1,416,416), there's a resize of the image to (416,416) and 1 reprensents the number of input image in that case.
The model expect inputs to have the shape (?,416, 416, 3) which means RGB images.
To solve the problem, first transform your grayscale images to RGB like so :
img=np.array(Image.open(PATH_TO_IMG)) if len(img.shape)<3 : w, h = img.shape ret = np.empty((w, h, 3), dtype=np.uint8) ret[:, :, 2] = ret[:, :, 1] = ret[:, :, 0] = img img=ret
Thank you for your answer. The gray image does cause the problem,which I had solved the problem.
when I use command "python test_yolo.py model_data/yolo.h5", always display "cannot feed value of shape(1,416,416) for Tensor ‘ input_1:0’ ,which has shape '(?,416,416,3)'" problem, have others meet this problem? please explain the problem and how to solve the problem