Stack#

class deeptrack.features.Stack(value: Any | Callable[[...], Any], **kwargs: Dict[str, Any])#

Bases: Feature

Stacks the input and the value.

This feature combines the output of the input data (image) and the value produced by the specified feature (value). The resulting output is a list where the elements of the image and value are concatenated.

If either the input (image) or the value is a single Image object, it is automatically converted into a list to maintain consistency in the output format.

If B is a feature, Stack can be visualized as:

>>>   A >> Stack(B) = [*A(), *B()]

Parameters#

valuePropertyLike[Any]

The feature or data to stack with the input.

**kwargsDict[str, Any]

Additional arguments passed to the parent Feature class.

Attributes#

__distributed__bool

Indicates whether this feature distributes computation across inputs. Always False for Stack, as it processes all inputs at once.

Example#

Start by creating a pipeline using Stack:

>>> from deeptrack.features import Stack, Value
>>> pipeline = Value([1, 2, 3]) >> Stack(value=[4, 5])
>>> print(pipeline.resolve())
[1, 2, 3, 4, 5]

Equivalently, this pipeline can be created using:

>>> pipeline = Value([1, 2, 3]) & [4, 5]
>>> pipeline = [4, 5] & Value([1, 2, 3])  # Different result.

Methods Summary

get(image, value, **kwargs)

Concatenate the input with the value.

Methods Documentation

get(image: Any | List[Any], value: Any | List[Any], **kwargs: Dict[str, Any]) List[Any]#

Concatenate the input with the value.

It ensures that both the input (image) and the value (value) are treated as lists before concatenation.

Parameters#

imageAny or List[Any]

The input data to stack. Can be a single element or a list.

valueAny or List[Any]

The feature or data to stack with the input. Can be a single element or a list.

**kwargsDict[str, Any]

Additional keyword arguments (not used here).

Returns#

List[Any]

A list containing all elements from image and value.