File Exchange

image thumbnail

Deep Learning Toolbox Model for ResNet-50 Network

Pretrained Resnet-50 network model for image classification

124 Downloads

Updated 11 Sep 2019

ResNet-50 is a pretrained model that has been trained on a subset of the ImageNet database and that won the ImageNet Large-Scale Visual Recognition Challenge (ILSVRC) competition in 2015. The model is trained on more than a million images, has 177 layers in total, corresponding to a 50 layer residual network, and can classify images into 1000 object categories (e.g. keyboard, mouse, pencil, and many animals).
Opening the resnet50.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 R2017b and beyond.
Usage Example:
% Access the trained model
net = resnet50();
% See details of the architecture
net.Layers
% Read the image to classify
I = imread('peppers.png');
% Adjust size of the image
sz = net.Layers(1).InputSize
I = I(1:sz(1),1:sz(2),1:sz(3));
% Classify the image using Resnet-50
label = classify(net, I)
% Show the image and the classification results
figure
imshow(I)
text(10,20,char(label),'Color','white')

Comments and Ratings (26)

hi, can you show how to calculate the accuracy for an image

It's very well !

Fan Zhang

Any one test it on imagenet validation set? I got 70% accuracy which is about 4-5% lower than keras report of pre-trained resnet50

Lao WuLve

i have download this tool box, how to install for making data set.

Garrick Liu

Hi there, I am currently using this architecture as part of my honours project to segment lungs in chest x-rays. However, a major issue I have now is that the images are of 1092x1920 size where as the ResNet can only take in 224 by 224. Would there be any way to get around with this?

Any help or advice would be very much appreciated!

ranheng ran

Azhar Imran

Azhar Imran

I need this Resnet-50 network for Matlab 2016-b.
Can you please suggest me any solution.

azharimran63@gmail.com

can to please tell me that how i can obtain its layer by layer code?

software

zhangshaungqing Thanks

I used the following code to successfully train the resnet network without the problems mentioned above.
numClasses = numel(categories(imdsTrain.Labels));
lgraph = removeLayers(lgraph, {'fc1000','fc1000_softmax','ClassificationLayer_fc1000'});
newLayers = [
fullyConnectedLayer(numClasses,'Name','fc','WeightLearnRateFactor',10,'BiasLearnRateFactor',10)
softmaxLayer('Name','softmax')
classificationLayer('Name','classoutput')];
lgraph = addLayers(lgraph,newLayers);
lgraph = connectLayers(lgraph,'avg_pool','fc');

Huawei Tian

"I have the problem with the output of layer 12 is incompatible with the input expected by layer 13."

yes. I also have this problem

layersTransfer = net.Layers(1:end-3);
numClasses = numel(categories(trainingImages.Labels))
layers = [
layersTransfer
fullyConnectedLayer(numClasses,'WeightLearnRateFactor',20,'BiasLearnRateFactor',20)
softmaxLayer
classificationLayer];
netTransfer = trainNetwork(trainingImages,layers,options);

von carlos

dont work, ResNet-50 and i had the same problem of layer 12 is incompatible with layer 13

caesar

I had used ResNet-50 and i had the same problem of layer 12 is incompatible with layer 13 when trying o resume training from a saved checked point

"I have the problem with the output of layer 12 is incompatible with the input expected by layer 13."

yes. I also have this problem

Hello,
I am trying to test the resnet 50 on Dataset consist of 1560 images. I have problem with the output of layer 12 is incompatible with the input expected by layer 13.

Any advice on how could I solve this problem is greatly appreciated

Dayou Jiang

NICE JOB!

cui

good!

adel adel

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