按步骤来就好:
1. 新建一个空文件夹quickstart使用官方给出的代码测试:
% Install and compile MatConvNet (needed once).
untar('http://www.vlfeat.org/matconvnet/download/matconvnet-1.0-beta25.tar.gz') ;
cd matconvnet-1.0-beta25
run matlab/vl_compilenn ;
报错1:
'cl.exe' 不是内部或外部命令,也不是可运行的程序 或批处理文件。
解决办法:
在c盘找到cl.exe文件位置,
C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\VC\Tools\MSVC\14.16.27023\bin\Hostx64\x64
将该路径添加至计算机系统环境变量,然后将MATLAB关闭再重启就好了。
2. 参考urlwrite函数下载模型速度比较慢:
% 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') ;
可以从网站上直接下载放在当前文件夹中: http://www.vlfeat.org/matconvnet/pretrained/
3. 然后加载预训练模型-运行:
注:peppers图片需要自己网上下载保存到当前文件夹
% Setup MatConvNet.
run matlab/vl_setupnn ;
% 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)) ;
之前参照别的博主文章推荐先在官网上下载matconvnet库出了一堆网上能够查出来的错误,简直暴风哭泣,这样重新开始除了cl.exe错误之外就很顺利了!