mindspore.dataset.vision.AdjustBrightness
- class mindspore.dataset.vision.AdjustBrightness(brightness_factor)[source]
- Adjust the brightness of the input image. - Supports Ascend hardware acceleration and can be enabled through the .device("Ascend") method. - Parameters
- brightness_factor (float) – How much to adjust the brightness, must be non negative. - 0.0gives a black image,- 1.0gives the original image, while- 2.0increases the brightness by a factor of 2.
- Raises
- TypeError – If brightness_factor is not of type float. 
- ValueError – If brightness_factor is less than - 0.0.
- RuntimeError – If shape of the input image is not <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.AdjustBrightness(brightness_factor=2.0)] >>> 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, 256, (20, 20, 3)) / 255.0 >>> data = data.astype(np.float32) >>> output = vision.AdjustBrightness(2.666)(data) >>> print(output.shape, output.dtype) (20, 20, 3) float32 - Tutorial Examples:
 - device(device_target='CPU')[source]
- Set the device for the current operator execution. - When the device is Ascend, 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"]) >>> transforms_list = [vision.AdjustBrightness(2.0).device("Ascend")] >>> 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, 256, (20, 20, 3)) / 255.0 >>> data = data.astype(np.float32) >>> output = vision.AdjustBrightness(2.666).device("Ascend")(data) >>> print(output.shape, output.dtype) (20, 20, 3) float32 - Tutorial Examples: