Document feedback

Question document fragment

When a question document fragment contains a formula, it is displayed as a space.

Submission type
issue

It's a little complicated...

I'd like to ask someone.

Please select the submission type

Problem type
Specifications and Common Mistakes

- Specifications and Common Mistakes:

- Misspellings or punctuation mistakes,incorrect formulas, abnormal display.

- Incorrect links, empty cells, or wrong formats.

- Chinese characters in English context.

- Minor inconsistencies between the UI and descriptions.

- Low writing fluency that does not affect understanding.

- Incorrect version numbers, including software package names and version numbers on the UI.

Usability

- Usability:

- Incorrect or missing key steps.

- Missing main function descriptions, keyword explanation, necessary prerequisites, or precautions.

- Ambiguous descriptions, unclear reference, or contradictory context.

- Unclear logic, such as missing classifications, items, and steps.

Correctness

- Correctness:

- Technical principles, function descriptions, supported platforms, parameter types, or exceptions inconsistent with that of software implementation.

- Incorrect schematic or architecture diagrams.

- Incorrect commands or command parameters.

- Incorrect code.

- Commands inconsistent with the functions.

- Wrong screenshots.

- Sample code running error, or running results inconsistent with the expectation.

Risk Warnings

- Risk Warnings:

- Lack of risk warnings for operations that may damage the system or important data.

Content Compliance

- Content Compliance:

- Contents that may violate applicable laws and regulations or geo-cultural context-sensitive words and expressions.

- Copyright infringement.

Please select the type of question

Problem description

Describe the bug so that we can quickly locate the problem.

mindspore.dataset.vision.GaussianBlur

class mindspore.dataset.vision.GaussianBlur(kernel_size, sigma=None)[source]

Blur input image with the specified Gaussian kernel.

Supports Ascend hardware acceleration and can be enabled through the .device("Ascend") method.

Parameters
  • kernel_size (Union[int, Sequence[int, int]]) – The size of the Gaussian kernel. Must be positive and odd. If the input type is int, the value will be used as both the width and height of the Gaussian kernel. If the input type is Sequence[int, int], the two elements will be used as the width and height of the Gaussian kernel respectively.

  • sigma (Union[float, Sequence[float, float]], optional) – The standard deviation of the Gaussian kernel. Must be positive. If the input type is float, the value will be used as the standard deviation of both the width and height of the Gaussian kernel. If the input type is Sequence[float, float], the two elements will be used as the standard deviation of the width and height of the Gaussian kernel respectively. Default: None , the standard deviation of the Gaussian kernel will be obtained by the formula ((kernel_size1)0.51)0.3+0.8 .

Raises
  • TypeError – If kernel_size is not of type int or Sequence[int].

  • TypeError – If sigma is not of type float or Sequence[float].

  • ValueError – If kernel_size is not positive and odd.

  • ValueError – If sigma is not positive.

  • RuntimeError – If given tensor shape is not <H, W> or <H, W, C>.

Supported Platforms:

CPU Ascend

Examples

>>> import numpy as np
>>> import mindspore.dataset as ds
>>> import mindspore.dataset.vision as vision
>>>
>>> # Use the transform in dataset pipeline mode
>>> data = np.random.randint(0, 255, size=(1, 100, 100, 3)).astype(np.uint8)
>>> numpy_slices_dataset = ds.NumpySlicesDataset(data, ["image"])
>>> transforms_list = [vision.GaussianBlur(3, 3)]
>>> numpy_slices_dataset = numpy_slices_dataset.map(operations=transforms_list, input_columns=["image"])
>>> for item in numpy_slices_dataset.create_dict_iterator(num_epochs=1, output_numpy=True):
...     print(item["image"].shape, item["image"].dtype)
...     break
(100, 100, 3) uint8
>>>
>>> # Use the transform in eager mode
>>> data = np.array([[0, 1, 2, 3, 4, 5], [0, 1, 2, 3, 4, 5]], dtype=np.uint8).reshape((2, 2, 3))
>>> output = vision.GaussianBlur(3, 3)(data)
>>> print(output.shape, output.dtype)
(2, 2, 3) uint8
Tutorial Examples:
device(device_target='CPU')[source]

Set the device for the current operator execution.

  • When the device is Ascend, the parameter kernel_size only supports values 1, 3, and 5. input shape should be limited from [4, 6] to [8192, 4096].

Parameters

device_target (str, optional) – The operator will be executed on this device. Currently supports CPU and Ascend . Default: CPU .

Raises
  • TypeError – If device_target is not of type str.

  • ValueError – If device_target is not within the valid set of ['CPU', 'Ascend'].

Supported Platforms:

CPU Ascend

Examples

>>> import numpy as np
>>> import mindspore.dataset as ds
>>> import mindspore.dataset.vision as vision
>>>
>>> # Use the transform in dataset pipeline mode
>>> data = np.random.randint(0, 255, size=(1, 100, 100, 3)).astype(np.uint8)
>>> numpy_slices_dataset = ds.NumpySlicesDataset(data, ["image"])
>>> blur_op = vision.GaussianBlur(3, 3).device("Ascend")
>>> transforms_list = [blur_op]
>>> numpy_slices_dataset = numpy_slices_dataset.map(operations=transforms_list, input_columns=["image"])
>>> for item in numpy_slices_dataset.create_dict_iterator(num_epochs=1, output_numpy=True):
...     print(item["image"].shape, item["image"].dtype)
...     break
(100, 100, 3) uint8
>>>
>>> # Use the transform in eager mode
>>> data = np.random.randint(0, 255, size=(100, 100, 3)).astype(np.uint8)
>>> output = vision.GaussianBlur(3, 3).device("Ascend")(data)
>>> print(output.shape, output.dtype)
(100, 100, 3) uint8
Tutorial Examples: