image_mixin
image_mixin
¶
Mixin for image encoders with multi-camera support.
ImageEncoderMixin
¶
Bases: ABC
Shared logic for encoders that process camera images.
Provides camera key storage, multi-camera detection, vision feature naming, and multi-camera encode dispatch. Camera modality checks are performed by experiment validation because they require observation-space metadata.
set_camera_metadata
¶
Store observation-space camera metadata for runtime camera routing.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
camera_metadata
|
dict[str, CameraMetadata]
|
Observation-space camera metadata keyed by observation key. |
required |
Source code in src/versatil/models/encoding/encoders/image_mixin.py
RGBEncoderMixin
¶
DepthEncoderMixin
¶
RGBDEncoderMixin
¶
Bases: ImageEncoderMixin
Mixin for encoders processing both RGB and depth camera images.
validate_input_metadata
¶
Validate that RGBD inputs use camera metadata.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
key
|
str
|
Observation key being validated. |
required |
metadata
|
BaseMetadata
|
Metadata from the observation space for this key. |
required |
Returns:
| Type | Description |
|---|---|
str | None
|
Error message if incompatible, None if valid. |
Source code in src/versatil/models/encoding/encoders/image_mixin.py
resize_to_target_size
¶
Resize images preserving aspect ratio and zero-pad to target size.
Scales down so the largest dimension fits the target, then zero-pads the shorter dimension. No-op if images already match the target.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
images
|
Tensor
|
Image tensor of shape (B*T, C, H, W); |
required |
target_height
|
int
|
Target height in pixels. |
required |
target_width
|
int
|
Target width in pixels. |
required |
Returns:
| Type | Description |
|---|---|
Tensor
|
Resized and padded tensor of shape (B, C, target_height, target_width). |