lerobot icon indicating copy to clipboard operation
lerobot copied to clipboard

problem when add_frame due to validate_feature_image_or_video

Open feixyz10 opened this issue 8 months ago • 0 comments

https://github.com/huggingface/lerobot/blob/0e7caae714787489b73f1f642bcf71c0b7069fd5/lerobot/common/datasets/utils.py#L815-L824

My code:

dataset = LeRobotDataset("lerobot/svla_so100_sorting", episodes=[0, 1])
print(f"Selected episodes: {dataset.episodes}")
print(f"Number of episodes selected: {dataset.num_episodes}")
print(f"Number of frames selected: {dataset.num_frames}")

for i, item in enumerate(dataset):
    images = {k: v for k, v in item.items() if k.startswith(OBS_IMAGES)}
    state = {OBS_STATE: item[OBS_STATE]}
    action = {ACTION: item[ACTION]}
    task = {"task": item["task"]}
    frame = {**images, **state, **action}
    dataset.add_frame(frame, task=task)

when add_frame, validate_feature_image_or_video fails due to shape checking: expected_shape is channel last, and actual_shape is channel first.

change if statement to following will fix the problem:

if len(actual_shape) != 3 or (actual_shape != (c, h, w) and actual_shape != (h, w, c)) and actual_shape != (w, c, h)

feixyz10 avatar Jun 10 '25 03:06 feixyz10