Standard
Standard processors
ControlMap
paz.processors.standard.ControlMap(processor, intro_indices=[0], outro_indices=[0], keep=None)
Controls which inputs are passed ''processor'' and the order of its outputs.
Arguments
- processor: Function e.g. a ''paz.processor''
- intro_indices: List of Ints.
- outro_indices: List of Ints.
- keep: ''None'' or dictionary. If
None
control maps operates without explicitly retaining an input. If dict it must contain as keys the input args to be kept and as values where they should be located at the end.
ExpandDomain
paz.processors.standard.ExpandDomain(processor)
Extends number of inputs a function can take applying the identity function to all new/extended inputs. e.g. For a given function f(x) = y. If g = ExtendInputs(f), we can now have g(x, x1, x2, ..., xn) = y, x1, x2, ..., xn.
Arguments
- processor: Function e.g. any procesor in ''paz.processors''.
CopyDomain
paz.processors.standard.CopyDomain(intro_indices, outro_indices)
Copies ''intro_indices'' and places it ''outro_indices''.
Arguments
- intro_indices: List of Ints.
- outro_indices: List of Ints.
ExtendInputs
paz.processors.standard.ExtendInputs(processor)
Extends number of inputs a function can take applying the identity function to all new/extended inputs. e.g. For a given function f(x) = y. If g = ExtendInputs(f), we can now have g(x, x1, x2, ..., xn) = y, x1, x2, ..., xn.
Arguments
- processor: Function e.g. any procesor in ''paz.processors''.
SequenceWrapper
paz.processors.standard.SequenceWrapper(inputs_info, labels_info)
Wraps arguments to directly use ''paz.abstract.ProcessingSequence'' or ''paz.abstract.GeneratingSequence''.
Arguments
- inputs_info: Dictionary containing an integer per key representing the argument to grab, and as value a dictionary containing the tensor name as key and the tensor shape of a single sample as value e.g. {0: {'input_image': [300, 300, 3]}, 1: {'depth': [300, 300]}}. The values given here are for the inputs of the model.
- labels_info: Dictionary containing an integer per key representing the argument to grab, and as value a dictionary containing the tensor name as key and the tensor shape of a single sample as value e.g. {2: {'classes': [10]}}. The values given here are for the labels of the model.
Predict
paz.processors.standard.Predict(model, preprocess=None, postprocess=None)
Perform input preprocessing, model prediction and output postprocessing.
Arguments
- model: Class with a ''predict'' method e.g. a Keras model.
- preprocess: Function applied to given inputs.
- postprocess: Function applied to outputted predictions from model.
PredictWithNones
paz.processors.standard.PredictWithNones(model, preprocess=None, postprocess=None)
Perform input preprocessing, model prediction and output postprocessing based on batches.
Arguments
- model: Class with a ''predict'' method e.g. a Keras model.
- preprocess: Function applied to given inputs.
- postprocess: Function applied to outputted predictions from model.
ToClassName
paz.processors.standard.ToClassName(labels)
ExpandDims
paz.processors.standard.ExpandDims(axis)
Expand dimension of given array.
Arguments
- axis: Int.
BoxClassToOneHotVector
paz.processors.standard.BoxClassToOneHotVector(num_classes)
Transform box data with class index to a one-hot encoded vector.
Arguments
- num_classes: Integer. Total number of classes.
Squeeze
paz.processors.standard.Squeeze(axis)
Wrap around numpy squeeze
due to common use before model predict.
Arguments
- expand_dims: Int or list of Ints.
- topic: String.
Copy
paz.processors.standard.Copy()
Copies value passed to function.
Lambda
paz.processors.standard.Lambda(function)
Applies a lambda function as a processor transformation.
Arguments
- function: Function.
UnpackDictionary
paz.processors.standard.UnpackDictionary(order)
Unpacks dictionary into a tuple. Arguments
- order: List of strings containing the keys of the dictionary. The order of the list is the order in which the tuple would be ordered.
WrapOutput
paz.processors.standard.WrapOutput(keys)
Wraps arguments in dictionary
Arguments
- keys: List of strings representing the keys used to wrap the inputs. The order of the list must correspond to the same order of inputs (''args'').
Concatenate
paz.processors.standard.Concatenate(axis)
Concatenates a list of arrays in given ''axis''.
Arguments
- axis: Int.
SelectElement
paz.processors.standard.SelectElement(index)
Selects element of input value.
Arguments
- index: Int. argument to select from ''inputs''.
StochasticProcessor
paz.processors.standard.StochasticProcessor(probability=0.5, name=None)
Stochastic
paz.processors.standard.Stochastic(function, probability=0.5, name=None)
UnwrapDictionary
paz.processors.standard.UnwrapDictionary(keys)
Unwraps a dictionry into a list given the key order.
Scale
paz.processors.standard.Scale(scales)
Scales an input.
AppendValues
paz.processors.standard.AppendValues(keys)
Append dictionary values to lists
Arguments
- keys: Keys to dictionary values
BooleanToTextMessage
paz.processors.standard.BooleanToTextMessage(true_message, false_message)
Convert a boolean to text message. Arguments
- true_message: String. Message for true case.
- false_message: String. Message for false case.
- Flag: Boolean.
Returns
- message: String.
PrintTopics
paz.processors.standard.PrintTopics(topics)
Prints topics Arguments
- topics: List of keys to the inputted dictionary
Returns
Returns same dictionary but outputs to terminal topic values.
FloatToBoolean
paz.processors.standard.FloatToBoolean(threshold=0.5)
Converts a float to a boolean. Arguments
- threshold: Float. Threshold value to convert to boolean.
- value: Float.
Returns
Boolean.
NoneConverter
paz.processors.standard.NoneConverter(default_value=0.0)
Converts a None value to the last valid or a default value. Arguments
- default_value: Any. Default value to convert to until a first valid value is stored.
- value: Any Noneable value.
Returns
Any.
AveragePredictions
paz.processors.standard.AveragePredictions(window_size=1, weighted=False)
Averages the last n predictions Arguments
- window_size: Int. Number of predictions to average over.
- weighted: Bool. If True, the average is weighted by the index of the prediction.
- value: Bool, Int or Float value. Value to average over. Returns
Bool, Int or Float value. Averaged value.
ComputeCommonRowIndices
paz.processors.standard.ComputeCommonRowIndices()
Computes row-wise intersection between two given arrays and returns the indices of the intersections.