symbol.image

Image Symbol API of MXNet.

Functions

adjust_lighting([data, alpha, name, attr, out])

Adjust the lighting level of the input.

crop([data, x, y, width, height, name, …])

Crop an image NDArray of shape (H x W x C) or (N x H x W x C) to the given size.

flip_left_right([data, name, attr, out])

Defined in src/operator/image/image_random.cc:L195

flip_top_bottom([data, name, attr, out])

Defined in src/operator/image/image_random.cc:L205

normalize([data, mean, std, name, attr, out])

Normalize an tensor of shape (C x H x W) or (N x C x H x W) with mean and standard deviation.

random_brightness([data, min_factor, …])

Defined in src/operator/image/image_random.cc:L215

random_color_jitter([data, brightness, …])

Defined in src/operator/image/image_random.cc:L246

random_contrast([data, min_factor, …])

Defined in src/operator/image/image_random.cc:L222

random_flip_left_right([data, name, attr, out])

Defined in src/operator/image/image_random.cc:L200

random_flip_top_bottom([data, name, attr, out])

Defined in src/operator/image/image_random.cc:L210

random_hue([data, min_factor, max_factor, …])

Defined in src/operator/image/image_random.cc:L238

random_lighting([data, alpha_std, name, …])

Randomly add PCA noise.

random_saturation([data, min_factor, …])

Defined in src/operator/image/image_random.cc:L230

resize([data, size, keep_ratio, interp, …])

Resize an image NDArray of shape (H x W x C) or (N x H x W x C) to the given size ..

to_tensor([data, name, attr, out])

Converts an image NDArray of shape (H x W x C) or (N x H x W x C)

mxnet.symbol.image.adjust_lighting(data=None, alpha=_Null, name=None, attr=None, out=None, **kwargs)

Adjust the lighting level of the input. Follow the AlexNet style.

Defined in src/operator/image/image_random.cc:L254

Parameters
  • data (Symbol) – The input.

  • alpha (tuple of <float>, required) – The lighting alphas for the R, G, B channels.

  • name (string, optional.) – Name of the resulting symbol.

Returns

The result symbol.

Return type

Symbol

mxnet.symbol.image.crop(data=None, x=_Null, y=_Null, width=_Null, height=_Null, name=None, attr=None, out=None, **kwargs)

Crop an image NDArray of shape (H x W x C) or (N x H x W x C) to the given size. .. rubric:: Example

Defined in src/operator/image/crop.cc:L66

Parameters
  • data (Symbol) – The input.

  • x (int, required) – Left boundary of the cropping area.

  • y (int, required) – Top boundary of the cropping area.

  • width (int, required) – Width of the cropping area.

  • height (int, required) – Height of the cropping area.

  • name (string, optional.) – Name of the resulting symbol.

Returns

The result symbol.

Return type

Symbol

mxnet.symbol.image.flip_left_right(data=None, name=None, attr=None, out=None, **kwargs)

Defined in src/operator/image/image_random.cc:L195

Parameters
  • data (Symbol) – The input.

  • name (string, optional.) – Name of the resulting symbol.

Returns

The result symbol.

Return type

Symbol

mxnet.symbol.image.flip_top_bottom(data=None, name=None, attr=None, out=None, **kwargs)

Defined in src/operator/image/image_random.cc:L205

Parameters
  • data (Symbol) – The input.

  • name (string, optional.) – Name of the resulting symbol.

Returns

The result symbol.

Return type

Symbol

mxnet.symbol.image.normalize(data=None, mean=_Null, std=_Null, name=None, attr=None, out=None, **kwargs)
Normalize an tensor of shape (C x H x W) or (N x C x H x W) with mean and

standard deviation.

