Open envhyf opened 2 years ago
Hi Yufang,
maybe your input image has more than 4 channels. If so, you could to change load_image() in edges.py:
if len(img.shape)<3:
img = sk.color.gray2rgb(img)
print('Input image was converted to grayscale.')
elif len(img.shape) == 3:
pass
elif len(img.shape) == 4:
img = img[:,:,:3]
print('Skipped last dimension(s) of input image.')
else:
raise ValueError('Input image has more than 4 channels:', img.shape)
Hi Johannes! When I executed your code with my own figures, there will be an error popping out as shown below:
Size of input image: 645px * 899px Estimated number of tiles: 2013 [ERROR:0@1.277] global /io/opencv/modules/dnn/src/dnn.cpp (3872) getLayerShapesRecursively OPENCV/DNN: [Convolution]:(conv1_1): getMemoryShapes() throws exception. inputs=1 outputs=0/1 blobs=2 [ERROR:0@1.277] global /io/opencv/modules/dnn/src/dnn.cpp (3878) getLayerShapesRecursively input[0] = [ 1 4 645 899 ] [ERROR:0@1.278] global /io/opencv/modules/dnn/src/dnn.cpp (3886) getLayerShapesRecursively blobs[0] = CV_32FC1 [ 64 3 3 3 ] [ERROR:0@1.278] global /io/opencv/modules/dnn/src/dnn.cpp (3886) getLayerShapesRecursively blobs[1] = CV_32FC1 [ 64 1 ] [ERROR:0@1.278] global /io/opencv/modules/dnn/src/dnn.cpp (3888) getLayerShapesRecursively Exception message: OpenCV(4.5.5) /io/opencv/modules/dnn/src/layers/convolution_layer.cpp:404: error: (-2:Unspecified error) Number of input channels should be multiple of 3 but got 4 in function 'getMemoryShapes'
Traceback (most recent call last): File "./mosaic.py", line 60, in
img_edges = edges.edges_hed(img0, gauss=GAUSS, plot=plot_list)
File "/mnt/d/Dropbox/code/web-project/Mosaic/mosaic-main/edges.py", line 113, in edges_hed
hed_matrix = hed_edges(img)
File "/mnt/d/Dropbox/code/web-project/Mosaic/mosaic-main/edges.py", line 99, in hed_edges
out = net.forward()
cv2.error: OpenCV(4.5.5) /io/opencv/modules/dnn/src/layers/convolution_layer.cpp:404: error: (-2:Unspecified error) Number of input channels should be multiple of 3 but got 4 in function 'getMemoryShapes'
I have searched on the internet, and still could not figure out how to solve it.