Add the "fill_mode" option in augment-image.cc#1602
Add the "fill_mode" option in augment-image.cc#1602danpovey merged 10 commits intokaldi-asr:kaldi_52from YiwenShaoStephen:kaldi_52
Conversation
| namespace kaldi { | ||
| namespace nnet3 { | ||
|
|
||
| enum fill_mode_type {kNearest, kReflect}; |
| if (r2 < 0) r2 = - r2; | ||
| } | ||
| if (r2 >= num_rows) { | ||
| r2 = num_rows -1 - (r2 - num_rows + 1); |
There was a problem hiding this comment.
I think you could simplify this expression.
There was a problem hiding this comment.
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}"); |
There was a problem hiding this comment.
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}");
There was a problem hiding this comment.
I will fix it.
| fill_mode_type fill_mode; | ||
| if (fill_mode_string == "reflect"){ | ||
| fill_mode = kReflect; | ||
| } else { |
There was a problem hiding this comment.
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}; |
There was a problem hiding this comment.
According to Google style, enum name should be in first-letter-capital format: i.e. FillModeType or simply FillMode.
There was a problem hiding this comment.
Also there should be a space before }
| int32 num_channels, | ||
| MatrixBase<BaseFloat> *image) { | ||
| MatrixBase<BaseFloat> *image, | ||
| fill_mode_type fill_mode) { |
There was a problem hiding this comment.
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); | ||
| } | ||
|
|
There was a problem hiding this comment.
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) { |
There was a problem hiding this comment.
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 " |
There was a problem hiding this comment.
Shouldn't this option be defined in the ImageAugmentationConfig class? Is it here because it is a string and is converted to Enum later?
|
You're right, it should be in that class.
It's OK to turn it to an enum inside the function, as long as it's outside
of any loops.
…On Thu, May 4, 2017 at 5:38 PM, Hossein Hadian ***@***.***> wrote:
***@***.**** commented on this pull request.
------------------------------
In src/nnet3bin/nnet3-egs-augment-image.cc
<#1602 (comment)>:
>
ImageAugmentationConfig config;
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 "
Shouldn't this option be defined in the ImageAugmentationConfig class? Is
it here because it is a string and is converted to Enum later?
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#1602 (review)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/ADJVu0pxSYD7xHqhcULZZhEJzumbWp6Bks5r2kVrgaJpZM4NODCe>
.
|
|
... or have a function
FillMode GetFillMode() const;
in the augmentation-config class, that works out the fill-mode as an enum.
…On Thu, May 4, 2017 at 5:47 PM, Daniel Povey ***@***.***> wrote:
You're right, it should be in that class.
It's OK to turn it to an enum inside the function, as long as it's outside
of any loops.
On Thu, May 4, 2017 at 5:38 PM, Hossein Hadian ***@***.***>
wrote:
> ***@***.**** commented on this pull request.
> ------------------------------
>
> In src/nnet3bin/nnet3-egs-augment-image.cc
> <#1602 (comment)>:
>
> >
> ImageAugmentationConfig config;
>
> 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 "
>
> Shouldn't this option be defined in the ImageAugmentationConfig class? Is
> it here because it is a string and is converted to Enum later?
>
> —
> You are receiving this because you commented.
> Reply to this email directly, view it on GitHub
> <#1602 (review)>,
> or mute the thread
> <https://github.com/notifications/unsubscribe-auth/ADJVu0pxSYD7xHqhcULZZhEJzumbWp6Bks5r2kVrgaJpZM4NODCe>
> .
>
|
|
Thanks a lot! Merging. |
No description provided.