observation_preprocessor
observation_preprocessor
¶
Observation preprocessing for the inference pipeline.
ObservationPreprocessor
¶
ObservationPreprocessor(camera_keys, state_keys, has_language, camera_metadata, compression_type=value, rotate_images=False, depth_clamp_ranges=None, state_dtypes=None)
Parses server responses and transforms observations into model-ready tensors.
Handles single and multi-environment responses, RGB normalization, depth clamping, and albumentations transforms.
Initialize the observation preprocessor.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
camera_keys
|
list[str]
|
Camera observation keys (RGB + optional depth). |
required |
state_keys
|
list[str]
|
Numerical non-image observation keys. |
required |
has_language
|
bool
|
Whether language instructions are expected. |
required |
camera_metadata
|
dict[str, CameraMetadata]
|
Per-camera metadata with training-time image dimensions. |
required |
compression_type
|
str
|
Compression format used by the server for images. |
value
|
rotate_images
|
bool
|
Whether to flip images 180 degrees. |
False
|
depth_clamp_ranges
|
dict[str, tuple[float, float]] | None
|
Optional per-camera (min, max) depth clamps. |
None
|
state_dtypes
|
dict[str, str] | None
|
Numpy dtype names per state key from the training observation metadata; unlisted keys parse as float32. |
None
|
Source code in src/versatil/inference/observation_preprocessor.py
parse_response
¶
Parse server response into per-environment observation dicts.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
response
|
dict
|
Raw server response. |
required |
Returns:
| Type | Description |
|---|---|
dict[int, dict[str, ndarray | str]]
|
Dict mapping environment index to observation dict. |
Source code in src/versatil/inference/observation_preprocessor.py
transform_camera_observations
¶
Transform a temporal sequence of camera images into model-ready tensors.
Note
Uses ImageProcessor for per-camera resize and normalization. Depth images are clamped to their camera's configured range.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
recent_observations
|
dict[str, list]
|
Dict mapping key to list of images per timestep. |
required |
Returns:
| Type | Description |
|---|---|
dict[str, Tensor]
|
Dict mapping camera key to tensor (observation_horizon, C, H, W). |