Package-level declarations

Types

Link copied to clipboard
class ChainedTransform<I, M, O>(first: Transform<I, M>, second: Transform<M, O>) : Transform<I, O>

A transform that chains two transforms together, applying them in sequence.

Link copied to clipboard

CIFAR-10 normalization statistics.

Link copied to clipboard
class Clamp<T : DType, V>(ctx: ExecutionContext, val min: Float, val max: Float) : TensorTransform<T, V>

Clamps tensor values to a specified range.

Link copied to clipboard

Color modes for image processing.

Link copied to clipboard
class Flatten<T : DType, V>(ctx: ExecutionContext, val startDim: Int = 0, val endDim: Int = -1) : TensorTransform<T, V>

Flattens a tensor along specified dimensions.

Link copied to clipboard
class Identity<T> : Transform<T, T>

An identity transform that returns its input unchanged.

Link copied to clipboard

Center crops an image to a square of the specified size.

Link copied to clipboard
class ImageCrop(val top: Int = 0, val bottom: Int = 0, val left: Int = 0, val right: Int = 0) : Transform<PlatformBitmapImage, PlatformBitmapImage>

Crops an image by removing pixels from the edges.

Link copied to clipboard
object ImageNet

ImageNet normalization statistics.

Link copied to clipboard
class ImagePad(val top: Int = 0, val bottom: Int = 0, val left: Int = 0, val right: Int = 0, val red: Int = 0, val green: Int = 0, val blue: Int = 0) : Transform<PlatformBitmapImage, PlatformBitmapImage>

Pads an image by adding pixels to the edges.

Link copied to clipboard
class ImageResize(val width: Int, val height: Int, val interpolation: Interpolation = Interpolation.BILINEAR) : Transform<PlatformBitmapImage, PlatformBitmapImage>

Resizes an image to the specified dimensions.

Link copied to clipboard
class ImageRotate(val degrees: Float, val interpolation: Interpolation = Interpolation.BILINEAR) : Transform<PlatformBitmapImage, PlatformBitmapImage>

Rotates an image by the specified degrees.

Link copied to clipboard

Converts a platform image to a tensor.

Link copied to clipboard

Interpolation methods for image resizing operations.

Link copied to clipboard
object MNISTNorm

MNIST normalization statistics (grayscale).

Link copied to clipboard
class Normalize<T : DType, V>(ctx: ExecutionContext, val mean: FloatArray, val std: FloatArray, val channelAxis: Int = -1) : TensorTransform<T, V>

Normalizes tensor values using channel-wise mean and standard deviation.

Link copied to clipboard
class Rescale<T : DType, V>(ctx: ExecutionContext, val scale: Float = 255.0f) : TensorTransform<T, V>

Rescales tensor values by dividing by a constant factor.

Link copied to clipboard
class Reshape<T : DType, V>(ctx: ExecutionContext, val newShape: Shape) : TensorTransform<T, V>

Reshapes a tensor to a new shape without changing the data.

Link copied to clipboard
class ScaleAndShift<T : DType, V>(ctx: ExecutionContext, val scale: Float = 1.0f, val offset: Float = 0.0f) : TensorTransform<T, V>

Scales and shifts tensor values: output = input * scale + offset

Link copied to clipboard
class Squeeze<T : DType, V>(ctx: ExecutionContext, val dim: Int? = null) : TensorTransform<T, V>

Removes a dimension of size 1 at the specified position.

Link copied to clipboard
abstract class TensorTransform<T : DType, V>(ctx: ExecutionContext) : Transform<Tensor<T, V>, Tensor<T, V>>

A transform that operates on tensors using an ExecutionContext.

Link copied to clipboard
interface Transform<I, O>

A type-safe transformation operation that converts input of type I to output of type O.

Link copied to clipboard

Scope that provides tensor transform DSL with an implicit execution context.

Link copied to clipboard
class Unsqueeze<T : DType, V>(ctx: ExecutionContext, val dim: Int) : TensorTransform<T, V>

Adds a dimension of size 1 at the specified position.

Functions

Link copied to clipboard

Chains an ImageCenterCrop transform that extracts a centered square.

Link copied to clipboard

Creates a standard CIFAR-10 preprocessing pipeline.

Link copied to clipboard
fun <I, T : DType, V> Transform<I, Tensor<T, V>>.clamp(ctx: ExecutionContext, min: Float, max: Float): Transform<I, Tensor<T, V>>

Chains a Clamp transform that restricts values to a range.

Link copied to clipboard
fun <I> Transform<I, PlatformBitmapImage>.crop(top: Int = 0, bottom: Int = 0, left: Int = 0, right: Int = 0): Transform<I, PlatformBitmapImage>

Chains an ImageCrop transform that removes pixels from edges.

Link copied to clipboard
actual fun cropPlatformImage(image: PlatformBitmapImage, x: Int, y: Int, width: Int, height: Int): PlatformBitmapImage

Android implementation of image crop using Bitmap APIs.

expect fun cropPlatformImage(image: PlatformBitmapImage, x: Int, y: Int, width: Int, height: Int): PlatformBitmapImage

Crops a platform image to the specified region.

actual fun cropPlatformImage(image: PlatformBitmapImage, x: Int, y: Int, width: Int, height: Int): PlatformBitmapImage
actual fun cropPlatformImage(image: PlatformBitmapImage, x: Int, y: Int, width: Int, height: Int): PlatformBitmapImage
actual fun cropPlatformImage(image: PlatformBitmapImage, x: Int, y: Int, width: Int, height: Int): PlatformBitmapImage

JVM implementation of image crop using Java2D.

actual fun cropPlatformImage(image: PlatformBitmapImage, x: Int, y: Int, width: Int, height: Int): PlatformBitmapImage
Link copied to clipboard
fun <I, T : DType, V> Transform<I, Tensor<T, V>>.flatten(ctx: ExecutionContext, startDim: Int = 0, endDim: Int = -1): Transform<I, Tensor<T, V>>

Chains a Flatten transform.

Link copied to clipboard

Creates a standard ImageNet preprocessing pipeline.

Link copied to clipboard

Creates a standard MNIST preprocessing pipeline.

Link copied to clipboard
fun <I, T : DType, V> Transform<I, Tensor<T, V>>.normalize(ctx: ExecutionContext, mean: FloatArray, std: FloatArray, channelAxis: Int = -1): Transform<I, Tensor<T, V>>

Chains a Normalize transform that applies channel-wise normalization.

Link copied to clipboard
fun <I> Transform<I, PlatformBitmapImage>.pad(top: Int = 0, bottom: Int = 0, left: Int = 0, right: Int = 0, red: Int = 0, green: Int = 0, blue: Int = 0): Transform<I, PlatformBitmapImage>

Chains an ImagePad transform that adds pixels to edges.

Link copied to clipboard
actual fun padPlatformImage(image: PlatformBitmapImage, top: Int, bottom: Int, left: Int, right: Int, red: Int, green: Int, blue: Int): PlatformBitmapImage

Android implementation of image padding using Canvas.

expect fun padPlatformImage(image: PlatformBitmapImage, top: Int, bottom: Int, left: Int, right: Int, red: Int, green: Int, blue: Int): PlatformBitmapImage

Pads a platform image with the specified margins.

actual fun padPlatformImage(image: PlatformBitmapImage, top: Int, bottom: Int, left: Int, right: Int, red: Int, green: Int, blue: Int): PlatformBitmapImage
actual fun padPlatformImage(image: PlatformBitmapImage, top: Int, bottom: Int, left: Int, right: Int, red: Int, green: Int, blue: Int): PlatformBitmapImage
actual fun padPlatformImage(image: PlatformBitmapImage, top: Int, bottom: Int, left: Int, right: Int, red: Int, green: Int, blue: Int): PlatformBitmapImage

JVM implementation of image padding using Java2D.

actual fun padPlatformImage(image: PlatformBitmapImage, top: Int, bottom: Int, left: Int, right: Int, red: Int, green: Int, blue: Int): PlatformBitmapImage
Link copied to clipboard
fun <T> pipeline(): Identity<T>

Creates a pipeline starting point with an identity transform.

Link copied to clipboard
fun <I, T : DType, V> Transform<I, Tensor<T, V>>.rescale(ctx: ExecutionContext, scale: Float = 255.0f): Transform<I, Tensor<T, V>>

Chains a Rescale transform that divides values by a scale factor.

Link copied to clipboard
fun <I, T : DType, V> Transform<I, Tensor<T, V>>.reshape(ctx: ExecutionContext, vararg dims: Int): Transform<I, Tensor<T, V>>

Chains a Reshape transform using vararg dimensions.

fun <I, T : DType, V> Transform<I, Tensor<T, V>>.reshape(ctx: ExecutionContext, shape: Shape): Transform<I, Tensor<T, V>>

Chains a Reshape transform.

Link copied to clipboard
fun <I> Transform<I, PlatformBitmapImage>.resize(width: Int, height: Int, interpolation: Interpolation = Interpolation.BILINEAR): Transform<I, PlatformBitmapImage>

Chains an ImageResize transform.

Link copied to clipboard
actual fun resizePlatformImage(image: PlatformBitmapImage, width: Int, height: Int, interpolation: Interpolation): PlatformBitmapImage

Android implementation of image resize using Bitmap APIs.

expect fun resizePlatformImage(image: PlatformBitmapImage, width: Int, height: Int, interpolation: Interpolation): PlatformBitmapImage

Resizes a platform image to the specified dimensions.

actual fun resizePlatformImage(image: PlatformBitmapImage, width: Int, height: Int, interpolation: Interpolation): PlatformBitmapImage
actual fun resizePlatformImage(image: PlatformBitmapImage, width: Int, height: Int, interpolation: Interpolation): PlatformBitmapImage
actual fun resizePlatformImage(image: PlatformBitmapImage, width: Int, height: Int, interpolation: Interpolation): PlatformBitmapImage

JVM implementation of image resize using Java2D.

actual fun resizePlatformImage(image: PlatformBitmapImage, width: Int, height: Int, interpolation: Interpolation): PlatformBitmapImage
Link copied to clipboard
fun <I> Transform<I, PlatformBitmapImage>.rotate(degrees: Float, interpolation: Interpolation = Interpolation.BILINEAR): Transform<I, PlatformBitmapImage>

Chains an ImageRotate transform.

Link copied to clipboard
actual fun rotatePlatformImage(image: PlatformBitmapImage, degrees: Float, interpolation: Interpolation): PlatformBitmapImage

Android implementation of image rotation using Matrix.

expect fun rotatePlatformImage(image: PlatformBitmapImage, degrees: Float, interpolation: Interpolation): PlatformBitmapImage

Rotates a platform image by the specified degrees.

actual fun rotatePlatformImage(image: PlatformBitmapImage, degrees: Float, interpolation: Interpolation): PlatformBitmapImage
actual fun rotatePlatformImage(image: PlatformBitmapImage, degrees: Float, interpolation: Interpolation): PlatformBitmapImage
actual fun rotatePlatformImage(image: PlatformBitmapImage, degrees: Float, interpolation: Interpolation): PlatformBitmapImage

JVM implementation of image rotation using Java2D.

actual fun rotatePlatformImage(image: PlatformBitmapImage, degrees: Float, interpolation: Interpolation): PlatformBitmapImage
Link copied to clipboard
fun <I, T : DType, V> Transform<I, Tensor<T, V>>.scaleAndShift(ctx: ExecutionContext, scale: Float, offset: Float = 0.0f): Transform<I, Tensor<T, V>>

Chains a ScaleAndShift transform: output = input * scale + offset

Link copied to clipboard
fun <I, T : DType, V> Transform<I, Tensor<T, V>>.squeeze(ctx: ExecutionContext, dim: Int? = null): Transform<I, Tensor<T, V>>

Chains a Squeeze transform that removes size-1 dimensions.

Link copied to clipboard

Chains an ImageToTensor transform that converts the image to a tensor.

Link copied to clipboard
inline fun <T : DType, V, R> transforms(ctx: ExecutionContext, block: TransformScope<T, V>.() -> R): R

Creates a transform scope with the given execution context.

Link copied to clipboard

Chains an Unsqueeze transform that adds a dimension.