How does the OverlapThreshold argument in balanceBoxLabels get passed along to the resulting blockLocationSet?
Ältere Kommentare anzeigen
If balanceBoxLabels simply creates a blockLocationSet ("bSet"), how exactly does the OverlapThreshold argument/value specified in balanceBoxLabels get 'passed along' to the subsequent step of creating a boxLabelDatastore ("blds") based on the blockLocationSet, given that a blockLocationSet only contains the properties (1) Image number(s), (2) Block origin(s), (3) Block size and (4) Resolution level(s)?
For example, if I do:
bSet = balanceBoxLabels(boxLabels,blockedImages,blockSize,numObservations,OverlapThreshold=0.5)
This is supposed to specify that any bounding box that partially overlaps a block by >50% of the bounding box's size gets cropped to the block boundary, while any bounding box that partially overlaps a block by <50% of the bounding box's size gets discarded. So far, so good. But then when I do:
blds = boxLabelDatastore(boxLabels,bSet)
How does the OverlapThreshold value of 0.5 specified when creating "bSet" using BalanceBoxLabels get passed along to the creation of "blds" using boxLabelDatastore?
1 Kommentar
Dominique
am 6 Mai 2024
Antworten (1)
Aneela
am 22 Mai 2024
Hi Dominique,
The “boxLocationSet”, “bSet”, resulting from the “balanceBoxLabels” does not explicitly carry the “OvelapThreshold” as one of its properties.
When the “OverlapThreshold” in “balanceBoxLabels” is specified, the function uses this threshold to decide which bounding boxes to include or exclude in each block.
bSet = balanceBoxLabels(boxLabels,blockedImages,blockSize, numObservations,OverlapThreshold=0.5);
- This decision-making and adjustment process happens during the execution of “balanceBoxLabels”.
- The outcome is a “boxLocationSet” object, “bSet”, that contains information about Image numbers, block origins, block sizes, and the information about which bounding boxes to include.
When a “boxLabelDatastore” is created using:
blds = boxLabelDatastore(boxLabels,bSet);
- The “bSet” already incorporates the effects of the “OverlapThreshold” through its content, which blocks were created and which bounding boxes they include.
- The “boxLabelDatastore” function then uses this information to create a datastore of the cropped images and their corresponding adjusted bounding boxes.
For more information on “balanceBoxLabels”, refer to the following MathWorks documentation: https://www.mathworks.com/help/vision/ref/balanceboxlabels.html
4 Kommentare
Corey Kurowski
am 23 Mai 2024
Hey Dominique,
What you stated here is correct. The algorithm for balanceBoxLabels uses a weighted sampling based on the class's overall representation in the dataset. So for a series of blockedImages, with a specified block size, the algorithm will prioritize grabbing image blocks (with minor x/y shifts) that contain the least represented class. It will do this until the precalculated quota is met [based on total number of observations] - taking into account the overlap threshold. The algorithm only cares if at least one object from the given class is contained within the image block [and checks if the overlap threshold is met with that object]. All other bounding boxes in that image block are lower priority and may be cropped if they fall on the image block boundary. This process is repeated with the second least represented class and so forth.
The intent of the function is to bring forth as many under-represented classes as possible to "balance" the dataset, but it is not a perfect solution since very under-represented classes will be balanced to merely be slightly shifted versions of the original tiles. This algorithm serves us well when then is a slight under-representation, but when it is ~1:10 or so, it really starts to fail a bit.
When it comes to blockedImage processing, it can be beneficial to have partial objects on the image block bounds, as unless all images are uniform in size and careful calculation is made to include only full objects, a detector is likely to encounter similar partial objects at inference time. This is one of the reasons why we do not automatically discard those cropped boxes.
With that being said, it would be great to understand what parts of the documentation are unclear to you regarding this function, and we can use that feedback to improve clarity.
As an offshoot, please see the following example for a more custom design of detecting objects in an image block: https://www.mathworks.com/help/vision/ug/object-detection-in-large-satellite-imagery-using-deep-learning.html
Dominique
am 24 Mai 2024
Corey Kurowski
am 30 Mai 2024
Hey Dominique,
Thanks for this feedback. Both of your noted additional functionalities are definitely something for us to consider in near future releases to help with a more robust deep learning training workflow. While we will likely keep balanceBoxLabels as a dedicated function, we may very well introduce additional functions that can assist in each of these cases.
Kategorien
Mehr zu Get Started with Computer Vision Toolbox finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!