Given mean (m1, …, mn) and std (s:sub:`1, …, sn)` for n channels, this transform normalizes each channel of the input tensor with:

\[ \begin{align}\begin{aligned} output[i] = (input[i] - m\ :sub:`i`\ ) / s\ :sub:`i`\\If mean or std is scalar, the same value will be applied to all channels.\\Default value for mean is 0.0 and stand deviation is 1.0.\end{aligned}\end{align} \]

Example

Defined in src/operator/image/image_random.cc:L167

Parameters
  • data (Symbol) – Input ndarray

  • mean (tuple of <float>, optional, default=[0,0,0,0]) – Sequence of means for each channel. Default value is 0.

  • std (tuple of <float>, optional, default=[1,1,1,1]) – Sequence of standard deviations for each channel. Default value is 1.

  • name (string, optional.) – Name of the resulting symbol.

Returns

The result symbol.

Return type

Symbol

mxnet.symbol.image.random_brightness(data=None, min_factor=_Null, max_factor=_Null, name=None, attr=None, out=None, **kwargs)

Defined in src/operator/image/image_random.cc:L215

Parameters
  • data (Symbol) – The input.

  • min_factor (float, required) – Minimum factor.

  • max_factor (float, required) – Maximum factor.

  • name (string, optional.) – Name of the resulting symbol.

Returns

The result symbol.

Return type

Symbol

mxnet.symbol.image.random_color_jitter(data=None, brightness=_Null, contrast=_Null, saturation=_Null, hue=_Null, name=None, attr=None, out=None, **kwargs)

Defined in src/operator/image/image_random.cc:L246

Parameters
  • data (Symbol) – The input.

  • brightness (float, required) – How much to jitter brightness.

  • contrast (float, required) – How much to jitter contrast.

  • saturation (float, required) – How much to jitter saturation.

  • hue (float, required) – How much to jitter hue.

  • name (string, optional.) – Name of the resulting symbol.

Returns

The result symbol.

Return type

Symbol

mxnet.symbol.image.random_contrast(data=None, min_factor=_Null, max_factor=_Null, name=None, attr=None, out=None, **kwargs)

Defined in src/operator/image/image_random.cc:L222

Parameters
  • data (Symbol) – The input.

  • min_factor (float, required) – Minimum factor.

  • max_factor (float, required) – Maximum factor.

  • name (string, optional.) – Name of the resulting symbol.

Returns

The result symbol.

Return type

Symbol

mxnet.symbol.image.random_flip_left_right(data=None, name=None, attr=None, out=None, **kwargs)

Defined in src/operator/image/image_random.cc:L200

Parameters
  • data (Symbol) – The input.

  • name (string, optional.) – Name of the resulting symbol.

Returns

The result symbol.

Return type

Symbol

mxnet.symbol.image.random_flip_top_bottom(data=None, name=None, attr=None, out=None, **kwargs)

Defined in src/operator/image/image_random.cc:L210

Parameters
  • data (Symbol) – The input.

  • name (string, optional.) – Name of the resulting symbol.

Returns

The result symbol.

Return type

Symbol

mxnet.symbol.image.random_hue(data=None, min_factor=_Null, max_factor=_Null, name=None, attr=None, out=None, **kwargs)

Defined in src/operator/image/image_random.cc:L238

Parameters
  • data (Symbol) – The input.

  • min_factor (float, required) – Minimum factor.

  • max_factor (float, required) – Maximum factor.

  • name (string, optional.) – Name of the resulting symbol.

Returns

The result symbol.

Return type

Symbol

mxnet.symbol.image.random_lighting(data=None, alpha_std=_Null, name=None, attr=None, out=None, **kwargs)

Randomly add PCA noise. Follow the AlexNet style.

Defined in src/operator/image/image_random.cc:L262

Parameters
  • data (Symbol) – The input.

  • alpha_std (float, optional, default=0.0500000007) – Level of the lighting noise.

  • name (string, optional.) – Name of the resulting symbol.

Returns

The result symbol.

Return type

Symbol

mxnet.symbol.image.random_saturation(data=None, min_factor=_Null, max_factor=_Null, name=None, attr=None, out=None, **kwargs)

Defined in src/operator/image/image_random.cc:L230

Parameters
  • data (Symbol) – The input.

  • min_factor (float, required) – Minimum factor.

  • max_factor (float, required) – Maximum factor.

  • name (string, optional.) – Name of the resulting symbol.

Returns

The result symbol.

Return type

Symbol

mxnet.symbol.image.resize(data=None, size=_Null, keep_ratio=_Null, interp=_Null, name=None, attr=None, out=None, **kwargs)

Resize an image NDArray of shape (H x W x C) or (N x H x W x C) to the given size .. rubric:: Example

Defined in src/operator/image/resize.cc:L71

Parameters
  • data (Symbol) – The input.

  • size (Shape(tuple), optional, default=[]) – Size of new image. Could be (width, height) or (size)

  • keep_ratio (boolean, optional, default=0) – Whether to resize the short edge or both edges to size, if size is give as an integer.

  • interp (int, optional, default='1') – Interpolation method for resizing. By default uses bilinear interpolationOptions are INTER_NEAREST - a nearest-neighbor interpolationINTER_LINEAR - a bilinear interpolationINTER_AREA - resampling using pixel area relationINTER_CUBIC - a bicubic interpolation over 4x4 pixel neighborhoodINTER_LANCZOS4 - a Lanczos interpolation over 8x8 pixel neighborhoodNote that the GPU version only support bilinear interpolation(1)

  • name (string, optional.) – Name of the resulting symbol.

Returns

The result symbol.

Return type

Symbol

mxnet.symbol.image.to_tensor(data=None, name=None, attr=None, out=None, **kwargs)

Converts an image NDArray of shape (H x W x C) or (N x H x W x C) with values in the range [0, 255] to a tensor NDArray of shape (C x H x W) or (N x C x H x W) with values in the range [0, 1]

Example

Defined in src/operator/image/image_random.cc:L92

Parameters
  • data (Symbol) – Input ndarray

  • name (string, optional.) – Name of the resulting symbol.

Returns

The result symbol.

Return type

Symbol