Hi,
I'm trying to evaluate a saved convolutional network according to this tutorial https://github.com/Microsoft/CNTK/wiki/Evaluate-a-saved-convolutional-network but I'm not able to load an image. Error I'm getting is
ValueError: Value::Create:: The shape of the sequence 0 ([224 x 224]) is not compatible with the sample shape ([3 x 224 x 224])
Here is my code
import numpy as np
from PIL import Image
import matplotlib.image as img
import cntk as ct
from cntk import load_model
if __name__ == "__main__":
pathToImage = 'C:\\Apache24\\htdocs\\diplomka\\images\\yay.png'
size = 224, 224
rgb_image = np.asarray(Image.open(pathToImage).resize(size), dtype=np.float32) - 128
bgr_image = rgb_image[..., [2, 1, 0]]
pic = np.ascontiguousarray(np.rollaxis(bgr_image, 2))
print(np.shape(pic)) # shape is (3x224x224) here
z = load_model("model.dnn")
z_out = ct.combine([z.outputs[2].owner])
predictions = np.squeeze(z_out.eval({z_out.arguments[0]:pic}))
top_class = np.argmax(predictions)
And here is the image I used

Hi
Your image has 4 channels, because it has png format. Line 14 will print (224, 224, 4) as the shape of image. You should put its transparency channel away before feed it into network.
@hajix I tried to remove the transparency layer of png image. It didn't help. The error is the same for jpg images.
@zhouwangzw Hi, could you please look into it? I can't tell if it's another bug or not :(
@Arminea
try:
...
predictions = np.squeeze(z_out.eval({z_out.arguments[0]: [pic]}))
...
i.e. put pic in a list.
I found a Stack Overflow post that helped me with a similar issue: http://stackoverflow.com/a/42354910/1226799
juharris is correct, pic should be in a list. I also updated the Wiki page.
@juharris That solved my issue. Thank you :)
Most helpful comment
@Arminea
try:
i.e. put
picin a list.I found a Stack Overflow post that helped me with a similar issue: http://stackoverflow.com/a/42354910/1226799