Caffe model gives same output for every image

53 views
Skip to first unread message

HARJATIN SINGH

unread,
May 22, 2017, 2:10:33 PM5/22/17
to Caffe Users

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, color=True)).squeeze()
    im_input = im[np.newaxis, np.newaxis, :, :]
    net.blobs['data'].reshape(*im_input.shape)
    net.blobs['data'].data[...] = im_input
    net.forward()
    fc = net.blobs['fc7'].data
    print(fc)#Always produces the same output

Shubham Juneja

unread,
May 23, 2017, 6:45:29 AM5/23/17
to Caffe Users

I am experiencing a similar problem. What I have seen so far is that first image gets stuck in the blob. I can't find any way to clear the blob after every net.forward() . I don't want to send in Test images in batches, I want to go sequentially.
Reply all
Reply to author
Forward
0 new messages