Skip to content

Add the "fill_mode" option in augment-image.cc#1602

Merged
danpovey merged 10 commits intokaldi-asr:kaldi_52from
YiwenShaoStephen:kaldi_52
May 5, 2017
Merged

Add the "fill_mode" option in augment-image.cc#1602
danpovey merged 10 commits intokaldi-asr:kaldi_52from
YiwenShaoStephen:kaldi_52

Conversation

@YiwenShaoStephen
Copy link
Contributor

No description provided.

namespace kaldi {
namespace nnet3 {

enum fill_mode_type {kNearest, kReflect};
Copy link
Contributor

Choose a reason for hiding this comment

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

space after {

if (r2 < 0) r2 = - r2;
}
if (r2 >= num_rows) {
r2 = num_rows -1 - (r2 - num_rows + 1);
Copy link
Contributor

Choose a reason for hiding this comment

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

I think you could simplify this expression.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No problem. I didn't simplify it just for ease of understanding.


ParseOptions po(usage);
po.Register("srand", &srand_seed, "Seed for the random number generator");
po.Register("fill_mode", &fill_mode_string, "Mode for filling the out-bundaries points = {nearest, reflect}");
Copy link
Contributor

Choose a reason for hiding this comment

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

use "fill-mode"
typo: bundaries should be boundaries;
and try to stay within the google-style-guide-mandated 80-character limit. e.g.

po.Register("fill-mode", &fill_mode_string, "Mode for dealing with "
                  "points outside the image boundary when applying transformations. "
                  "Choices = {nearest, reflect}");

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 will fix it.

fill_mode_type fill_mode;
if (fill_mode_string == "reflect"){
fill_mode = kReflect;
} else {
Copy link
Contributor

Choose a reason for hiding this comment

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

add:

     if (fill_mode_string != "nearest") 
       KALDI_ERR << "Choices for --fill-mode are 'nearest' or 'reflect', got: "
                          << fill_mode_string;

namespace kaldi {
namespace nnet3 {

enum fill_mode_type { kNearest, kReflect};
Copy link
Contributor

Choose a reason for hiding this comment

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

According to Google style, enum name should be in first-letter-capital format: i.e. FillModeType or simply FillMode.

Copy link
Contributor

Choose a reason for hiding this comment

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

Also there should be a space before }

int32 num_channels,
MatrixBase<BaseFloat> *image) {
MatrixBase<BaseFloat> *image,
fill_mode_type fill_mode) {
Copy link
Contributor

Choose a reason for hiding this comment

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

I can see you are using tabs. You need to change it to spaces. Fix other places in your code too.

po.PrintUsage();
exit(1);
}

Copy link
Contributor

Choose a reason for hiding this comment

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

There is a trailing space here. Please fix here and other places and configure your editor to disallow trailing spaces.

c1 = - c1;
if (c2 < 0) c2 = -c2;
}
if (c2 >= num_cols) {
Copy link
Contributor

Choose a reason for hiding this comment

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

All these num_cols should be changed to height. This issue existed in my code to. Please fix them as well.
Maybe better to rename num_rows to width to avoid future confusion.


ParseOptions po(usage);
po.Register("srand", &srand_seed, "Seed for the random number generator");
po.Register("fill-mode", &fill_mode_string, "Mode for dealing with "
Copy link
Contributor

Choose a reason for hiding this comment

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

Shouldn't this option be defined in the ImageAugmentationConfig class? Is it here because it is a string and is converted to Enum later?

@danpovey
Copy link
Contributor

danpovey commented May 4, 2017 via email

@danpovey
Copy link
Contributor

danpovey commented May 4, 2017 via email

@danpovey
Copy link
Contributor

danpovey commented May 5, 2017

Thanks a lot! Merging.

@danpovey danpovey merged commit 13b08e4 into kaldi-asr:kaldi_52 May 5, 2017
Skaiste pushed a commit to Skaiste/idlak that referenced this pull request Sep 26, 2018
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.

3 participants