Matconvnet工具箱在Matlab中的安装

安装

 

  • 编译前确保Matab已绑定C++编译器,否则使用命令>>mex -setup 进行绑定编译器。
  • 将Matalb的工作路径切换到Matconvnet目录下,../matconvnet-1.0-beta23。
  • 编译工具箱,>>run matlab/vl_compilenn ;
  • 安装工具箱,>>run matlab/vl_setupnn ;

 

测试

 

  • 在Matlab工作空间输入一下代码,并运行;成功显示图片说明安装成功。

 

 

% Download a pre-trained CNN from the web (needed once).
urlwrite('http://www.vlfeat.org/matconvnet/models/imagenet-vgg-f.mat','imagenet-vgg-f.mat') ;
% Load a model and upgrade it to MatConvNet current version.
net = load('imagenet-vgg-f.mat') ;
net = vl_simplenn_tidy(net) ;
% Obtain and preprocess an image.
im = imread('peppers.png') ;
im_ = single(im) ; % note: 255 range
im_ = imresize(im_, net.meta.normalization.imageSize(1:2)) ;
im_ = im_ - net.meta.normalization.averageImage ;
% Run the CNN.
res = vl_simplenn(net, im_) ;
% Show the classification result.
scores = squeeze(gather(res(end).x)) ;
[bestScore, best] = max(scores) ;figure(1) ; clf ; imagesc(im) ;
title(sprintf('%s (%d), score %.3f', net.meta.classes.description{best}, best, bestScore)) ;

 

 

Using DAG models

The example above exemplifies using a model using the SimpleNN wrapper. More complex models use the DagNN wrapper instead. For example, to run GoogLeNet use:

% setup MatConvNet
run  matlab/vl_setupnn

% download a pre-trained CNN from the web (needed once)
urlwrite(...
  'http://www.vlfeat.org/matconvnet/models/imagenet-googlenet-dag.mat', ...
  'imagenet-googlenet-dag.mat') ;

% load the pre-trained CNN net = dagnn.DagNN.loadobj(load('imagenet-googlenet-dag.mat')) ; net.mode = 'test' ; % load and preprocess an image im = imread('peppers.png') ; im_ = single(im) ; % note: 0-255 range im_ = imresize(im_, net.meta.normalization.imageSize(1:2)) ; im_ = bsxfun(@minus, im_, net.meta.normalization.averageImage) ; % run the CNN net.eval({'data', im_}) ; % obtain the CNN otuput scores = net.vars(net.getVarIndex('prob')).value ; scores = squeeze(gather(scores)) ; % show the classification results [bestScore, best] = max(scores) ; figure(1) ; clf ; imagesc(im) ; title(sprintf('%s (%d), score %.3f',... net.meta.classes.description{best}, best, bestScore)) ;

http://www.vlfeat.org/matconvnet/quick/

 
 

 

 

转载于:https://www.cnblogs.com/wylhouse/p/7019885.html

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值