Browse Source

!13906 【MD】【BUG】Conventional judgment on the parameter h w not less than zero

From: @xulei2020
Reviewed-by: 
Signed-off-by:
pull/13906/MERGE
mindspore-ci-bot Gitee 5 years ago
parent
commit
5926f7c386
5 changed files with 18 additions and 5 deletions
  1. +7
    -0
      mindspore/ccsrc/minddata/dataset/kernels/image/lite_cv/warp_affine.cc
  2. +1
    -1
      mindspore/dataset/transforms/validators.py
  3. +6
    -3
      mindspore/dataset/vision/validators.py
  4. +1
    -0
      tests/ut/cpp/dataset/README.md
  5. +3
    -1
      tests/ut/python/dataset/README.md

+ 7
- 0
mindspore/ccsrc/minddata/dataset/kernels/image/lite_cv/warp_affine.cc View File

@@ -355,6 +355,10 @@ static void Remap(const LiteMat &src, LiteMat &dst, LiteMat &map1, const LiteMat


bool WarpAffineBilinear(const LiteMat &src, LiteMat &dst, const LiteMat &M, int dst_w, int dst_h, // NOLINT bool WarpAffineBilinear(const LiteMat &src, LiteMat &dst, const LiteMat &M, int dst_w, int dst_h, // NOLINT
PaddBorderType borderType, std::vector<uint8_t> &borderValue) { // NOLINT PaddBorderType borderType, std::vector<uint8_t> &borderValue) { // NOLINT
if (dst_w <= 0 || dst_h <= 0) {
return false;
}

if (!(M.height_ == 2 && M.width_ == 3)) { if (!(M.height_ == 2 && M.width_ == 3)) {
return false; return false;
} }
@@ -471,6 +475,9 @@ static void PerspectiveInvert(double *src, double *dst) {


bool WarpPerspectiveBilinear(const LiteMat &src, LiteMat &dst, const LiteMat &M, int dst_w, int dst_h, // NOLINT bool WarpPerspectiveBilinear(const LiteMat &src, LiteMat &dst, const LiteMat &M, int dst_w, int dst_h, // NOLINT
PaddBorderType borderType, std::vector<uint8_t> &borderValue) { // NOLINT PaddBorderType borderType, std::vector<uint8_t> &borderValue) { // NOLINT
if (dst_w <= 0 || dst_h <= 0) {
return false;
}
if (!(M.height_ == 3 && M.width_ == 3)) { if (!(M.height_ == 3 && M.width_ == 3)) {
return false; return false;
} }


+ 1
- 1
mindspore/dataset/transforms/validators.py View File

@@ -60,7 +60,7 @@ def check_one_hot_op(method):
@wraps(method) @wraps(method)
def new_method(self, *args, **kwargs): def new_method(self, *args, **kwargs):
[num_classes, smoothing_rate], _ = parse_user_args(method, *args, **kwargs) [num_classes, smoothing_rate], _ = parse_user_args(method, *args, **kwargs)
type_check(smoothing_rate, (int, float), "smoothing_rate")
type_check(num_classes, (int,), "num_classes") type_check(num_classes, (int,), "num_classes")
check_positive(num_classes) check_positive(num_classes)




+ 6
- 3
mindspore/dataset/vision/validators.py View File

@@ -44,6 +44,8 @@ def check_cut_mix_batch_c(method):
def new_method(self, *args, **kwargs): def new_method(self, *args, **kwargs):
[image_batch_format, alpha, prob], _ = parse_user_args(method, *args, **kwargs) [image_batch_format, alpha, prob], _ = parse_user_args(method, *args, **kwargs)
type_check(image_batch_format, (ImageBatchFormat,), "image_batch_format") type_check(image_batch_format, (ImageBatchFormat,), "image_batch_format")
type_check(alpha, (int, float), "alpha")
type_check(prob, (int, float), "prob")
check_pos_float32(alpha) check_pos_float32(alpha)
check_positive(alpha, "alpha") check_positive(alpha, "alpha")
check_value(prob, [0, 1], "prob") check_value(prob, [0, 1], "prob")
@@ -70,6 +72,7 @@ def check_mix_up_batch_c(method):
@wraps(method) @wraps(method)
def new_method(self, *args, **kwargs): def new_method(self, *args, **kwargs):
[alpha], _ = parse_user_args(method, *args, **kwargs) [alpha], _ = parse_user_args(method, *args, **kwargs)
type_check(alpha, (int, float), "alpha")
check_positive(alpha, "alpha") check_positive(alpha, "alpha")
check_pos_float32(alpha) check_pos_float32(alpha)


@@ -463,11 +466,11 @@ def check_mix_up(method):
@wraps(method) @wraps(method)
def new_method(self, *args, **kwargs): def new_method(self, *args, **kwargs):
[batch_size, alpha, is_single], _ = parse_user_args(method, *args, **kwargs) [batch_size, alpha, is_single], _ = parse_user_args(method, *args, **kwargs)

type_check(is_single, (bool,), "is_single")
type_check(batch_size, (int,), "batch_size")
type_check(alpha, (int, float), "alpha")
check_value(batch_size, (1, FLOAT_MAX_INTEGER)) check_value(batch_size, (1, FLOAT_MAX_INTEGER))
check_positive(alpha, "alpha") check_positive(alpha, "alpha")
type_check(is_single, (bool,), "is_single")

return method(self, *args, **kwargs) return method(self, *args, **kwargs)


return new_method return new_method


+ 1
- 0
tests/ut/cpp/dataset/README.md View File

@@ -1,3 +1,4 @@


### Introduce of data ### Introduce of data

All of data used in this folder created by Huawei Technologies Co. All of data used in this folder created by Huawei Technologies Co.

+ 3
- 1
tests/ut/python/dataset/README.md View File

@@ -1,7 +1,9 @@
## DE Dataset Ops Test (Python) ## DE Dataset Ops Test (Python)


#### Environment
### Environment

Python3.7 (PyCharm IDE is recommended) Python3.7 (PyCharm IDE is recommended)


### Introduce of data ### Introduce of data

All of data used in this folder created by Huawei Technologies Co. All of data used in this folder created by Huawei Technologies Co.

Loading…
Cancel
Save