File Exchange

image thumbnail

Deep Learning Toolbox Importer for Caffe Models

Software support package for importing pretrained Caffe Models

34 Downloads

Updated 11 Sep 2019

This software support package provides functions for importing pretrained models as well as layers of Convolutional Neural Networks (CNNs) from Caffe (http://caffe.berkeleyvision.org/). Pretrained models are imported as a SeriesNetwork or a Directed Acyclic Graph (DAG) network object.

Opening the caffeimporter.mlpkginstall file from your operating system or from within MATLAB will initiate the installation process for the release you have.
This mlpkginstall file is functional for R2017a and beyond.

Usage Example (importCaffeNetwork):
% Specify files to import
protofile = 'digitsnet.prototxt';
datafile = 'digits_iter_10000.caffemodel';
% Import network
net = importCaffeNetwork(protofile,datafile)
Usage Example (importCaffeLayers):
% Specify file to import
protofile = 'digitsnet.prototxt';
% Import network layers
layers = importCaffeLayers('digitsnet.prototxt')

For more information on importing Caffe networks, please visit our documentation at https://www.mathworks.com/help/deeplearning/ref/importcaffenetwork.html

For more information on importing layers from Caffe, please visit our documentation at
https://www.mathworks.com/help/deeplearning/ref/importcaffelayers.html

To get a list of all the pretrained models supported by MATLAB, please visit https://www.mathworks.com/solutions/deep-learning/models.html

Comments and Ratings (21)

Sorry, but with the latest version I'm still unable to import a Resnet50 model. This is the error I get:

Error using nnet.internal.cnn.caffe.CaffeModelReader/importSeriesNetwork (line 310)
The network 'ResNet-50' is not determined to be a Series Network. Only series networks can be imported.

Error in importCaffeNetwork (line 84)
network = importSeriesNetwork(readerObj);

Ting Su

DAG networks can be imported using the importer released after Sep/12/2018.

Ting Su

Hi Ankit,
The digitsnet.prototxt file is shipped with this importer.

from where to download digitsnet.prototxt file

cui

The network 'GoogleNet' is not determined to be a Series Network. Only series networks can be
imported. Can it enhance its versatility?

Baris Ersoy

Hi I was trying to import SqueezeNet_v_1.0 from caffe. However, I get the following error message:
"The network '' is not determined to be a Series Network. Only series networks can be imported"
Is there any solution to this? It would be really helpful if we could export networks like SqueezeNet, GoogleNet (which contain concat layer) from caffe to matlab.

Serendipity

hua ye

Same with adhusch. I would also appreciate if 'Deconbolution' layer is supported..

Also support for PReLU layers would be sweet :)

Carl Hart

Echoing adhusch's comment: support for 'Deconvolution' layers would be a very practical improvement.

adhusch

Would be great if you could support the import of "Deconvolution" (i.e. transposed convolution) layers, enabling the use of U-Nets.

Thanks for the nice tool! I got an error though while importing a net:

The pooling layer 'pool2' is not compatible with MATLAB. Caffe computes the output size as [13 13
256] but MATLAB computes it as [12 12 256].

Is there any workaround for this?

Hi, I just wonder is there's any way to transfer "tile" layer of CAFFE to MATLAB.

cui

Ok, I understood...
the step 3 (previous comment) ./install_supportsoftware.sh -matlabroot $MROOT/R2017a
install effectively importCaffexxxx in the matlbrootdirectory BUT also a lot of stuff in /root/Documents/MATLAB/...
=> Consequentce: only root is able to use the add-ons !!???
Is there an other solution to install an add-on for every user on a platform?

install on HPC using command line would be great...:
1) first: (no command line) : choose "download" (whearas install in a graphical session)
2) transfer the package to your HPC main node (default download directory : ~/MathWorks/SupportedPackages
3) ./install_supportsoftware.sh -matlabroot $MROOT/R2017a
4) test (the previous example on this page) ... produce the following error:
net = importCaffeNetwork(protofile,datafile)
Error using importCaffeNetwork (line 77)
importCaffeNetwork requires the Neural Network Toolbox Importer for Caffe Models support package. To install this
support package, use the <a href="matlab:
matlab.addons.supportpackage.internal.explorer.showSupportPackages('CAFFEIMPORTER', 'tripwire')">Add-On
Explorer</a>.

=> :-( ???

I was wondering if there is a way to install this package on the HPC (using command line)? Thanks a heap in advance!

sconly

is it not compatible with win10?

MATLAB Release Compatibility
Created with R2017a
Compatible with R2017a to R2019b
Platform Compatibility
Windows macOS Linux