Package org.jetbrains.kotlinx.dl.impl.preprocessing

Types

ConvertToFloatArray
Link copied to clipboard
class ConvertToFloatArray(layout: TensorLayout) : Operation<Bitmap, Pair<FloatArray, TensorShape>>

Converts Bitmap to float array representation. Only Bitmap.Config.ARGB_8888 is supported.

FloatArrayOperation
Link copied to clipboard
common
abstract class FloatArrayOperation

The aim of this class is to provide common functionality for all Operations that can be applied to Pair and simplify the implementation of a new Operations.

Normalizing
Link copied to clipboard
common
class Normalizing : FloatArrayOperation

This preprocessor defines normalizing operation. Given mean and std for n channels, this operation normalizes each channel of the input array, i.e.

Rescaling
Link copied to clipboard
common
class Rescaling(scalingCoefficient: Float) : FloatArrayOperation

This preprocessor defines the Rescaling operation. It scales each pixel pixel_i = pixel_i / scalingCoefficient.

TensorLayout
Link copied to clipboard
enum TensorLayout : Enum<TensorLayout>

Supported layouts for flat representations of tensors.

Functions

call
Link copied to clipboard
common
fun <I, M, O> <ERROR CLASS><I, M>.call(operation: <ERROR CLASS><M, O>): <ERROR CLASS><I, O>

Applies provided operation to the preprocessing pipeline.

crop
Link copied to clipboard
fun <I> Operation<I, Bitmap>.crop(block: Crop.() -> Unit): Operation<I, Bitmap>

Applies Crop operation to crop the Bitmap at a specified region.

mean
Link copied to clipboard
common
fun FloatArray.mean(channels: Int = 1): FloatArray

Computes mean value for each channel of the array. Array size should be divisible by the passed channels number.

fun mean(vararg arrays: FloatArray, channels: Int = 1): FloatArray

Computes mean value for each channel of the provided arrays.

normalize
Link copied to clipboard
common
fun <I> <ERROR CLASS><I, <ERROR CLASS><FloatArray, <ERROR CLASS>>>.normalize(block: Normalizing.() -> Unit): <ERROR CLASS><I, <ERROR CLASS><FloatArray, <ERROR CLASS>>>

Applies Normalizing preprocessor to the tensor to normalize it with given mean and std values.

onResult
Link copied to clipboard
common
fun <I, O> <ERROR CLASS><I, O>.onResult(block: (O) -> Unit): <ERROR CLASS><I, O>

Convenience functions for executing custom logic after applying Operation. Could be useful for debugging purposes.

rescale
Link copied to clipboard
common
fun <I> <ERROR CLASS><I, <ERROR CLASS><FloatArray, <ERROR CLASS>>>.rescale(block: Rescaling.() -> Unit): <ERROR CLASS><I, <ERROR CLASS><FloatArray, <ERROR CLASS>>>

Applies Rescaling preprocessor to the tensor to scale each value by a given coefficient.

resize
Link copied to clipboard
fun <I> Operation<I, Bitmap>.resize(block: Resize.() -> Unit): Operation<I, Bitmap>

Applies Resize operation to resize the Bitmap to a specific size.

rotate
Link copied to clipboard
fun <I> Operation<I, Bitmap>.rotate(block: Rotate.() -> Unit): Operation<I, Bitmap>

Applies Rotate operation to rotate the Bitmap by an arbitrary angle (specified in degrees).

std
Link copied to clipboard
common
fun FloatArray.std(channels: Int = 1): FloatArray

Computes std value for each channel of the array. Array size should be divisible by the passed channels number.

fun std(vararg arrays: FloatArray, channels: Int = 1): FloatArray

Computes std value for each channel of the provided arrays.

toFloatArray
Link copied to clipboard
fun <I> Operation<I, Bitmap>.toFloatArray(block: ConvertToFloatArray.() -> Unit): Operation<I, Pair<FloatArray, TensorShape>>

Applies ConvertToFloatArray operation to convert the Bitmap to a float array.