synapse.ml.opencv package

Submodules

synapse.ml.opencv.ImageSetAugmenter module

class synapse.ml.opencv.ImageSetAugmenter.ImageSetAugmenter(java_obj=None, flipLeftRight=True, flipUpDown=False, inputCol='image', outputCol='ImageSetAugmenter_b10d1438043f_output')[source]

Bases: ComplexParamsMixin, JavaMLReadable, JavaMLWritable, JavaTransformer

Parameters:
  • flipLeftRight (bool) – Symmetric Left-Right

  • flipUpDown (bool) – Symmetric Up-Down

  • inputCol (str) – The name of the input column

  • outputCol (str) – The name of the output column

flipLeftRight = Param(parent='undefined', name='flipLeftRight', doc='Symmetric Left-Right')
flipUpDown = Param(parent='undefined', name='flipUpDown', doc='Symmetric Up-Down')
getFlipLeftRight()[source]
Returns:

Symmetric Left-Right

Return type:

flipLeftRight

getFlipUpDown()[source]
Returns:

Symmetric Up-Down

Return type:

flipUpDown

getInputCol()[source]
Returns:

The name of the input column

Return type:

inputCol

static getJavaPackage()[source]

Returns package name String.

getOutputCol()[source]
Returns:

The name of the output column

Return type:

outputCol

inputCol = Param(parent='undefined', name='inputCol', doc='The name of the input column')
outputCol = Param(parent='undefined', name='outputCol', doc='The name of the output column')
classmethod read()[source]

Returns an MLReader instance for this class.

setFlipLeftRight(value)[source]
Parameters:

flipLeftRight – Symmetric Left-Right

setFlipUpDown(value)[source]
Parameters:

flipUpDown – Symmetric Up-Down

setInputCol(value)[source]
Parameters:

inputCol – The name of the input column

setOutputCol(value)[source]
Parameters:

outputCol – The name of the output column

setParams(flipLeftRight=True, flipUpDown=False, inputCol='image', outputCol='ImageSetAugmenter_b10d1438043f_output')[source]

Set the (keyword only) parameters

synapse.ml.opencv.ImageTransformer module

class synapse.ml.opencv.ImageTransformer.ImageTransformer(java_obj=None, autoConvertToColor=False, colorScaleFactor=None, ignoreDecodingErrors=False, inputCol='image', normalizeMean=None, normalizeStd=None, outputCol='ImageTransformer_bd8f4708d656_output', stages=None, tensorChannelOrder='RGB', tensorElementType=None, toTensor=False)[source]

Bases: _ImageTransformer

Transformer for common image processing stages.

blur(height, width)[source]

Blurs the image using a normalized box filter

Parameters:
  • height (double) – The height of the box filter (>= 0)

  • width (double) – The width of the box filter (>= 0)

centerCrop(height, width)[source]

Center crops the image given the width and height.

Parameters:
  • height (int) – The height to crop to (>= 0)

  • width (int) – The width to crop to (>= 0)

colorFormat(format)[source]

Formats the image to the given image format

Parameters:

format (int) – The format to convert to, please see OpenCV cvtColor function documentation for all formats

crop(x, y, height, width)[source]

Crops the image given the starting x,y coordinates and the width and height

Parameters:
  • x (int) – The initial x coordinate (>=0)

  • y (int) – The initial y coordinate (>=0)

  • height (int) – The height to crop to (>=0)

  • width (int) – The width to crop to (>=0)

flip(flip_code=1)[source]

Flips the image :param int _sphinx_paramlinks_synapse.ml.opencv.ImageTransformer.ImageTransformer.flip.flip_code: a flag to specify how to flip the image - 0 means flipping around the x-axis (up-down) - positive value (for example, 1) means flipping around y-axis (left-right, default) - negative value (for example, -1) means flipping around both axes (diagonally) See OpenCV documentation for details.

gaussianKernel(aperture_size, sigma)[source]

Blurs the image by applying a gaussian kernel

Parameters:
  • aperture_size (double) – The aperture size, which should be odd and positive

  • sigma (double) – The standard deviation of the gaussian

normalize(mean, std, color_scale_factor)[source]

Normalizes the image by multiplying the color_scale_factor, substracting mean and dividing by std

resize(size, keep_aspect_ratio=True)[source]

Resizes the image to the given size.

Parameters:
  • size (int or tuple(width, height)) – The size to resize to (>=0).

  • keep_aspect_ratio (bool) – Whether to keep aspect ratio.

  • true (If) –

  • size. (the _sphinx_paramlinks_synapse.ml.opencv.ImageTransformer.ImageTransformer.resize.shorter side of the image will be resized to the specified) –

threshold(threshold, max_val, threshold_type)[source]

Thresholds the image, please see OpenCV threshold function documentation for more information

Parameters:
  • threshold – (double) The threshold value

  • max_val (double) – The maximum value to use

  • threshold_type (double) – The type of threshold, can be binary, binary_inv, trunc, zero, zero_inv

synapse.ml.opencv.ImageTransformer.toImage(array, path='', mode=16)[source]

Converts a one-dimensional array to a 2 dimensional image

Parameters:
Returns:

2 dimensional image

Return type:

object

synapse.ml.opencv.ImageTransformer.toNDArray(image)[source]

Converts an image to a 1-dimensional array

Parameters:

image (object) – The image to be converted

Returns:

The image as a 1-dimensional array

Return type:

array

Module contents

SynapseML is an ecosystem of tools aimed towards expanding the distributed computing framework Apache Spark in several new directions. SynapseML adds many deep learning and data science tools to the Spark ecosystem, including seamless integration of Spark Machine Learning pipelines with Microsoft Cognitive Toolkit (CNTK), LightGBM and OpenCV. These tools enable powerful and highly-scalable predictive and analytical models for a variety of datasources.

SynapseML also brings new networking capabilities to the Spark Ecosystem. With the HTTP on Spark project, users can embed any web service into their SparkML models. In this vein, SynapseML provides easy to use SparkML transformers for a wide variety of Microsoft Cognitive Services. For production grade deployment, the Spark Serving project enables high throughput, sub-millisecond latency web services, backed by your Spark cluster.

SynapseML requires Scala 2.12, Spark 3.0+, and Python 3.6+.