Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions src/lerobot/utils/visualization_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,10 @@ def log_rerun_data(
observation: An optional dictionary containing observation data to log.
action: An optional dictionary containing action data to log.
"""
max_width = os.getenv("LEROBOT_RERUN_MAX_IMAGE_WIDTH")
if max_width:
max_width = int(max_width)

if observation:
for k, v in observation.items():
if v is None:
Expand All @@ -75,6 +79,13 @@ def log_rerun_data(
for i, vi in enumerate(arr):
rr.log(f"{key}_{i}", rr.Scalars(float(vi)))
else:
if arr.ndim == 3:
h, w = arr.shape[:2]
if max_width and w > max_width:
import cv2
scale = max_width / w
new_h, new_w = int(h * scale), max_width
arr = cv2.resize(arr, (new_w, new_h), interpolation=cv2.INTER_AREA)
rr.log(key, rr.Image(arr), static=True)

if action:
Expand Down