MATLAB Answers

dlnetwork error running YOLO v3 example

2 views (last 30 days)
RonE
RonE on 23 Apr 2021
I am getting the following error running this YOLO v3 deep learning example:
https://www.mathworks.com/help/vision/ug/object-detection-using-yolo-v3-deep-learning.html
Error using dlnetwork (line 117)
Invalid network.
Caused by:
Layer 'depthConcat1Detection2': Input size mismatch. Size of input to this layer is different from the expected input size.
Inputs to this layer:
from layer 'upsample1Detection2' (output size 24×254×256)
from layer 'fire5-concat' (output size 24×255×256)
I don't know where the sizes 24x254x256 and 24x255x256 are coming from.
I copied the code from:
C:\Users\xxxxx\Documents\MATLAB\Examples\R2020b\deeplearning_shared\ObjectDetectionUsingYOLOV3DeepLearningExample
and am running ObjectDetectionUsingYOLOV3DeepLearningExample.mlx, which is very similar to that web page above, but unfortunately some key parts are different. The web page is missing the line that is crashing for me. I have the following under "Define YOLO v3 Network":
rng(0)
trainingDataForEstimation = transform(trainingData, @(data)preprocessData(data, networkInputSize));
numAnchors = 6;
[anchorBoxes, meanIoU] = estimateAnchorBoxes(trainingDataForEstimation, numAnchors)
area = anchorBoxes(:, 1).*anchorBoxes(:, 2);
[~, idx] = sort(area, 'descend');
anchorBoxes = anchorBoxes(idx, :);
anchorBoxMasks = {[1,2,3]
[4,5,6]
};
baseNetwork = squeezenet;
lgraph = squeezenetFeatureExtractor(baseNetwork, networkInputSize);
classNames = {'boat'};
numClasses = size(classNames, 2);
numPredictorsPerAnchor = 5 + numClasses;
lgraph = addFirstDetectionHead(lgraph, anchorBoxMasks{1}, numPredictorsPerAnchor);
lgraph = addSecondDetectionHead(lgraph, anchorBoxMasks{2}, numPredictorsPerAnchor);
lgraph = connectLayers(lgraph, 'fire9-concat', 'conv1Detection1');
lgraph = connectLayers(lgraph, 'relu1Detection1', 'upsample1Detection2');
lgraph = connectLayers(lgraph, 'fire5-concat', 'depthConcat1Detection2/in2');
networkOutputs = ["conv2Detection1"
"conv2Detection2"
];
...
if doTraining
% Convert layer graph to dlnetwork.
net = dlnetwork(lgraph); %############ THIS LINE IS CRASHING
% Create subplots for the learning rate and mini-batch loss.
fig = figure;
[lossPlotter, learningRatePlotter] = configureTrainingProgressPlotter(fig);
iteration = 0;
% Custom training loop.
for epoch = 1:numEpochs
...
I have created my own ground truth data.
I have set networkInputSize = [200 2048 3]; since that is the size of my input images.
Thanks for any ideas.

Answers (0)

Products


Release

R2020b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!