Skip to content

daft.functions.image_to_tensor#

image_to_tensor #

image_to_tensor(image: Expression) -> Expression

Convert an image expression to a tensor, inferring dtype and shape.

This is safer than casting to a tensor dtype manually, since Daft can infer the correct pixel dtype (e.g. UInt8) and determine whether a fixed-shape tensor is appropriate.

Source code in daft/functions/image.py
103
104
105
106
107
108
109
def image_to_tensor(image: Expression) -> Expression:
    """Convert an image expression to a tensor, inferring dtype and shape.

    This is safer than casting to a tensor dtype manually, since Daft can infer the correct
    pixel dtype (e.g. UInt8) and determine whether a fixed-shape tensor is appropriate.
    """
    return Expression._call_builtin_scalar_fn("to_tensor", image)