def __init__(self):
caffe.set_mode_gpu()
#caffe.set_device(0)
model_path = '../models/bvlc_googlenet/' # substitute your path here
net_fn = model_path + 'deploy.prototxt'
param_fn = model_path + 'bvlc_googlenet.caffemodel'
model = caffe.io.caffe_pb2.NetParameter()
text_format.Merge(open(net_fn).read(), model)
model.force_backward = True #backward to input layer
open('tmp.prototxt', 'w').write(str(model))
self.net = caffe.Classifier('tmp.prototxt', param_fn,
mean = np.float32([104.0, 116.0, 122.0]),
channel_swap = (2,1,0))
# for the mode guide, if flag = 1
self.flag = 0
self.epoch = 20
self.end = 'inception_4c/output'
#self.end = 'conv4'
评论列表
文章目录