From: @luoyang42 Reviewed-by: @heleiwang,@liucunwei Signed-off-by: @liucunweitags/v1.1.0
| @@ -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 | // 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_, | 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_) + "."); | ", num_workers=" + std::to_string(num_workers_) + "."); | ||||
| return Status::OK(); | return Status::OK(); | ||||
| @@ -163,6 +163,7 @@ class Decode(cde.DecodeOp): | |||||
| Args: | Args: | ||||
| rgb (bool, optional): Mode of decoding input image (default=True). | rgb (bool, optional): Mode of decoding input image (default=True). | ||||
| If True means format of decoded image is RGB else BGR(deprecated). | |||||
| Examples: | Examples: | ||||
| >>> import mindspore.dataset.vision.c_transforms as c_vision | >>> import mindspore.dataset.vision.c_transforms as c_vision | ||||
| @@ -186,7 +187,7 @@ class Decode(cde.DecodeOp): | |||||
| img (NumPy), Decoded image. | img (NumPy), Decoded image. | ||||
| """ | """ | ||||
| if not isinstance(img, np.ndarray) or img.ndim != 1 or img.dtype.type is np.str_: | 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)) | decode = cde.Execute(cde.DecodeOp(self.rgb)) | ||||
| img = decode(cde.Tensor(np.asarray(img))) | img = decode(cde.Tensor(np.asarray(img))) | ||||
| return img.as_array() | return img.as_array() | ||||
| @@ -95,14 +95,14 @@ def test_eager_exceptions(): | |||||
| img = C.Decode()(img) | img = C.Decode()(img) | ||||
| assert False | assert False | ||||
| except TypeError as e: | 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: | try: | ||||
| img = np.array(["a", "b", "c"]) | img = np.array(["a", "b", "c"]) | ||||
| img = C.Decode()(img) | img = C.Decode()(img) | ||||
| assert False | assert False | ||||
| except TypeError as e: | 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: | try: | ||||
| img = cv2.imread("../data/dataset/apple.jpg") | img = cv2.imread("../data/dataset/apple.jpg") | ||||