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 enable_frame_num to the experimental video reader #5628

Merged
merged 5 commits into from
Sep 11, 2024

Conversation

JanuszL
Copy link
Contributor

@JanuszL JanuszL commented Sep 9, 2024

  • adds an ability to output frame numbers in the experimental video
    reader
  • this allows making VideoReaderDecoderCpuTest.RandomShuffle_* test
    independent from the hardcoding of the expected frame order (in case
    random generator implementation changes)

Category:

New feature (non-breaking change which adds functionality)

Description:

  • adds an ability to output frame numbers in the experimental video
    reader
  • this allows making VideoReaderDecoderCpuTest.RandomShuffle_* test
    independent from the hardcoding of the expected frame order (in case
    random generator implementation changes)
  • needed for Moves to manylinux_2_28 #5608 as the random generator output changes with the manylinux change

Additional information:

Affected modules and functionalities:

  • experimental video reader

Key points relevant for the review:

  • NA

Tests:

  • Existing tests apply
    • VideoReaderDecoderCpuTest.RandomShuffle_*
  • 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: RDVID.13

JIRA TASK: N/A

- adds an ability to output frame numbers in the experimental video
  reader
- this allows making VideoReaderDecoderCpuTest.RandomShuffle_* test
  independent from the hardcoding of the expected frame order (in case
  random generator implementation changes)

Signed-off-by: Janusz Lisiecki <[email protected]>
@JanuszL
Copy link
Contributor Author

JanuszL commented Sep 9, 2024

!build

@dali-automaton
Copy link
Collaborator

CI MESSAGE: [18262573]: BUILD STARTED

@dali-automaton
Copy link
Collaborator

CI MESSAGE: [18262564]: BUILD FAILED

@dali-automaton
Copy link
Collaborator

CI MESSAGE: [18262573]: BUILD FAILED

Comment on lines 38 to 39
int label_;
int first_frame_;
Copy link
Contributor

Choose a reason for hiding this comment

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

Since VideoSample already has a non-trivial constructor, some initialization (e.g. to invalid values, like -1) would be nice.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed

Signed-off-by: Janusz Lisiecki <[email protected]>
@dali-automaton
Copy link
Collaborator

CI MESSAGE: [18262573]: BUILD PASSED

@mzient mzient self-assigned this Sep 10, 2024
Comment on lines 53 to 57
int num_outputs = 1;
if (spec.HasArgument("labels")) num_outputs++;
bool enable_frame_num = spec.GetArgument<bool>("enable_frame_num");
if (enable_frame_num) num_outputs++;
return num_outputs;
Copy link
Contributor

Choose a reason for hiding this comment

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

Perhaps clearer (?) Your call.

Suggested change
int num_outputs = 1;
if (spec.HasArgument("labels")) num_outputs++;
bool enable_frame_num = spec.GetArgument<bool>("enable_frame_num");
if (enable_frame_num) num_outputs++;
return num_outputs;
bool has_label_output = spec.HasArgument("labels");
bool has_frame_num_output = spec.GetArgument<bool>("enable_frame_num");
return 1 + has_label_output + has_frame_num_output;

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

Comment on lines 85 to 86
R"code(If set, returns the first frame number in the decoded sequence
as a separate output.)code",
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
R"code(If set, returns the first frame number in the decoded sequence
as a separate output.)code",
R"code(If set, returns the index of the first frame in the decoded sequence
as an additional output.)code",

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

@@ -68,6 +81,10 @@ even in the variable frame rate scenario.)code")
.AddArg("sequence_length",
R"code(Frames to load per sequence.)code",
DALI_INT32)
.AddOptionalArg("enable_frame_num",
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
.AddOptionalArg("enable_frame_num",
.AddOptionalArg("enable_frame_idx",

?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I want to keep it consistent with the video reader .

Copy link
Contributor

Choose a reason for hiding this comment

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

I understand and agree - nonetheless, it's unfortunate.

@@ -168,6 +172,15 @@ void VideoReaderDecoderBaseTest::RunShuffleTest<dali::CPUBackend>() {
RunShuffleTestImpl<dali::CPUBackend>("cpu", dali::CPU_ONLY_DEVICE_ID);
}

template<>
int VideoReaderDecoderBaseTest::GetFrameNo(
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 VideoReaderDecoderBaseTest::GetFrameNo(
int VideoReaderDecoderBaseTest::GetFrameIdx(

...if going with the idx suggestion.

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

@@ -181,6 +194,15 @@ void VideoReaderDecoderBaseTest::RunShuffleTest<dali::GPUBackend>() {
RunShuffleTestImpl<dali::GPUBackend>("gpu", 0);
}

template<>
int VideoReaderDecoderBaseTest::GetFrameNo(
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 VideoReaderDecoderBaseTest::GetFrameNo(
int VideoReaderDecoderBaseTest::GetFrameIdx(

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

@@ -40,6 +40,9 @@ class VideoReaderDecoderBaseTest : public VideoTestBase {
virtual void AssertFrame(
int frame_id, const uint8_t *frame, TestVideo &ground_truth) = 0;

template<typename Backend>
int GetFrameNo(dali::TensorList<Backend> &device_frame_no);
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 GetFrameNo(dali::TensorList<Backend> &device_frame_no);
int GetFrameIdx(dali::TensorList<Backend> &device_frame_idx);

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

@@ -35,6 +35,7 @@ class VideoReaderDecoderGpu : public DataReader<GPUBackend, VideoSampleGpu, Vide

private:
bool has_labels_ = false;
bool has_frame_no_ = false;
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
bool has_frame_no_ = false;
bool has_frame_idx_ = false;

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

Signed-off-by: Janusz Lisiecki <[email protected]>
@JanuszL JanuszL force-pushed the frame_no_exp_reader branch from e2afd19 to ec7fa68 Compare September 10, 2024 10:37
Signed-off-by: Janusz Lisiecki <[email protected]>
@JanuszL
Copy link
Contributor Author

JanuszL commented Sep 10, 2024

!build

@dali-automaton
Copy link
Collaborator

CI MESSAGE: [18290753]: BUILD FAILED

@dali-automaton
Copy link
Collaborator

CI MESSAGE: [18290753]: BUILD STARTED

Signed-off-by: Janusz Lisiecki <[email protected]>
@JanuszL
Copy link
Contributor Author

JanuszL commented Sep 10, 2024

!build

@dali-automaton
Copy link
Collaborator

CI MESSAGE: [18302585]: BUILD STARTED

@dali-automaton
Copy link
Collaborator

CI MESSAGE: [18302585]: BUILD PASSED

@JanuszL JanuszL merged commit 4b1833a into NVIDIA:main Sep 11, 2024
7 checks passed
@JanuszL JanuszL deleted the frame_no_exp_reader branch September 11, 2024 05:29
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