Skip to content
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

Equalization operator #4575

Merged
merged 2 commits into from
Jan 20, 2023
Merged

Equalization operator #4575

merged 2 commits into from
Jan 20, 2023

Conversation

stiepan
Copy link
Member

@stiepan stiepan commented Jan 16, 2023

Signed-off-by: Kamil Tokarski ktokarski@nvidia.com

Category:

New feature (non-breaking change which adds functionality)

Description:

Adds per-channel histogram equalization operator (GPU, uint8_t).

Additional information:

Uses kernels added in the #4565

It is needed to implement the standard RandAugment/AutoAugment policies.

Affected modules and functionalities:

Key points relevant for the review:

Tests:

  • Existing tests apply
  • New tests added
    • Python tests
    • GTests
    • Benchmark
    • Other
  • N/A

Checklist

Documentation

  • Existing documentation applies
  • Documentation updated
    • Docstring
    • Doxygen
    • RST
    • Jupyter
    • Other
  • N/A

DALI team only

Requirements

  • Implements new requirements
  • Affects existing requirements
  • N/A

REQ IDs: N/A

JIRA TASK: DALI-3187

@stiepan stiepan force-pushed the equalize_operator branch 2 times, most recently from ae107e5 to 4551a07 Compare January 18, 2023 10:56
@stiepan stiepan marked this pull request as ready for review January 18, 2023 10:57
assert(layout.size() == 2 || layout.size() == 3);
output.SetLayout(layout);
kernels::DynamicScratchpad scratchpad({}, AccessOrder(ws.stream()));
ctx_.gpu.stream = ws.stream();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ctx should be a local variable - you populate all of its fields anyway.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

imgs = [np.array(img) for img in imgs.as_cpu()]
assert len(equalized) == len(imgs)
baseline = [equalize_cv_baseline(img, layout) for img in imgs]
check_batch(equalized, baseline)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we expect bit-exactness with OpenCV?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As discussed elsewhere, the algorithm is the same, the only float arithmetic is scaling of the comulative. It happens to work, let us see if the CI does not complain.

template <int ndim>
TensorListShape<2> GetFlattenedShape(TensorListShape<ndim> shape) {
if (shape.sample_dim() == 3) { // has_channels
return collapse_dims<2>(shape, {{0, shape.sample_dim() - 1}});
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The layout can be HWC and CHW, doesn't it impact anything here?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SequenceOperator handles the latter

Signed-off-by: Kamil Tokarski <ktokarski@nvidia.com>
Signed-off-by: Kamil Tokarski <ktokarski@nvidia.com>
@dali-automaton
Copy link
Collaborator

CI MESSAGE: [7059662]: BUILD STARTED

@dali-automaton
Copy link
Collaborator

CI MESSAGE: [7059662]: BUILD PASSED

@stiepan stiepan merged commit a406e41 into NVIDIA:main Jan 20, 2023
aderylo pushed a commit to zpp-dali-2022/DALI that referenced this pull request Mar 17, 2023
Signed-off-by: Kamil Tokarski <ktokarski@nvidia.com>
@JanuszL JanuszL mentioned this pull request Sep 6, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants