Download examples/plot_dataset.py from movensys/wmx-r2-command-grounded-cr3a-camera-v0: direct link, hf CLI and curl.
- Browser
- Download file 1.53 kB
-
https://huggingface.co/datasets/movensys/wmx-r2-command-grounded-cr3a-camera-v0/resolve/main/examples/plot_dataset.py
- Command line
-
hf download hf://datasets/movensys/wmx-r2-command-grounded-cr3a-camera-v0/examples/plot_dataset.py
-
curl -L -o plot_dataset.py https://huggingface.co/datasets/movensys/wmx-r2-command-grounded-cr3a-camera-v0/resolve/main/examples/plot_dataset.py
1.53 kB
| """Plot a converted numeric episode without loading video or accessing the network.""" | |
| from pathlib import Path | |
| import argparse,numpy as np,pyarrow.parquet as pq,pyarrow as pa | |
| import matplotlib | |
| matplotlib.use('Agg') | |
| import matplotlib.pyplot as plt | |
| p=argparse.ArgumentParser();p.add_argument('--root',type=Path,required=True);p.add_argument('--episode',type=int,default=162);p.add_argument('--axis',type=int,choices=range(6),default=0);p.add_argument('--output',type=Path,required=True);a=p.parse_args() | |
| tables=[pq.read_table(f,filters=[('episode_index','=',a.episode)]) for f in sorted((a.root/'data').rglob('*.parquet'))] | |
| t=pa.concat_tables([x for x in tables if len(x)]);time=np.array(t['timestamp']);cmd=np.array(t['action'].to_pylist())[:,a.axis];fb=np.array(t['observation.state'].to_pylist())[:,a.axis];err=np.array(t['observation.tracking_error'].to_pylist())[:,a.axis] | |
| fig,ax=plt.subplots(2,1,figsize=(11,6),sharex=True,layout='constrained') | |
| ax[0].plot(time,cmd,label='Command',color='#1460aa');ax[0].plot(time,fb,label='Feedback',linestyle='--',color='#d55e00');ax[0].set_ylabel('Position [configured rad]');ax[0].legend() | |
| ax[1].plot(time,err,color='#147d64');ax[1].set_ylabel('Tracking error [rad]');ax[1].set_xlabel('LeRobot regular-grid timestamp [s]') | |
| for z in ax:z.grid(alpha=.25) | |
| fig.suptitle(f'Episode {a.episode} | Joint {a.axis} | uncalibrated physical synchronization') | |
| a.output.parent.mkdir(parents=True,exist_ok=True);fig.savefig(a.output,dpi=160);plt.close(fig) | |
| print('Plot saved:',a.output) | |