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

rocAL Video Reader : Support to pass filenames and labels as list #89

Merged
merged 24 commits into from
Feb 13, 2024

Conversation

fiona-gladwin
Copy link
Contributor

  • Add support to pass filenames and labels as list in Video reader
  • Add changes in rocalVideo iterator to return labels
  • Add new python example which demonstrates passing filenames and labels as input to the reader
  • Add C++ test case for the filenames case

@@ -627,6 +629,7 @@ extern "C" RocalImage ROCAL_API_CALL rocalVideoFileSource(RocalContext context,
RocalDecodeDevice rocal_decode_device,
unsigned internal_shard_count,
unsigned sequence_length,
std::vector<std::string> file_names_list = {},
Copy link
Contributor

@rrawther rrawther Jan 17, 2024

Choose a reason for hiding this comment

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

pass as a reference instead and remove the default initialition. Applies to all others. If it is read_only, please make it const

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

* False : when the inputs from text file is to considered as timestamps.
* \return RocalMetaData object, can be used to inquire about the rocal's output (processed) tensors
*/
extern "C" RocalMetaData ROCAL_API_CALL rocalCreateVideoLabelReader(RocalContext rocal_context, const char *source_path, unsigned sequence_length, unsigned frame_step, unsigned frame_stride, bool file_list_frame_num = true);
extern "C" RocalMetaData ROCAL_API_CALL rocalCreateVideoLabelReader(RocalContext rocal_context, const char *source_path, unsigned sequence_length, unsigned frame_step, unsigned frame_stride, bool file_list_frame_num = true,
std::vector<std::string> file_names_list = {}, std::vector<int> labels = {});
Copy link
Contributor

Choose a reason for hiding this comment

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

please pass those as reference instead like const std::vectorstd::string&

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

@@ -67,12 +67,13 @@ ROCAL_API_CALL rocalCreateLabelReader(RocalContext p_context, const char* source
}

RocalMetaData
ROCAL_API_CALL rocalCreateVideoLabelReader(RocalContext p_context, const char* source_path, unsigned sequence_length, unsigned frame_step, unsigned frame_stride, bool file_list_frame_num) {
ROCAL_API_CALL rocalCreateVideoLabelReader(RocalContext p_context, const char* source_path, unsigned sequence_length, unsigned frame_step, unsigned frame_stride, bool file_list_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.

As mentioned before please pass vectors by reference

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

self.w = self.loader.getOutputWidth()
self.h = self.loader.getOutputHeight()
self.n = self.loader.getOutputImageCount()
self.rim = self.loader.getRemainingImages()
Copy link
Contributor

Choose a reason for hiding this comment

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

What is remaining images means to video? Please change the name to describe correctly (Is it same as dataset_size?)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Renamed to self.remaining_sequences = self.loader.getRemainingImages()

@@ -189,7 +210,7 @@ int main(int argc, const char **argv)
default:
{
std::cout << "\n>>>> VIDEO READER\n";
input1 = rocalVideoFileSource(handle, source_path, color_format, decoder_mode, shard_count, sequence_length, shuffle, is_output, false, frame_step, frame_stride, file_list_frame_num);
input1 = rocalVideoFileSource(handle, source_path, color_format, decoder_mode, shard_count, sequence_length, {}, shuffle, is_output, false, frame_step, frame_stride, file_list_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.

instead of passing an empty structure, please pass 0 or nullptr which can be used if passed as reference

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We will not be able to pass 0 or nullptr to vector argument hence passing as empty vector.

Copy link
Contributor

@rrawther rrawther left a comment

Choose a reason for hiding this comment

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

please address review comments

@fiona-gladwin
Copy link
Contributor Author

please address review comments

@rrawther Addressed all review comments, Please check

@kiritigowda kiritigowda requested a review from rrawther January 23, 2024 13:50
@kiritigowda kiritigowda self-assigned this Jan 23, 2024
@kiritigowda kiritigowda added the enhancement New feature or request label Jan 23, 2024
@LakshmiKumar23
Copy link
Contributor

@fiona-gladwin @rrawther why is this PR going to master? We have develop for all the tensor work.

@fiona-gladwin
Copy link
Contributor Author

fiona-gladwin commented Jan 24, 2024

@fiona-gladwin @rrawther why is this PR going to master? We have develop for all the tensor work.

@LakshmiKumar23 We have added these changes to master since this was requested by a user, The develop branch has tensor related changes and is not yet merged with master branch.

@kiritigowda
Copy link
Collaborator

@rrawther - let me know if we can merge to master

@@ -80,6 +82,10 @@ struct MetaDataConfig
unsigned out_img_height() const { return _out_img_height; }
void set_out_img_width(unsigned out_img_width) { _out_img_width = out_img_width; }
void set_out_img_height(unsigned out_img_height) { _out_img_height = out_img_height; }
std::vector<std::string> file_names() const { return _file_names; }
std::vector<int> labels() const { return _labels; }
void set_file_names(std::vector<std::string> file_names) { _file_names = file_names; }
Copy link
Contributor

Choose a reason for hiding this comment

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

Please take these arguments by reference instead since it is passed by reference

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

Copy link
Contributor

@rrawther rrawther left a comment

Choose a reason for hiding this comment

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

@fiona-gladwin : added comment in passing vectors. Also please merge tot

@fiona-gladwin
Copy link
Contributor Author

@fiona-gladwin : added comment in passing vectors. Also please merge tot

Addressed review comments and merged with TOT

Copy link
Contributor

@rrawther rrawther left a comment

Choose a reason for hiding this comment

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

@hansely: Can you please test this PR?

@hansely
Copy link
Contributor

hansely commented Jan 27, 2024

@rrawther
Verified that the tests are passing.
@fiona-gladwin
Before merging the PR, would you be able to update the README file in the cpp_api_test for video label case?(case =4)

@rrawther
Copy link
Contributor

@kiritigowda : this PR can be merged . But it uses ROCAL_DATA and we don't have that in ROCm. We can merge it and create the DATA repo and update readme afterwards

@kiritigowda
Copy link
Collaborator

@rrawther
Copy link
Contributor

@kiritigowda : I think the PR was meant for develop branch for tensor. So it has to be merged to develop
@fiona-gladwin : Can you please confirm

@fiona-gladwin
Copy link
Contributor Author

@kiritigowda : I think the PR was meant for develop branch for tensor. So it has to be merged to develop @fiona-gladwin : Can you please confirm

@rrawther We have added these changes to master branch since this was requested by a user, Please let me know if this needs to be added to the develop branch and I can issue a different PR for the same

@kiritigowda kiritigowda merged commit bd334c8 into ROCm:master Feb 13, 2024
2 of 5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants