File size: 1,026 Bytes
208faa0 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 | """Shared temporal sampling for coaf_dataset_24_25.
RGB (I2V target): 24 frames via uniform indices over raw episode steps.
Reason modalities + state + action: 25 frames via a separate uniform index
array so each reason frame k uses state[k] and action[k] from the same
raw timestep.
"""
from __future__ import annotations
import numpy as np
RGB_FRAMES = 24
REASON_FRAMES = 25
def sampled_indices(length: int, target: int) -> np.ndarray:
"""Uniformly sample `target` indices in [0, length - 1]."""
if length < 1:
raise ValueError(f"length must be >= 1, got {length}")
if target < 1:
raise ValueError(f"target must be >= 1, got {target}")
if length < target:
raise ValueError(f"length {length} < target {target}")
return np.linspace(0, length - 1, target).astype(np.int64)
def rgb_indices(num_steps: int) -> np.ndarray:
return sampled_indices(num_steps, RGB_FRAMES)
def reason_indices(num_steps: int) -> np.ndarray:
return sampled_indices(num_steps, REASON_FRAMES)
|