yolov3 upsampleLayer problem.

1 次查看(过去 30 天)
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 个评论
Joon
Joon 2020-5-2
编辑:Joon 2020-5-2
I have same problem. I would like to ask to MATHWORKS to upload 'upsampleLayer' function.
Aasim Khurshid
Aasim Khurshid 2021-2-9
编辑:Aasim Khurshid 2021-2-9
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

请先登录,再进行评论。

回答(1 个)

SERDAR KIZILKAYA
SERDAR KIZILKAYA 2020-5-6
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 个评论
Joon
Joon 2020-7-29
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 2020-7-29
编辑:Joon-Hyuk Lee 2020-7-29
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{:});
==================================================

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Classification 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by