I am trying to classify some images from GoogleNet
using Pycaffe
everything is in its default state, the deploy.prototxt
and also the pre-trained model. However, when I want to run the code, I get the following error:
ValueError: could not broadcast input array from shape (1,3,256,256) into shape (1,3,224,224)
which happens when I want to subtract my image from the mean file! This is the code I'm using:
# Extract mean from the mean image file
mean_blobproto_new = caffe.proto.caffe_pb2.BlobProto()
f = open(args.mean, 'rb')
mean_blobproto_new.ParseFromString(f.read())
mean_image = caffe.io.blobproto_to_array(mean_blobproto_new)
for i, image, label in reader:
image_caffe = image.reshape(1, *image.shape)
out = net.forward(data=np.asarray([ image_caffe ])- mean_image)
plabel = int(out['pred'][0].argmax(axis=0))
and this is the deploy.prototxt
file, (the network was trained on 256x256
images cropped at 224x224 just like GoogleNet
and GoogleNet mean-file is used as well): https://pastebin.com/2QEtEeHW
what is wrong here?
Shouldn't Caffe
first subtract the image and then crops it so this error wouldn't happen?
What should I do?