Caffe model produces the same result for every image

I just loaded alexnet into caffe using the predefined prototxt and caffemodel files. However, sending any image to the model returns the same value as the output of the fc7 layer.

Here is a code snippet

net=caffe.Net('alexnet/train_val.prototxt','alexnet/bvlc_alexnet.caffemodel',caffe.TEST) 

for image in images:
    im = np.array(caffe.io.load_image(image))
    im = caffe.io.resize_image(im, (227, 227))
    im = np.array(im,dtype=np.float32)
    im =255*im;
    im = im[:,:,::-1]
    im -= np.array(((104.00698793,116.66876762,122.67891434)))
    im = im.transpose(2,0,1)
    net.blobs['data'].reshape(1,*im.shape)
    net.blobs['data'].data[...] = im
    net.forward()
    fc = net.blobs['fc7'].data #Always the same value

      

+3


source to share





All Articles