-
Notifications
You must be signed in to change notification settings - Fork 610
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
RandomBBoxCrop to optionally output the indices of the bounding boxes that passed the centroid filter #2374
RandomBBoxCrop to optionally output the indices of the bounding boxes that passed the centroid filter #2374
Conversation
… that passed the centroid filter Signed-off-by: Joaquin Anton <janton@nvidia.com>
const auto &labels_in = ws.Input<CPUBackend>(1); | ||
auto &labels_out = ws.Output<CPUBackend>(next_out_idx++); | ||
labels_out.Resize({static_cast<Index>(prospective_crop.bbox_indices.size()), 1}); | ||
int64_t i = 0; |
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.
Unused
Can you add a test to check if the 4th output is provided and is a subset of id returned by the coco reader? Edit |
Signed-off-by: Joaquin Anton <janton@nvidia.com>
@@ -323,7 +332,13 @@ The values are: | |||
.. note:: | |||
If left empty, depending on the number of dimensions ``"WH"`` or ``"WHD"`` will be assumed. | |||
)code", | |||
TensorLayout{""}); | |||
TensorLayout{""}) |
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.
TensorLayout{""}) | |
TensorLayout{}) |
TensorLayout{""}) | ||
.AddOptionalArg<bool>( | ||
"output_bbox_indices", | ||
R"code(If set to True, an extra output ``bbox_indices`` will be returned, containing |
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.
R"code(If set to True, an extra output ``bbox_indices`` will be returned, containing | |
R"code(If set to True, an extra output will be returned, containing |
I don't we have named outputs.
@@ -529,20 +546,21 @@ class RandomBBoxCropImpl : public OpImplBase<CPUBackend> { | |||
bool success = false; | |||
Box<ndim, float> crop{}; | |||
std::vector<Box<ndim, float>> boxes; | |||
std::vector<int> labels; | |||
SmallVector<int, 128> bbox_indices; |
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.
I think that's a bit too big an object - perhaps it should be a regular vector instead or at the very least we should be much more conservative wrt static size (8-16, not 128).
bool has_labels) | ||
: success(success), crop(crop) { | ||
assert(boxes_data.size() == labels_data.size() || !has_labels); | ||
SmallVector<int, 128> indices = {}) |
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.
Passing a small vector by value is not a good idea.
47ff204
to
47f768a
Compare
Signed-off-by: Joaquin Anton <janton@nvidia.com>
47f768a
to
0a46f46
Compare
for (int sample_idx = 0; sample_idx < num_samples; sample_idx++) { | ||
const auto &prospective_crop = sample_data_[sample_idx].prospective_crop; | ||
auto extent = prospective_crop.crop.extent(); | ||
auto anchor_out_view = view<float>(anchor_out[sample_idx]); |
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.
Get a view to whole anchor/shape TLV outside the loop?
auto &bbox_out = ws.template OutputRef<CPUBackend>(2); | ||
bbox_out.Resize(bbox_out_shape); | ||
for (int sample_idx = 0; sample_idx < num_samples; sample_idx++) { | ||
auto bbox_out_view = view<float>(bbox_out[sample_idx]); |
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.
Likewise - get a view outside of the loop?
auto labels_in_view = view<const int>(labels_in[sample_idx]); | ||
auto labels_out_view = view<int>(labels_out[sample_idx]); |
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.
...and again.
} | ||
bbox_indices_out.Resize(bbox_indices_out_shape); | ||
for (int sample_idx = 0; sample_idx < num_samples; sample_idx++) { | ||
auto bbox_indices_out_view = view<int>(bbox_indices_out[sample_idx]); |
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.
...and once more.
for (int sample_idx = 0; sample_idx < num_samples; sample_idx++) { | ||
auto &data = sample_data_[sample_idx]; | ||
tp.AddWork([&, sample_idx](int thread_id) { | ||
auto in_boxes_view = view<const float>(in_boxes[sample_idx]); |
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.
Get a view to entire batch outside of the loop.
e4e0c8d
to
3686518
Compare
Signed-off-by: Joaquin Anton <janton@nvidia.com>
3686518
to
763cd87
Compare
!build |
CI MESSAGE: [1717854]: BUILD STARTED |
CI MESSAGE: [1717854]: BUILD FAILED |
293d361
to
19518d5
Compare
!build |
CI MESSAGE: [1719715]: BUILD STARTED |
Signed-off-by: Joaquin Anton <janton@nvidia.com>
19518d5
to
3ab7730
Compare
!build |
CI MESSAGE: [1719811]: BUILD STARTED |
CI MESSAGE: [1719811]: BUILD PASSED |
Signed-off-by: Joaquin Anton janton@nvidia.com
Why we need this PR?
What happened in this PR?
Fill relevant points, put NA otherwise. Replace anything inside []
Added an optional output to RandomBBoxCrop with the indices of the filtered bounding boxes, so that it can be used to select the relevant masks associated with those (in a different operator)
RandomBBoxCrop
All
Existing tests
Docstr updated
JIRA TASK: [DALI-1633]