Groups keyboard shortcuts have been updated
Dismiss
See shortcuts

Deploy and use LeNet on Matlab using MatCaffe

29 views
Skip to first unread message

Victor Ang

unread,
Apr 26, 2017, 12:05:22 AM4/26/17
to Caffe Users

I am having issue with MatCaffe. I trained LeNet using my own dataset (2 classification, 0 or 1) in python successfully and trying to deploy it on Matlab now. Net architecture is from caffe/examples/mnist/lenet.prototxt. All the input images I fed into the net always return 1. (i tried using both positive and negative images from training).

Below is my code:

deployNet = 'lenet_deploy.prototxt';
caffeModel = 'weight.caffemodel';
caffe.set_mode_cpu();
net = caffe.Net(deployNet, caffeModel, 'test');
net.blobs('data').reshape([28 28 1 1]);
net.reshape();

patch_data = imread('cropped.jpg'); % already in greyscale
patch_data = imresize(patch_data, [28 28],'bilinear');
imshow(patch_data)

input_data = {patch_data};
scores = net.forward(input_data);

highest = max(scores{1});
disp(i);
disp(highest);

The highest always return 1 even for negative image. I tried deploying it on python and it works great. I am guessing issue with the way I pre-process the input.


Reply all
Reply to author
Forward
0 new messages