Browse Source

!10109 [MD] Fix Decode doc & RandomNode log

From: @luoyang42
Reviewed-by: @heleiwang,@liucunwei
Signed-off-by: @liucunwei
tags/v1.1.0
mindspore-ci-bot Gitee 5 years ago
parent
commit
691e3baab6
3 changed files with 5 additions and 4 deletions
  1. +1
    -1
      mindspore/ccsrc/minddata/dataset/engine/ir/datasetops/source/random_node.cc
  2. +2
    -1
      mindspore/dataset/vision/c_transforms.py
  3. +2
    -2
      tests/ut/python/dataset/test_eager_vision.py

+ 1
- 1
mindspore/ccsrc/minddata/dataset/engine/ir/datasetops/source/random_node.cc View File

@@ -54,7 +54,7 @@ Status RandomNode::ValidateParams() {

// allow total_rows == 0 for now because RandomOp would generate a random row when it gets a 0
CHECK_FAIL_RETURN_UNEXPECTED(total_rows_ == 0 || total_rows_ >= num_workers_,
"RandomNode needs total_rows < num_workers. total_rows=" + std::to_string(total_rows_) +
"RandomNode needs total_rows >= num_workers, total_rows=" + std::to_string(total_rows_) +
", num_workers=" + std::to_string(num_workers_) + ".");

return Status::OK();


+ 2
- 1
mindspore/dataset/vision/c_transforms.py View File

@@ -163,6 +163,7 @@ class Decode(cde.DecodeOp):

Args:
rgb (bool, optional): Mode of decoding input image (default=True).
If True means format of decoded image is RGB else BGR(deprecated).

Examples:
>>> import mindspore.dataset.vision.c_transforms as c_vision
@@ -186,7 +187,7 @@ class Decode(cde.DecodeOp):
img (NumPy), Decoded image.
"""
if not isinstance(img, np.ndarray) or img.ndim != 1 or img.dtype.type is np.str_:
raise TypeError("Input should be a 1-D NumPy with integer type, got {}.".format(type(img)))
raise TypeError("Input should be an encoded image with 1-D NumPy type, got {}.".format(type(img)))
decode = cde.Execute(cde.DecodeOp(self.rgb))
img = decode(cde.Tensor(np.asarray(img)))
return img.as_array()


+ 2
- 2
tests/ut/python/dataset/test_eager_vision.py View File

@@ -95,14 +95,14 @@ def test_eager_exceptions():
img = C.Decode()(img)
assert False
except TypeError as e:
assert "Input should be a 1-D NumPy with integer type" in str(e)
assert "Input should be an encoded image with 1-D NumPy type" in str(e)

try:
img = np.array(["a", "b", "c"])
img = C.Decode()(img)
assert False
except TypeError as e:
assert "Input should be a 1-D NumPy with integer type" in str(e)
assert "Input should be an encoded image with 1-D NumPy type" in str(e)

try:
img = cv2.imread("../data/dataset/apple.jpg")


Loading…
Cancel
Save