-
Notifications
You must be signed in to change notification settings - Fork 609
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add option to prune bboxes based on % area in Crop ROI #5368
Conversation
false); | ||
false) | ||
.AddOptionalArg<float>("bbox_prune", | ||
R"code(Controls how bboxes are pruned from the ROI. Valid values of `bbox_prune` are `-1.f` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about instead of using -1
as an off value, call ArgumentDefined
to learn if the argument was used at all?
Hi @5had3z, Thank you for your contribution. Let us check it and share our comments with you soon. |
Hi @5had3z. Thanks a lot for your contribution. I took the liberty to propose some changes to the API, which I put in a PR to this branch: 5had3z#1 The change is to separate the two filtering methods with |
Hi @jantonguirao, I prefer @JanuszL's suggestion for testing the presence of a Two Args # No args, Prune by centroid - OK
outputs= fn.random_bbox_crop(*args)
# Specify threshold, dominated by centroid pruning - OOPS
outputs = fn.random_bbox_crop(*args, bbox_prune_area_threshold=0.1)
# Both Args, Prune by area - OK
outputs = fn.random_bbox_crop(*args, bbox_prune_area_threshold=0.1, bbox_prune_by_centroid=False) Testing for Presence of area # No args, Prune by centroid - OK
outputs= fn.random_bbox_crop(*args)
# Specify threshold, Prune by area - OK
outputs = fn.random_bbox_crop(*args, bbox_prune_area_threshold=0.1) |
Sure, that works as well. Let's just avoid the magic value for the default behaviour and explicitly check if the argument was provided or not. |
Ironically the "meta-test" of my python intersection function was the problem that had me the most stuck. Accidentially had |
Signed-off-by: Bryce Ferenczi <frenzi@hotmail.com.au>
Signed-off-by: Bryce Ferenczi <frenzi@hotmail.com.au>
…te docs. Signed-off-by: Bryce Ferenczi <frenzi@hotmail.com.au>
…ools.product, remove mutable defaults from SynthDataPipeline and make keyword only (original default placed in appropriate areas). Signed-off-by: Bryce Ferenczi <frenzi@hotmail.com.au>
Signed-off-by: Bryce Ferenczi <frenzi@hotmail.com.au>
Co-authored-by: Janusz Lisiecki <39967756+JanuszL@users.noreply.github.com> Signed-off-by: Bryce Ferenczi <frenzi@hotmail.com.au>
…ling underscores from local lambda vars. Signed-off-by: Bryce Ferenczi <frenzi@hotmail.com.au>
for i, bbox in enumerate(bboxes): | ||
intersec = intersection(bbox, crop_box) | ||
box_area = np.prod(bbox[ndim:] - bbox[:ndim]) | ||
if intersec / box_area > thresh: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if intersec / box_area > thresh: | |
if intersec / box_area >= thresh: |
I guess the tests need to be updated as well.
….0 to test parameterization, 1.0 has freezing issues in the test, but works as expected on normal datasets... Signed-off-by: Bryce Ferenczi <frenzi@hotmail.com.au>
Signed-off-by: Bryce Ferenczi <frenzi@hotmail.com.au>
!build |
CI MESSAGE: [13523046]: BUILD STARTED |
CI MESSAGE: [13523046]: BUILD PASSED |
Category:
New feature
Description:
Following on #5366, I made some modifications to RandomBBoxCropImpl to enable pruning bboxes based on their remaining area within the ROI, while leaving the option to use the original centroid algorithm (which is currently default). This simply finds the intersection between the crop and bbox and divides this by the bbox area. The bbox is kept if this result is above a threshold.
Some results of this change are also shown in the aforementioned thread.
Additional information:
Affected modules and functionalities:
Added new argument to
random_bbox_crop
, namelybbox_prune
, which is a float that signals to use the old algorithm (by default), or the new algorithm.Key points relevant for the review:
Naming things is a difficult part of CS, I just copied my original "one new parameter" implementation that has overloaded functionality. We can change it to a string to signal which algoirthm, and add another parameter for the threshold tolerance. Always better to have more than one opinion on API design.
Tests:
I intend to add some more tests to
operator_2/test_random_bbox_crop.py
.Checklist
Documentation
DALI team only
Requirements
REQ IDs: N/A
JIRA TASK: N/A