sparkocr.transformers.inpainting.image_inpainting#

Module Contents#

Classes#

ImageInpainting

Image inpainting.

ImageInpaintingWriter

Specialization of MLWriter for Params types

class ImageInpainting(classname='sparkocr.transformers.inpainting.ImageInpainting', java_model=None)#

Bases: pyspark.ml.wrapper.JavaTransformer, pyspark.ml.param.shared.HasInputCol, pyspark.ml.param.shared.HasOutputCol, sparkocr.transformers.params.HasForceProcessing, sparkocr.transformers.params.HasKeepInput, pyspark.ml.util.DefaultParamsReadable, ImageInpaintingWriter, pyspark.ml.util.JavaMLReadable, pyspark.ml.util.JavaMLWritable

Image inpainting.

InferenceCls = None#
forceProcessing#
height#
inputCol :Param[str]#
inputRegionsCol#
instance#
keepInput#
name = 'ImageInpainting'#
optionMap :Dict[str, Any]#
originCol#
outputCol :Param[str]#
shouldOverwrite :bool = False#
uid = ''#
useGPU#
width#
clear(param: pyspark.ml.param.Param) → None#

Clears a param from the param map if it has been explicitly set.

copy(extra: pyspark.ml._typing.ParamMap | None = None) → JP#

Creates a copy of this instance with the same uid and some extra params. This implementation first calls Params.copy and then make a copy of the companion Java pipeline component with extra params. So both the Python wrapper and the Java pipeline component get copied.

Parameters:

extra (dict, optional) – Extra parameters to copy to the new instance

Returns:

Copy of this instance

Return type:

JavaParams

explainParam(param: str | Param) → str#

Explains a single param and returns its name, doc, and optional default value and user-supplied value in a string.

explainParams() → str#

Returns the documentation of all params with their optionally default values and user-supplied values.

exploding_wrap(func)#
static extractJsonParams(instance: pyspark.ml.base.Params, skipParams: Sequence[str]) → Dict[str, Any]#
extractParamMap(extra: pyspark.ml._typing.ParamMap | None = None) → pyspark.ml._typing.ParamMap#

Extracts the embedded default param values and user-supplied values, and then merges them with extra values from input into a flat param map, where the latter value is used if there exist conflicts, i.e., with ordering: default param values < user-supplied values < extra.

Parameters:

extra (dict, optional) – extra param values

Returns:

merged param map

Return type:

dict

getInputCol() → str#

Gets the value of inputCol or its default value.

getModelPath()#

Saves model :param model_path: location of saved model :return:

getOrDefault(param: str) → Any#
getOrDefault(param: Param[T]) → T

Gets the value of a param in the user-supplied param map or its default value. Raises an error if neither is set.

getOutputCol() → str#

Gets the value of outputCol or its default value.

getParam(paramName: str) → Param#

Gets a param by its name.

hasDefault(param: str | Param[Any]) → bool#

Checks whether a param has a default value.

hasParam(paramName: str) → bool#

Tests whether this instance contains a param with a given (string) name.

static inpaint_image(regions, original, params)#
isDefined(param: str | Param[Any]) → bool#

Checks whether a param is explicitly set by user or has a default value.

isSet(param: str | Param[Any]) → bool#

Checks whether a param is explicitly set by user.

static load(folder)#

Loads a spark model :param folder: location of spark model :return:

static load_model_objects(params)#
option(key: str, value: Any) → MLWriter#

Adds an option to the underlying MLWriter. See the documentation for the specific model’s writer for possible options. The option name (key) is case-insensitive.

overwrite() → MLWriter#

Overwrites if the output path already exists.

static pretrained(name, lang='en', remote_loc=None)#
static process_region_information(boxes)#
classmethod read() → DefaultParamsReader[RL]#

Returns a DefaultParamsReader instance for this class.

save(path: str) → None#

Save the ML instance to the input path.

saveImpl(path: str) → None#

save() handles overwriting and then calls this method. Subclasses should override this method to implement the actual saving of the instance.

static saveMetadata(instance: pyspark.ml.base.Params, path: str, sc: pyspark.SparkContext, extraMetadata: Dict[str, Any] | None = None, paramMap: Dict[str, Any] | None = None) → None#

Saves metadata + Params to: path + “/metadata”

  • class

  • timestamp

  • sparkVersion

  • uid

  • paramMap

  • defaultParamMap (since 2.4.0)

  • (optionally, extra metadata)

Parameters:
  • extraMetadata (dict, optional) – Extra metadata to be saved at same level as uid, paramMap, etc.

  • paramMap (dict, optional) – If given, this is saved in the “paramMap” field.

saveModel(model_path)#

Saves model :param model_path: location of saved model :return:

session(sparkSession: pyspark.sql.SparkSession) → RW#

Sets the Spark Session to use for saving/loading.

set(param: Param, value: Any) → None#

Sets a parameter in the embedded param map.

setForceProcessing(value)#

Sets the value of forceProcessing.

setHeight(value)#

Sets the value of height.

setInputCol(value)#

Sets the value of inputCol.

setInputRegionsCol(value)#

Sets the value of inputRegionsCol.

setKeepInput(value)#

Sets the value of keepInput.

setOriginCol(value)#

Sets the value of originCol.

setOutputCol(value)#

Sets the value of outputCol.

setUseGPU(value)#

Sets the value of useGPU.

setWidth(value)#

Sets the value of width.

transform(dataset: pyspark.sql.dataframe.DataFrame, params: pyspark.ml._typing.ParamMap | None = None) → pyspark.sql.dataframe.DataFrame#

Transforms the input dataset with optional parameters.

New in version 1.3.0.

Parameters:
  • dataset (pyspark.sql.DataFrame) – input dataset

  • params (dict, optional) – an optional param map that overrides embedded params.

Returns:

transformed dataset

Return type:

pyspark.sql.DataFrame

static transform_image(image, output, regions, inputs, exception)#
write() → JavaMLWriter#

Returns an MLWriter instance for this ML instance.

class ImageInpaintingWriter(instance: pyspark.ml.base.Params)#

Bases: pyspark.ml.util.DefaultParamsWriter

Specialization of MLWriter for Params types

Class for writing Estimators and Transformers whose parameters are JSON-serializable.

New in version 2.3.0.

instance#
optionMap :Dict[str, Any]#
shouldOverwrite :bool = False#
static extractJsonParams(instance: pyspark.ml.base.Params, skipParams: Sequence[str]) → Dict[str, Any]#
option(key: str, value: Any) → MLWriter#

Adds an option to the underlying MLWriter. See the documentation for the specific model’s writer for possible options. The option name (key) is case-insensitive.

overwrite() → MLWriter#

Overwrites if the output path already exists.

save(path: str) → None#

Save the ML instance to the input path.

saveImpl(path: str) → None#

save() handles overwriting and then calls this method. Subclasses should override this method to implement the actual saving of the instance.

static saveMetadata(instance: pyspark.ml.base.Params, path: str, sc: pyspark.SparkContext, extraMetadata: Dict[str, Any] | None = None, paramMap: Dict[str, Any] | None = None) → None#

Saves metadata + Params to: path + “/metadata”

  • class

  • timestamp

  • sparkVersion

  • uid

  • paramMap

  • defaultParamMap (since 2.4.0)

  • (optionally, extra metadata)

Parameters:
  • extraMetadata (dict, optional) – Extra metadata to be saved at same level as uid, paramMap, etc.

  • paramMap (dict, optional) – If given, this is saved in the “paramMap” field.

session(sparkSession: pyspark.sql.SparkSession) → RW#

Sets the Spark Session to use for saving/loading.