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

Adds video support to color based augmentations #3580

Merged
merged 13 commits into from
Jan 4, 2022

Conversation

JanuszL
Copy link
Contributor

@JanuszL JanuszL commented Dec 17, 2021

  • extends brightness_contrast operator family to support sequences
  • extends color_twist operator family to support sequences
  • removes old_color_twist operator
  • makes Yiq2Rgb a runtime computed inversion of the Rgb2Yiq matrix in the color twist operator

Signed-off-by: Janusz Lisiecki jlisiecki@nvidia.com

Description

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Refactoring (Redesign of existing code that doesn't affect functionality)
  • Other (e.g. Documentation, Tests, Configuration)

What happened in this PR

Additional information

  • Affected modules and functionalities:
    • brightness_contrast
    • color_twist
    • old_color_twist
  • Key points relevant for the review:
    • NA

Checklist

Tests

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

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: CTSTOPS.04, BRICON.05

JIRA TASK: DALI-2509

@JanuszL JanuszL marked this pull request as draft December 17, 2021 14:07
Comment on lines 65 to 67
int num_channels = in.shape[2];
int image_width = in.shape[1];
int image_hight = in.shape[0];
Copy link
Contributor

@mzient mzient Dec 17, 2021

Choose a reason for hiding this comment

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

Suggested change
int num_channels = in.shape[2];
int image_width = in.shape[1];
int image_hight = in.shape[0];
int num_channels = in.shape[ndims-1];
int image_width = in.shape[ndims-2];
int image_height = in.shape[ndims-3];

Comment on lines 71 to 73
num_channels = in.shape[3];
image_width = in.shape[2];
image_hight = in.shape[1];
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
num_channels = in.shape[3];
image_width = in.shape[2];
image_hight = in.shape[1];

num_channels = in.shape[3];
image_width = in.shape[2];
image_hight = in.shape[1];
// wer cannot use .z as it is field, [] is resolved in the runtime
Copy link
Contributor

Choose a reason for hiding this comment

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

In principle, unless we include this file in a .cu unit, we could use .z.

Comment on lines 82 to 89
auto *row = in.data + adjusted_roi.lo.y * row_stride + img_start * row_stride * image_hight;
for (int z = img_start; z < img_end; z++) {
for (int y = adjusted_roi.lo.y; y < adjusted_roi.hi.y; y++) {
for (int xc = adjusted_roi.lo.x * num_channels; xc < adjusted_roi.hi.x * num_channels; xc++)
*ptr++ = ConvertSat<OutputType>(row[xc] * multiplier + addend);
row += row_stride;
}
row += img_stride;
Copy link
Contributor

@mzient mzient Dec 17, 2021

Choose a reason for hiding this comment

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

Suggested change
auto *row = in.data + adjusted_roi.lo.y * row_stride + img_start * row_stride * image_hight;
for (int z = img_start; z < img_end; z++) {
for (int y = adjusted_roi.lo.y; y < adjusted_roi.hi.y; y++) {
for (int xc = adjusted_roi.lo.x * num_channels; xc < adjusted_roi.hi.x * num_channels; xc++)
*ptr++ = ConvertSat<OutputType>(row[xc] * multiplier + addend);
row += row_stride;
}
row += img_stride;
auto *img = in.data + adjusted_roi.lo.y * row_stride + img_start * row_stride * image_hight;
for (int z = img_start; z < img_end; z++) {
auto *row = img;
for (int y = adjusted_roi.lo.y; y < adjusted_roi.hi.y; y++) {
for (int xc = adjusted_roi.lo.x * num_channels; xc < adjusted_roi.hi.x * num_channels; xc++)
*ptr++ = ConvertSat<OutputType>(row[xc] * multiplier + addend);
row += row_stride;
}
img += img_stride;

batch_size=32
n_iters = 8
ri1 = RandomDataIterator(batch_size, shape=(128, 32, 3), dtype=dali_type_to_np(inp_dtype))
ri2 = RandomDataIterator(batch_size, shape=(128, 32, 3), dtype=dali_type_to_np(inp_dtype))
shape = (128, 32, 3) if not is_video else (random.randint(2-5), 128, 32, 3)
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
shape = (128, 32, 3) if not is_video else (random.randint(2-5), 128, 32, 3)
shape = (128, 32, 3) if not is_video else (random.randint(2, 5), 128, 32, 3)

using Kernel = TheKernel<OutputType, InputType>;
TensorListShape<> sh = input.shape();
auto num_dims = sh.sample_dim();
int frame_num = num_dims == 3 ? 1 : sh[0][0];
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
int frame_num = num_dims == 3 ? 1 : sh[0][0];
int num_frames = num_dims == 3 ? 1 : sh[0][0];

frame_num reads too much as "frame number" which is ambiguous

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

brightness_[sample_id],
brightness_shift_[sample_id],
contrast_[sample_id]);
kernel_manager_.Run<Kernel>(thread_id, sample_id, ctx, tvout, tvin,
Copy link
Contributor

Choose a reason for hiding this comment

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

Technically, this is wrong. Now we've multipled the number of samples, so it's sum(num_frames[i] for i in range(num_samples). Since the kernel is stateless, we can stop pretending that there are multiple samples and just pass 0 as sample_id all the time. It will be less confusing.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

@JanuszL JanuszL force-pushed the video_contrast branch 3 times, most recently from 25db40d to 0e0d2a7 Compare December 18, 2021 02:59
@JanuszL
Copy link
Contributor Author

JanuszL commented Dec 18, 2021

!build

@dali-automaton
Copy link
Collaborator

CI MESSAGE: [3617555]: BUILD STARTED

@dali-automaton
Copy link
Collaborator

CI MESSAGE: [3617555]: BUILD FAILED

@JanuszL
Copy link
Contributor Author

JanuszL commented Dec 18, 2021

!build

@dali-automaton
Copy link
Collaborator

CI MESSAGE: [3617736]: BUILD STARTED

@dali-automaton
Copy link
Collaborator

CI MESSAGE: [3617736]: BUILD FAILED

@JanuszL JanuszL force-pushed the video_contrast branch 2 times, most recently from 07da4fd to b963aae Compare December 20, 2021 18:21
- extends brightness_contrast operator family
- extends hue operator

Signed-off-by: Janusz Lisiecki <jlisiecki@nvidia.com>
Signed-off-by: Janusz Lisiecki <jlisiecki@nvidia.com>
Signed-off-by: Janusz Lisiecki <jlisiecki@nvidia.com>
Signed-off-by: Janusz Lisiecki <jlisiecki@nvidia.com>
Signed-off-by: Janusz Lisiecki <jlisiecki@nvidia.com>
Signed-off-by: Janusz Lisiecki <jlisiecki@nvidia.com>
Signed-off-by: Janusz Lisiecki <jlisiecki@nvidia.com>
Signed-off-by: Joaquin Anton <janton@nvidia.com>
@jantonguirao
Copy link
Contributor

!build

@dali-automaton
Copy link
Collaborator

CI MESSAGE: [3694441]: BUILD STARTED

@dali-automaton
Copy link
Collaborator

CI MESSAGE: [3694441]: BUILD FAILED

Signed-off-by: Joaquin Anton <janton@nvidia.com>
@jantonguirao
Copy link
Contributor

!build

@dali-automaton
Copy link
Collaborator

CI MESSAGE: [3694673]: BUILD STARTED

@dali-automaton
Copy link
Collaborator

CI MESSAGE: [3694673]: BUILD FAILED

Signed-off-by: Joaquin Anton <janton@nvidia.com>
@jantonguirao
Copy link
Contributor

!build

@dali-automaton
Copy link
Collaborator

CI MESSAGE: [3694778]: BUILD STARTED

@dali-automaton
Copy link
Collaborator

CI MESSAGE: [3694778]: BUILD PASSED

@jantonguirao jantonguirao merged commit c4c2e32 into NVIDIA:main Jan 4, 2022
cyyever pushed a commit to cyyever/DALI that referenced this pull request Jan 23, 2022
Signed-off-by: Janusz Lisiecki <jlisiecki@nvidia.com>
Co-authored-by: Joaquin Anton <janton@nvidia.com>
cyyever pushed a commit to cyyever/DALI that referenced this pull request Jan 23, 2022
Signed-off-by: Janusz Lisiecki <jlisiecki@nvidia.com>
Co-authored-by: Joaquin Anton <janton@nvidia.com>
cyyever pushed a commit to cyyever/DALI that referenced this pull request Jan 23, 2022
Signed-off-by: Janusz Lisiecki <jlisiecki@nvidia.com>
Co-authored-by: Joaquin Anton <janton@nvidia.com>
cyyever pushed a commit to cyyever/DALI that referenced this pull request Jan 23, 2022
Signed-off-by: Janusz Lisiecki <jlisiecki@nvidia.com>
Co-authored-by: Joaquin Anton <janton@nvidia.com>
cyyever pushed a commit to cyyever/DALI that referenced this pull request Jan 23, 2022
Signed-off-by: Janusz Lisiecki <jlisiecki@nvidia.com>
Co-authored-by: Joaquin Anton <janton@nvidia.com>
cyyever pushed a commit to cyyever/DALI that referenced this pull request Jan 23, 2022
Signed-off-by: Janusz Lisiecki <jlisiecki@nvidia.com>
Co-authored-by: Joaquin Anton <janton@nvidia.com>
cyyever pushed a commit to cyyever/DALI that referenced this pull request Jan 23, 2022
Signed-off-by: Janusz Lisiecki <jlisiecki@nvidia.com>
Co-authored-by: Joaquin Anton <janton@nvidia.com>
cyyever pushed a commit to cyyever/DALI that referenced this pull request Jan 23, 2022
Signed-off-by: Janusz Lisiecki <jlisiecki@nvidia.com>
Co-authored-by: Joaquin Anton <janton@nvidia.com>
cyyever pushed a commit to cyyever/DALI that referenced this pull request Jan 23, 2022
Signed-off-by: Janusz Lisiecki <jlisiecki@nvidia.com>
Co-authored-by: Joaquin Anton <janton@nvidia.com>
cyyever pushed a commit to cyyever/DALI that referenced this pull request Jan 23, 2022
Signed-off-by: Janusz Lisiecki <jlisiecki@nvidia.com>
Co-authored-by: Joaquin Anton <janton@nvidia.com>
cyyever pushed a commit to cyyever/DALI that referenced this pull request Jan 23, 2022
Signed-off-by: Janusz Lisiecki <jlisiecki@nvidia.com>
Co-authored-by: Joaquin Anton <janton@nvidia.com>
cyyever pushed a commit to cyyever/DALI that referenced this pull request Jan 23, 2022
Signed-off-by: Janusz Lisiecki <jlisiecki@nvidia.com>
Co-authored-by: Joaquin Anton <janton@nvidia.com>
cyyever pushed a commit to cyyever/DALI that referenced this pull request Jan 23, 2022
Signed-off-by: Janusz Lisiecki <jlisiecki@nvidia.com>
Co-authored-by: Joaquin Anton <janton@nvidia.com>
cyyever pushed a commit to cyyever/DALI that referenced this pull request Feb 21, 2022
Signed-off-by: Janusz Lisiecki <jlisiecki@nvidia.com>
Co-authored-by: Joaquin Anton <janton@nvidia.com>
cyyever pushed a commit to cyyever/DALI that referenced this pull request May 13, 2022
Signed-off-by: Janusz Lisiecki <jlisiecki@nvidia.com>
Co-authored-by: Joaquin Anton <janton@nvidia.com>
cyyever pushed a commit to cyyever/DALI that referenced this pull request Jun 7, 2022
Signed-off-by: Janusz Lisiecki <jlisiecki@nvidia.com>
Co-authored-by: Joaquin Anton <janton@nvidia.com>
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.

None yet

6 participants