π0 github地址
在做:π0基于自己的数据集微调 Fine-Tuning Base Models on Your Own Data 的时候遇到各种报错,记录一下。
推荐教程:π0的微调——如何基于各种开源数据集、以及私有数据集微调通用VLA π0(含我司七月的微调实践及在机械臂上的部署)
convert_libero_data_to_lerobot.py 报错:ImportError: cannot import name ‘LEROBOT_HOME’ from ‘lerobot.common.datasets.lerobot_dataset’
modified_libero_rlds数据集我放在了~/modified_libero_rlds
这个路径
所以执行的代码是
uv run examples/libero/convert_libero_data_to_lerobot.py --data_dir ~/modified_libero_rlds
为了方便,还是写上/path/to/your/libero/data,下一节有个 No module named 'tensorflow_datasets’的报错,需要把uv run
改成python
,即python examples/libero/convert_libero_data_to_lerobot.py --data_dir ~/modified_libero_rlds
执行uv run examples/libero/convert_libero_data_to_lerobot.py --data_dir /path/to/your/libero/data
报错:
Traceback (most recent call last):
File “/root/openpi/examples/libero/convert_libero_data_to_lerobot.py”, line 23, in
from lerobot.common.datasets.lerobot_dataset import LEROBOT_HOME
ImportError: cannot import name ‘LEROBOT_HOME’ from ‘lerobot.common.datasets.lerobot_dataset’
解决方法:
convert_libero_data_to_lerobot.py
中注释掉from lerobot.common.datasets.lerobot_dataset import LEROBOT_HOME
,然后补上LEROBOT_HOME还有REPO_NAME 的定义
修改convert_libero_data_to_lerobot.py
如下:
#from lerobot.common.datasets.lerobot_dataset import LEROBOT_HOME 注释掉
from lerobot.common.datasets.lerobot_dataset import LeRobotDataset
import tensorflow_datasets as tfds
import tyrofrom pathlib import Path # 要加上
LEROBOT_HOME = Path("\~/modified_libero_rlds") # 随便放,不一定是libero数据集路径
REPO_NAME = Path("haha") # 先随便起个名
RAW_DATASET_NAMES = ["libero_10_no_noops","libero_goal_no_noops","libero_object_no_noops","libero_spatial_no_noops",
]
def main(data_dir: str, *, push_to_hub: bool = False): # data_dir是libero数据集路径# Clean up any existing dataset in the output directoryoutput_path = LEROBOT_HOME / REPO_NAMEif output_path.exists(): # 如果这里报错了,就是haha这个文件夹存在了,把它删掉重跑即可shutil.rmtree(output_path)
记得如果用os.join.path
的话会报错如下,需要用from pathlib import Path
Traceback (most recent call last):
File “/root/openpi/examples/libero/convert_libero_data_to_lerobot.py”, line 106, in
tyro.cli(main)
File “/home/vipuser/miniconda3/lib/python3.11/site-packages/tyro/_cli.py”, line 229, in cli
return run_with_args_from_cli()
^^^^^^^^^^^^^^^^^^^^^^^^
File “/root/openpi/examples/libero/convert_libero_data_to_lerobot.py”, line 39, in main
output_path = LEROBOT_HOME / REPO_NAME
~~~^
TypeError: unsupported operand type(s) for /: ‘str’ and ‘str’
convert_libero_data_to_lerobot.py 报错:ModuleNotFoundError: No module named ‘tensorflow_datasets’ 和 Missing features: {‘task’}
执行uv run examples/libero/convert_libero_data_to_lerobot.py --data_dir /path/to/your/libero/data
报错:
Traceback (most recent call last):
File “/root/openpi/examples/libero/convert_libero_data_to_lerobot.py”, line 25, in
import tensorflow_datasets as tfds
ModuleNotFoundError: No module named ‘tensorflow_datasets’
查看到相关issues:https://github.com/Physical-Intelligence/openpi/issues/354 得知,要改成:
python examples/libero/convert_libero_data_to_lerobot.py --data_dir /path/to/your/libero/data
,改完后会有一个task的报错Missing features: {'task'}
:
继续修改
convert_libero_data_to_lerobot.py
:
for raw_dataset_name in RAW_DATASET_NAMES:raw_dataset = tfds.load(raw_dataset_name, data_dir=data_dir, split="train")for episode in raw_dataset:for step in episode["steps"].as_numpy_iterator():dataset.add_frame({"image": step["observation"]["image"],"wrist_image": step["observation"]["wrist_image"],"state": step["observation"]["state"],"actions": step["action"],"task": step["language_instruction"].decode(), #补上这句})dataset.save_episode() #记得这里参数有个task=xxx的,也要删掉
就ok了,开始将Libero数据集转换为LeRobot数据集v2.0格式