@tensorleap_input_encoder
code_loader.inner_leap_binder.leapbinder_decorators.tensorleap_preprocess.tensorleap_input_encoder
The tensorleap_input_encoder
decorates an Input Encoder
@tensorleap_input_encoder(name='image', channel_dim=-1)
def input_encoder(idx: int, preprocess: PreprocessResponse) -> np.ndarray
pass
Args
name
(str) with the given name of the input, e.g. image.
channel_dim
(int, optional) The dimension of the channels in the result. Default is -1 (channel last). Example: If return shape of the function is [H,W,3] -> channel_dim=-1 If return shape of the function is [3,H,W] -> channel_dim=1
Returns:
a np.ndarray typed input (without a batch dimension)
Examples
Basic Usage
import numpy as np
from code_loader.contract.datasetclasses import PreprocessResponse
from code_loader.inner_leap_binder.leapbinder_decorators import tensorleap_input_encoder
...
@tensorleap_input_encoder('image')
def input_encoder(idx: int, preprocess: PreprocessResponse) -> np.ndarray:
return preprocess.data['images'][idx].astype('float32')
Usage within the full script can be found at Dataset Script.
Guides
Full examples can be found at the Dataset Integration section of the following guides:
Last updated
Was this helpful?