Package org.jetbrains.kotlinx.dl.dataset.preprocessor

Types

ImageShape
Link copied to clipboard
data class ImageShape(width: Long?, height: Long?, channels: Long?)

Helper class to keep widely used shape of image object presented as a 4D tensor (batchSize = 1, width, height, channels). null values are allowed for width, height and channels, indicating that the dimension size is unknown.

Normalizing
Link copied to clipboard
class Normalizing : Preprocessor

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

Preprocessing
Link copied to clipboard
class Preprocessing

The data preprocessing pipeline presented as Kotlin DSL on receivers.

Preprocessor
Link copied to clipboard
interface Preprocessor

Basic interface for the data preprocessing.

Rescaling
Link copied to clipboard
class Rescaling(scalingCoefficient: Float) : Preprocessor

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

TensorPreprocessing
Link copied to clipboard
class TensorPreprocessing

Represents the tensor preprocessing stage of the Preprocessing. Consists of the operations implementing Preprocessor which are applied to the tensor one by one.

Functions

mean
Link copied to clipboard
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
fun TensorPreprocessing.normalize(block: Normalizing.() -> Unit)

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

preprocess
Link copied to clipboard
fun preprocess(init: Preprocessing.() -> Unit): Preprocessing

Defines preprocessing operations.

rescale
Link copied to clipboard
fun TensorPreprocessing.rescale(block: Rescaling.() -> Unit)

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

std
Link copied to clipboard
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.

transformImage
Link copied to clipboard
fun Preprocessing.transformImage(block: ImagePreprocessing.() -> Unit)

Defines preprocessing operations on the image.

transformTensor
Link copied to clipboard
fun Preprocessing.transformTensor(block: TensorPreprocessing.() -> Unit)

Defines preprocessing operations on the tensor.