Skip to content

Commit 2106ae4

Browse files
authored
[Vizualisation] independent column names (huggingface#783)
1 parent 7fcc844 commit 2106ae4

File tree

2 files changed

+9
-7
lines changed

2 files changed

+9
-7
lines changed

lerobot/scripts/visualize_dataset_html.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -245,16 +245,17 @@ def get_episode_data(dataset: LeRobotDataset | IterableNamespace, episode_index)
245245
if isinstance(dataset, LeRobotDataset)
246246
else dataset.features[column_name].shape[0]
247247
)
248-
header += [f"{column_name}_{i}" for i in range(dim_state)]
249248

250249
if "names" in dataset.features[column_name] and dataset.features[column_name]["names"]:
251250
column_names = dataset.features[column_name]["names"]
252251
while not isinstance(column_names, list):
253252
column_names = list(column_names.values())[0]
254253
else:
255-
column_names = [f"motor_{i}" for i in range(dim_state)]
254+
column_names = [f"{column_name}_{i}" for i in range(dim_state)]
256255
columns.append({"key": column_name, "value": column_names})
257256

257+
header += column_names
258+
258259
selected_columns.insert(0, "timestamp")
259260

260261
if isinstance(dataset, LeRobotDataset):

lerobot/templates/visualize_dataset_template.html

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -246,14 +246,16 @@ <h1 class="text-xl font-bold mt-4 font-mono">
246246
<div class="flex gap-x-2 max-w-64 font-semibold px-1 break-all">
247247
<input type="checkbox" :checked="isRowChecked(rowIndex)"
248248
@change="toggleRow(rowIndex)">
249-
<p x-text="`${rowLabels[rowIndex]}`"></p>
250249
</div>
251250
</td>
252251
<template x-for="(cell, colIndex) in row">
253252
<td x-show="cell" class="border border-slate-700">
254-
<div class="flex gap-x-2 w-24 justify-between px-2" :class="{ 'hidden': cell.isNull }">
255-
<input type="checkbox" x-model="cell.checked" @change="updateTableValues()">
256-
<span x-text="`${!cell.isNull ? cell.value.toFixed(2) : null}`"
253+
<div class="flex gap-x-2 justify-between px-2" :class="{ 'hidden': cell.isNull }">
254+
<div class="flex gap-x-2">
255+
<input type="checkbox" x-model="cell.checked" @change="updateTableValues()">
256+
<span x-text="`${!cell.isNull ? cell.label : null}`"></span>
257+
</div>
258+
<span class="w-14 text-right" x-text="`${!cell.isNull ? (typeof cell.value === 'number' ? cell.value.toFixed(2) : cell.value) : null}`"
257259
:style="`color: ${cell.color}`"></span>
258260
</div>
259261
</td>
@@ -295,7 +297,6 @@ <h1 class="text-xl font-bold mt-4 font-mono">
295297
videosKeys: {{ videos_info | map(attribute='filename') | list | tojson }},
296298
videosKeysSelected: [],
297299
columns: {{ columns | tojson }},
298-
rowLabels: {{ columns | tojson }}.reduce((colA, colB) => colA.value.length > colB.value.length ? colA : colB).value,
299300

300301
// alpine initialization
301302
init() {

0 commit comments

Comments
 (0)