Skip to content

vllm_omni.diffusion.models.gr00t.dataio.utils

apply_sin_cos_encoding

apply_sin_cos_encoding(values: ndarray) -> ndarray

Apply sin/cos encoding to values.

Parameters:

Name Type Description Default
values ndarray

Array of shape (..., D) containing values to encode

required

Returns:

Type Description
ndarray

Array of shape (..., 2*D) with [sin, cos] concatenated

This DOUBLES the dimension. For example:

Input: [v₁, v₂, v₃] with shape (..., 3) Output: [sin(v₁), sin(v₂), sin(v₃), cos(v₁), cos(v₂), cos(v₃)] with shape (..., 6)

nested_dict_to_numpy

nested_dict_to_numpy(data: Any) -> Any

Recursively convert bottom-level list-of-lists to NumPy arrays.

Parameters:

Name Type Description Default
data Any

A nested dictionary whose leaves are lists (or lists of lists).

required

Returns:

Type Description
Any

The same dictionary structure with leaf lists converted to np.ndarray.

normalize_values_meanstd

normalize_values_meanstd(
    values: ndarray, params: dict[str, ndarray]
) -> ndarray

Z-score normalize values using params['mean'] and params['std'].

Features whose std == 0 are passed through unchanged.

normalize_values_minmax

normalize_values_minmax(
    values: ndarray, params: dict[str, ndarray]
) -> ndarray

Min-max normalize values to [-1, 1] using params['min'] and params['max'].

Accepts 2D (T, D) or 3D (B, T, D) arrays. Features with min == max are emitted as 0.

parse_modality_configs

parse_modality_configs(
    modality_configs: dict[str, dict[str, ModalityConfig]],
) -> dict[str, dict[str, ModalityConfig]]

to_json_serializable

to_json_serializable(obj: Any) -> Any

Recursively convert dataclasses and numpy arrays to JSON-serializable format.

Parameters:

Name Type Description Default
obj Any

Object to convert (can be dataclass, numpy array, dict, list, etc.)

required

Returns:

Type Description
Any

JSON-serializable representation of the object

unnormalize_values_meanstd

unnormalize_values_meanstd(
    normalized_values: ndarray, params: dict[str, ndarray]
) -> ndarray

Inverse of :func:normalize_values_meanstd (x * std + mean).

Features whose std == 0 are passed through unchanged.

unnormalize_values_minmax

unnormalize_values_minmax(
    normalized_values: ndarray, params: dict[str, ndarray]
) -> ndarray

Inverse of :func:normalize_values_minmax.

Input values are clipped to [-1, 1] before being mapped back to [params['min'], params['max']].