Mask R-CNN maximum number of detected instances per image.
21 ビュー (過去 30 日間)
古いコメントを表示
Hi, I've been working on the mask r-cnn following the documentation instructions. I've got everything tot work but I stumbled upon a potential library mistake. Let me explain better my situation: I am working on a dataset with ~250 images (split between training and validation) and with just 1 category. Each image might have 40-50 instances up to 600-650 instances.
The problem is this, mask r-cnn can only detect up to 100 instances by class definition. I believe this is hurting the training of the network - however I cannot confirm this because I have to run the training by remote, by command prompt, since I don't have a GPU powerful enough to run the training locally. My evidence is that the network, after the training, performs somewhat well on images with 40-50 instances, while it performs horrible on images with a lot of instances. In fact, when I evaluate my network on the validation set (something that I can do on my own computer), the network outputs at most 100 masks per image.
My "local" fix: I edited the maskrcnn.m file of the library. I went to the directory "C:\Program\Files\MATLAB\R2023b\toolbox\vision\vision\@maskrcnn\maskrcnn.m" and at line 172 of the code, instead of
NumStrongestRegionsPrediction = 100
I put (expecting to not detect more than 800 instances, given my ground truth data)
NumStrongestRegionsPrediction = 800
which fixes my issue at least at validation time. However, since my training is run without this fix and, given my results, I am writing here to ask what I can do about this issue, I am basically certain my code is correct.
Again, all I can observe at training time is the training loss, which converges to a good number, however sometimes it outputs a bigger number, probably because it encounters the batch with the images with a lot of instances - in other words, the network isn't learning enough out of these images and mistakes/training loss.
I can provide more information if needed, however for now I want to keep the post simple.
2 件のコメント
John D'Errico
2024 年 6 月 2 日
It is totally amazing at how often people claim they are certain their code is correct. Surely, nothing you could have done could possibly be wrong? SIGH.
I would point out it is a terribly poor idea to edit supplied code. The rule I have always understood and used is, you change it, you own it. Once you change supplied code, then any problems are now yours.
Anyway, I would suggest you post this as a tech support issue, not Answers. They may have had valid reasons to limit that parameter.
回答 (1 件)
aditi bagora
2024 年 6 月 26 日
Hi Andrea,
I understand that you are trying to detect objects using mask-rcnn and you observed model performing well for smaller instances when compared to larger instances.
The parameter "NumStrongestRegionsPrediction" controls the number of regions with high prediction values to output. Setting it to a value 8x will lead to more instances in the output. It seems that it is solving your issue. But, increasing the value can also increase the number of false positive instances.
I would suggest you to not change the code locally instead use the parameter "threshold". Changing the threshold gives controls over selection of number of instances with a prediction value. Please note setting the threshold to lower values may also lead to false positive detections.
Also, If the model is unable to detect more instances with higher prediction values it is a clear indication that model is unable to learn properly from the training data. In that case, you need to analyse your model, training data and maybe re-train your model.
Hope this helps!
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!