caffe layer zero output-python

255 views Asked by At

I get the output of the VGG-changed network(here is vectors of 3 float numbers)every thing is OK, but when I just want to get the output of other layers(e.g. last convolution layer conv5_4) instead of the last layer, the output vectors are all zero. This is the python code to get the output:

import sys
import cv2
import numpy as np
sys.path.insert(0, '/home/deep/rahim/caffe-master/python')
import caffe
input_image_file = sys.argv[1]
output_file = sys.argv[2]
model_file = '/home/deep/rahim/PGM/Final/feature/deep/snapshot_iter_355000.caffemodel'
deploy_prototxt = '/home/deep/rahim/PGM/Final/feature/deep/deploy.prototxt'
net = caffe.Net(deploy_prototxt, model_file, caffe.TEST)
layer = 'conv5_4'
transformer = caffe.io.Transformer({'data':       net.blobs['data'].data.shape})
transformer.set_transpose('data', (2,0,1))
transformer.set_raw_scale('data', 255.0)
net.blobs['data'].reshape(1,3,40,40)
img = caffe.io.load_image(input_image_file)
net.blobs['data'].data[...] = transformer.preprocess('data', img)
output = net.forward()
print '%s' %(net.blobs[layer].data[0])

please help me

1

There are 1 answers

0
RahimEnt On

I changed the model from VGG-changed to LENET. the problem solved. It seemed the changed to vgg causes the above problem.