SmolVLA

SmolVLA 是 Hugging Face 为机器人打造的轻量级基础模型。它专为在 LeRobot dataset 上轻松 fine-tune 而设计,可帮助你加速开发!

SmolVLA architecture.
图 1. SmolVLA 的输入包括:(i) 多个相机视角,(ii) 机器人当前的 感觉运动 state,以及 (iii) 自然语言指令,这些输入被编码为上下文特征, 用于在生成 action chunk 时对 action expert 进行条件设置。

设置你的环境

  1. 按照我们的安装指南安装 LeRobot。

  2. 通过运行以下命令安装 SmolVLA 依赖:

    pip install -e ".[smolvla]"

收集 dataset

SmolVLA 是一个基础模型,因此要在你的环境中获得最佳性能,需要在自己的数据上进行 fine-tune。 作为起点,我们建议录制约 50 个 episode 的任务 demonstration。请按照我们的指南开始:录制 dataset

在你的 dataset 中,请确保针对你引入的每个变体(例如,如果是立方体抓取放置任务,就是立方体在桌子上的位置)都有足够的 demonstration。

我们建议查看下面链接的 dataset,它来自 SmolVLA 论文,可作为参考:

🔗 SVLA SO100 PickPlace

在这个 dataset 中,我们跨 5 个不同的立方体位置录制了 50 个 episode。对于每个位置,我们收集了 10 个 episode 的抓取放置交互。这种重复多次每个变体的结构帮助模型更好地泛化。我们曾尝试过 25 个 episode 的类似 dataset,但数量不够,导致性能不佳。因此,数据的质量和数量绝对是关键。 当你的 dataset 在 Hub 上可用后,就可以使用我们的 fine-tune 脚本,让 SmolVLA 适配你的应用。

在你的数据上 fine-tune SmolVLA

使用我们的预训练 450M 模型 smolvla_base,并在你的数据上对其进行 fine-tune。 在单个 A100 GPU 上将模型训练 20k 步大约需要 4 小时。你应该根据性能和你的用例来调整步数。

如果你没有 GPU 设备,可以使用我们在 Google Colab 上的笔记本进行训练

使用 --dataset.repo_id 将你的 dataset 传递给训练脚本。如果你想测试自己的安装,请运行以下命令,其中我们使用了为 SmolVLA 论文收集的 dataset 之一。

cd lerobot && lerobot-train \
  --policy.path=lerobot/smolvla_base \
  --dataset.repo_id=${HF_USER}/mydataset \
  --batch_size=64 \
  --steps=20000 \
  --output_dir=outputs/train/my_smolvla \
  --job_name=my_smolvla_training \
  --policy.device=cuda \
  --wandb.enable=true
你可以从小批量大小开始,并在 GPU 允许的情况下逐步增大, 只要加载时间保持较短即可。

fine-tune 是一门艺术。若要全面了解 fine-tune 的选项,请运行

lerobot-train --help

Comparison of SmolVLA across task variations.
图 2:SmolVLA 在不同任务变体上的对比。从左到右: (1) 抓取放置立方体计数,(2) 抓取放置立方体计数,(3) 扰动下的 抓取放置立方体计数,以及 (4) 在真实 SO101 上抓取放置 乐高积木的泛化表现。

评估 fine-tune 后的模型并实时运行

与录制 episode 时类似,建议你登录 HuggingFace Hub。你可以按照相应的步骤操作:录制 dataset。 登录后,你就可以在环境中按以下方式运行 inference:

lerobot-rollout \
  --strategy.type=base \
  --robot.type=so101_follower \
  --robot.port=/dev/ttyACM0 \ # <- Use your port
  --robot.id=my_blue_follower_arm \ # <- Use your robot id
  --robot.cameras="{ front: {type: opencv, index_or_path: 8, width: 640, height: 480, fps: 30}}" \ # <- Use your cameras
  --task="Grasp a lego block and put it in the bin." \ # <- Use the same task description you used in your dataset recording
  # <- RTC optional, use when running on low power hardware \
  # --inference.type=rtc \
  # --inference.rtc.execution_horizon=10 \
  # --inference.rtc.max_guidance_weight=10.0 \
  # <- Teleop optional if you want to teleoperate in between episodes \
  # --teleop.type=so100_leader \
  # --teleop.port=/dev/ttyACM0 \
  # --teleop.id=my_red_leader_arm \
  # --display_data=true #optional use if you want to see the camera stream \
  --policy.path=HF_USER/FINETUNE_MODEL_NAME # <- Use your fine-tuned model

根据你的评估设置,你可以为评估套件配置要录制的时长和 episode 数。

在 GitHub 上更新