Skip to content

Commit dfec947

Browse files
rbgirshickshelhamer
authored andcommitted
cleanup matlab demo
1 parent 9c7a993 commit dfec947

File tree

2 files changed

+13
-42
lines changed

2 files changed

+13
-42
lines changed

matlab/caffe/matcaffe_demo.m

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
function scores = matcaffe_demo(im, use_gpu)
1+
function [scores, layers] = matcaffe_demo(im, use_gpu)
22
% scores = matcaffe_demo(im, use_gpu)
33
%
44
% Demo of the matlab wrapper using the ILSVRC network.
@@ -11,7 +11,7 @@
1111
% scores 1000-dimensional ILSVRC score vector
1212
%
1313
% You may need to do the following before you start matlab:
14-
% $ export LD_LIBRARY_PATH=/opt/intel/mkl/lib/intel64:/usr/local/cuda/lib64
14+
% $ export LD_LIBRARY_PATH=/opt/intel/mkl/lib/intel64:/usr/local/cuda-5.5/lib64
1515
% $ export LD_PRELOAD=/usr/lib/x86_64-linux-gnu/libstdc++.so.6
1616
% Or the equivalent based on where things are installed on your system
1717
%
@@ -20,12 +20,16 @@
2020
% scores = matcaffe_demo(im, 1);
2121
% [score, class] = max(scores);
2222

23-
model_def_file = '../../examples/imagenet/imagenet_deploy.prototxt';
24-
% NOTE: you'll have to get the pre-trained ILSVRC network
25-
model_file = '../../examples/imagenet/caffe_reference_imagenet_model';
26-
2723
% init caffe network (spews logging info)
28-
caffe('init', model_def_file, model_file);
24+
if caffe('is_initialized') == 0
25+
model_def_file = '../../examples/imagenet/imagenet_deploy.prototxt';
26+
model_file = '../../examples/imagenet/caffe_reference_imagenet_model';
27+
if exist(model_file, 'file') == 0
28+
% NOTE: you'll have to get the pre-trained ILSVRC network
29+
error('You need a network model file');
30+
end
31+
caffe('init', model_def_file, model_file);
32+
end
2933

3034
% set to use GPU or CPU
3135
if exist('use_gpu', 'var') && use_gpu
@@ -51,6 +55,8 @@
5155
scores = reshape(scores{1}, [1000 10]);
5256
scores = mean(scores, 2);
5357

58+
% you can also get network weights by calling
59+
layers = caffe('get_weights');
5460

5561
% ------------------------------------------------------------------------
5662
function images = prepare_image(im)

matlab/caffe/matcaffe_demo_weights.m

Lines changed: 0 additions & 35 deletions
This file was deleted.

0 commit comments

Comments
 (0)