Caffe model gives same output for every image

Viewed 602

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

Here is the 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
0 Answers
Related