-
Notifications
You must be signed in to change notification settings - Fork 629
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 debayer operator #4495
Add debayer operator #4495
Conversation
Signed-off-by: Kamil Tokarski <ktokarski@nvidia.com> Add docs Signed-off-by: Kamil Tokarski <ktokarski@nvidia.com> NPP baseline tests Signed-off-by: Kamil Tokarski <ktokarski@nvidia.com> Fix lint issues Signed-off-by: Kamil Tokarski <ktokarski@nvidia.com> Better algorithm description in the docs Signed-off-by: Kamil Tokarski <ktokarski@nvidia.com> Revert formatting in npp helper filer Signed-off-by: Kamil Tokarski <ktokarski@nvidia.com> Add debayer calls to stub generator Signed-off-by: Kamil Tokarski <ktokarski@nvidia.com> Include uin16_t tests Signed-off-by: Kamil Tokarski <ktokarski@nvidia.com> Test single-channel 3dim inputs, adjust error messages, prepare seq baseline Signed-off-by: Kamil Tokarski <ktokarski@nvidia.com> Read video helper Signed-off-by: Kamil Tokarski <ktokarski@nvidia.com> Use pair of ints instead of enum, add cpp tests Signed-off-by: Kamil Tokarski <ktokarski@nvidia.com> Simplfy the tests sligthly Signed-off-by: Kamil Tokarski <ktokarski@nvidia.com>
Signed-off-by: Kamil Tokarski <ktokarski@nvidia.com>
Signed-off-by: Kamil Tokarski <ktokarski@nvidia.com>
!build |
CI MESSAGE: [6685417]: BUILD STARTED |
CI MESSAGE: [6685417]: BUILD FAILED |
Signed-off-by: Kamil Tokarski <ktokarski@nvidia.com>
!build |
CI MESSAGE: [6692025]: BUILD STARTED |
Signed-off-by: Kamil Tokarski <ktokarski@nvidia.com>
!build |
CI MESSAGE: [6694079]: BUILD STARTED |
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.
Still reading tests, comments for implementation
dali/operators/image/color/debayer.h
Outdated
constexpr static const char *algArgName = "algorithm"; | ||
constexpr static const char *bluePosArgName = "blue_position"; |
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.
constexpr static const char *algArgName = "algorithm"; | |
constexpr static const char *bluePosArgName = "blue_position"; | |
constexpr static const char *kAlgArgName = "algorithm"; | |
constexpr static const char *kBluePosArgName = "blue_position"; |
I think this k
is required by the coding guide. I am also never sure if it's better to use those constants or maybe just stick with strings. I was thinking about alternative once, but didn't find anything that would allow to have both validation and not introduce need for additional definitions or obfuscation.
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.
done
sample_idx, " has shape ", input_shapes[sample_idx], | ||
", which, assuming HWC layout, implies ", num_channels, " channels. ", | ||
"If you are trying to process video or sequences, please make sure to set " | ||
"input's layout to `FHW`. You can use `fn.reshape` to set proper layout.")); |
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.
Can we do it without assumptions, just check what is the layout and error out accordingly?
Btw, can we access the original layout in Sequence Operator?
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 you don't provide any layout but pass 3d tensor in hope of processing sequence of bayered images, you likely will fail here. This is for such a situation. There layout won't tell us much.
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.
As to the SequenceOperator, kind of. You have original layouts in ShouldExpand(ws) overrides, the idea was that if you'd like to report layout to the user, you can do that there and then forget about it. There is also IsExpanding() method to tell if that's the sequence case or not.
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.
Oh, this kinda boils down to the fact, that we don't know if we were running with empty layout if executor set it to a default.
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.
Yeah
dali/operators/image/color/debayer.h
Outdated
blue_position.size(), " values.")); | ||
int y = blue_position[0]; | ||
int x = blue_position[1]; | ||
int bayer_enum_val = 2 * y + x; |
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.
Hmm, (-2, 4) would work fine.
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.
Yeah, the current check is a bit liberal, just to prevent "overflowing" the enum. Do you think we need the strict version to check it elementwise?
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 so, it's easier to go in the other direction later.
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.
done
dali/operators/image/color/debayer.h
Outdated
pattern_.resize(batch_size, static_pattern_); | ||
} else { | ||
const auto &tv = ws.ArgumentInput(debayer::bluePosArgName); | ||
auto blue_positions_view = view<const int, 1>(tv); |
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.
Just checking, I think we have something that asserts dimensionality here, so it would error out with a bit of a cryptic message, if the user provides us with for example 2D-input. And we don't strictly require 1D data, just two elements exactly?
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.
Yep, we require two elements. And the message will be cryptic. So your suggestion is to go with dynamic extent and simply .num_elements() == 2?
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.
This is one solution if you want to be more flexible.
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.
done
Signed-off-by: Kamil Tokarski <ktokarski@nvidia.com>
CI MESSAGE: [6692025]: BUILD FAILED |
…equiresemnts for the tensor input Signed-off-by: Kamil Tokarski <ktokarski@nvidia.com>
Signed-off-by: Kamil Tokarski <ktokarski@nvidia.com>
CI MESSAGE: [6694079]: BUILD PASSED |
!build |
CI MESSAGE: [6704750]: BUILD STARTED |
CI MESSAGE: [6704750]: BUILD PASSED |
return view<const InOutT, 2>(input); | ||
} | ||
assert(([&]() { | ||
for (int sample_idx = 0; sample_idx < in_shape.num_samples(); 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.
assert(std::all_of(in_shape.begin(), in_shape.end(), [](auto &shape) { return shape[2] == 1; }));
nitpick
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.
Unfortunately, AFAIK, there is no begin/end in neither TL nor TLS class.
Add debayer operator
Signed-off-by: Kamil Tokarski ktokarski@nvidia.com
Category:
New feature (non-breaking change which adds functionality)
Description:
Additional information:
Affected modules and functionalities:
Key points relevant for the review:
Around 70% of this PR are tests and documentation. It is a small PR. :)
Tests:
Checklist
Documentation
DALI team only
Requirements
REQ IDs: DEBAYER.02, 03, 04, 07, 08, 09, 11, 12, 13.
JIRA TASK: DALI-3075