'Error using roialign' when training maskrcnn model

3 views (last 30 days)
When using the trainMaskRCNN() function, I get the error
Warning: Empty Proposals. Skipping training step
Error using roialign
Invalid argument at position 2. Value must not be empty.
Error in maskrcnn/roiAlignPooling (line 19)
outFeatures = roialign(X, squeeze(boxes), poolSize, 'ROIScale', 1);
Error in maskrcnn/forward (line 550)
dlPooled = roiAlignPooling(obj, dlX, dlProposals, obj.PoolSize);
Error in images.dltrain.internal.SerialTrainer>modelGradients (line 133)
[networkOutputs{:},state] = forward(net,inputs{:});
Error in deep.internal.dlfeval (line 17)
[varargout{1:nargout}] = fun(x{:});
Error in dlfeval (line 40)
[varargout{1:nargout}] = deep.internal.dlfeval(fun,varargin{:});
Error in images.dltrain.internal.SerialTrainer/fit (line 76)
[loss,grad,state,networkOutputs,lossData] = dlfeval(@modelGradients,self.Network,self.LossFcn,...
Error in images.dltrain.internal.dltrain (line 102)
net = fit(networkTrainer);
Error in trainMaskRCNN (line 240)
[network,info] = images.dltrain.internal.dltrain(mbqTrain,network,options,lossFcn,metrics,'Loss',
'ExperimentMonitor',params.ExperimentMonitor);
Error in fibers_train (line 86)
[net,info] = trainMaskRCNN(ds,net,options);
Does anyone have any idea of what could be the cause of this, and what I can do about it?
  1 Comment
Hanqing
Hanqing on 4 Oct 2022
Had similar issue with this function and the same a warning before this particular function.
I did not find a way to solve this. But there are some walk around solutions for me to deal with my own problem.
One thing is to change the initial training step to a lower value. Other training parameters like the 'Momentum' should also have some influence on the results.
Then if the training still goes wrong, you can select only part of your training datasets. In my case, some of my samples are more easiler to trigger this problem than the other ones.

Sign in to comment.

Answers (1)

Spruha
Spruha on 23 Apr 2025
Hi David,
I see you are trying to train a Mask R-CNN instance segmentation network using ‘trainMaskRCNN()’ and are encountering the following errors:
  • Warning: Empty Proposals. Skipping training step
  • Invalid argument at position 2. Value must not be empty
This error typically occurs when the region proposal network fails to generate any valid region proposals, resulting in empty proposals during training.
As a workaround, I recommend using 'SOLOv2' instead of Mask R-CNN. 'SOLOv2' provides a more robust solution for instance segmentation, as it does not rely on region proposals. This means you can avoid errors related to empty proposals entirely.
Please refer to this documentation of SOLOv2: https://in.mathworks.com/help/vision/ref/solov2.html
Hope this helps!

Categories

Find more on Recognition, Object Detection, and Semantic Segmentation in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!