yolov3 upsampleLayer problem.

6 views (last 30 days)
SERDAR KIZILKAYA
SERDAR KIZILKAYA on 1 May 2020
Edited: Aasim Khurshid on 9 Feb 2021
I wanna follow "Object Detection Using YOLO v3 Deep Learning example.
But there is not funciton defining "upsampleLayer".
I tried to use "transposedConv2dLayer" with the following specs in the "addSecondDetectionHead.m"
>>>
weights = zeros(2,2,numFilters,numFilters);
bias = zeros(1,1,numFilters);
for i= 1:numFilters
weights(:,:,i,i) = 1;
end
transposedConv2dLayer([2,2],numFilters,'Stride',[2,2],...
'WeightLearnRateFactor',0,'BiasLearnRateFactor',0, 'Name', 'ups_2d', 'Weights', weights, 'Bias',bias );
<<<
But I get the following error:
***
Error using dlfeval (line 43)
Layer 'ups_2d': Invalid input data. Number of channels to convolve (18, specified by the size
of weights dimension number 4) must be equal to the size of the 'C' dimension of the input data
(256).
Any upsamplelayer function working ?
I also want to check each layer input and output size, is there any practical solution ?
  2 Comments
Joon
Joon on 2 May 2020
Edited: Joon on 2 May 2020
I have same problem. I would like to ask to MATHWORKS to upload 'upsampleLayer' function.
Aasim Khurshid
Aasim Khurshid on 9 Feb 2021
Edited: Aasim Khurshid on 9 Feb 2021
This function is part of the example of object detection. You should go to the example in MATLAB (click the "View MATLAB Command" link in the box in the upper-right corner of the example or open it in MATLAB Online by clicking the button in that same box) and you will find that helper in the example's directory. Or you may click on the error, where it says, it is used in object detection example, Click there, Copy this file to your directory, and you are good to go.
Do the same for other missing files as well.
Indicated here for another file:
https://www.mathworks.com/matlabcentral/answers/608676-validateinputdata-in-yolo-v3-missing

Sign in to comment.

Answers (1)

SERDAR KIZILKAYA
SERDAR KIZILKAYA on 6 May 2020
Function is built in Matlab/examples, also given below:
% Upsample by replicating neighbouring pixel values.
% Copyright 2019 The MathWorks, Inc.
classdef upsampleLayer < nnet.layer.Layer
properties
% factor to upsample the input.
UpSampleFactor
end
methods
function layer = upsampleLayer(factor, name)
% Set layer name.
layer.Name = name;
% Set layer description.
layer.Description = "upSamplingLayer with factor " + factor;
% Stride by which layer is upsampled.
layer.UpSampleFactor = factor;
end
function Z = predict(layer, X)
% Z = predict(layer, X) forwards the input data X through the
% layer and outputs the result Z.
Z = repelem(X,layer.UpSampleFactor,layer.UpSampleFactor);
end
end
end
  4 Comments
Joon
Joon on 29 Jul 2020
Thanks! I just gave up and have been using Yolov2 instead. But it is working after I installed 2020a as you suggested. Cool!
Joon-Hyuk Lee
Joon-Hyuk Lee on 29 Jul 2020
Edited: Joon-Hyuk Lee on 29 Jul 2020
I got another problem during the training. The value of bboxA (which is the predicted box, not truth box) seems to have infinite(?) value. Anyone had same problem before?
Error messages are here:=====================================
Error using bboxOverlapRatio
The value of 'bboxA' is invalid. Expected input to be finite.
Error in bboxOverlapRatio>validateAndParseInputs (line 195)
parser.parse(bboxA,bboxB,varargin{:});
Error in bboxOverlapRatio>iParseInputs (line 94)
[bboxA, bboxB, ratioType] = validateAndParseInputs(bboxA, bboxB, varargin{:});
Error in bboxOverlapRatio (line 55)
[bboxA, bboxB, ratioType, isUsingCodeGeneration] = iParseInputs(bboxA,bboxB,varargin{:});
Error in generateTargets>getMaxIOUPredictedWithGroundTruth (line 138)
overlap = bboxOverlapRatio(predb,truthBatch);
Error in generateTargets (line 45)
iou = getMaxIOUPredictedWithGroundTruth(bx,by,bw,bh,groundTruth);
Error in yolov3>modelGradients (line 354)
[boxTarget, objectnessTarget, classTarget, objectMaskTarget, boxErrorScale] = generateTargets(gatheredPredictions, YTrain, inputImageSize, anchors, mask, penaltyThreshold);
Error in deep.internal.dlfeval (line 18)
[varargout{1:nout}] = fun(x{:});
Error in dlfeval (line 41)
[varargout{1:nout}] = deep.internal.dlfeval(fun,varargin{:});
==================================================

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!