MatDeepRep: Deep representation learning tool for image classification with Matlab

MatDeepRep is a Matlab plugin , built on top of Caffe framework, capable of learning deep representations for image classification using the BVLC caffe matlab interface (matcaffe) & various pretrained .caffemodel binaries.


The MatDeepRep function requires the Caffe deep learning framework (available from, which must be installed and accessible on the MATLAB path (you can follow my step-by-step guide here.

Next, all the latest deep ConvNet models must be downloaded in the required Caffe format from here. Please note they must be placed inside the default folder of the Caffe installation named ‘models’. The safer option will be to extract the downloaded zip file inside the ‘models’ folder of the Caffe installation.

In addition, the datasets should be downloaded and stored in a directory of your choice. However, We must pay attention to the structure of the folders which will contain the raw jpg images. We will need 4 different folders: (1) positive training; (2) negative training; (3) positive test and (4) negative test. This happens in order to be able to evaluate both processes of training and testing in the end. The complete structure of the folder with the name ‘datasets’ (which needs to be inside the matlab/demo folder) is given by the following example:


Usage & examples

Open Matlab and go to Caffe framework. Then add the current folder and subfolders to path. MatDeepRep must be placed and ran from inside the demo folder which can be located inside matlab folder.

The following command will extract fetrures using the ResNet50 model and FMD dataset for the fabric category:

[code,code_v] = matdeeprep('ReseNet50', 'FMD', 'fabric');

You can modify the command according to your needs in order to learn deep features representations for any given dataset.

The final step would be to evaluate your system by feeding the extracted features to a linear SVM classifier, which is beyond the scope of this repository.


comments powered by Disqus