Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
huggingface
GitHub Repository: huggingface/notebooks
Path: blob/main/lerobot/training-act.ipynb
4515 views
Kernel: Python 3

🤗 x 🦾: Training ACT with LeRobot Notebook

Welcome to the LeRobot ACT training notebook! This notebook provides a ready-to-run setup for training imitation learning policies using the 🤗 LeRobot library.

In this example, we train an ACT policy using a dataset hosted on the Hugging Face Hub, and optionally track training metrics with Weights & Biases (wandb).

⚙️ Requirements

  • A Hugging Face dataset repo ID containing your training data (--dataset.repo_id=YOUR_USERNAME/YOUR_DATASET)

  • Optional: A wandb account if you want to enable training visualization

  • Recommended: GPU runtime (e.g., NVIDIA A100) for faster training

⏱️ Expected Training Time

Training with the ACT policy for 100,000 steps typically takes about 1.5 hours on an NVIDIA A100 GPU. On less powerful GPUs or CPUs, training may take significantly longer.

Example Output

Model checkpoints, logs, and training plots will be saved to the specified --output_dir. If wandb is enabled, progress will also be visualized in your wandb project dashboard.

Install conda

This cell uses condacolab to bootstrap a full Conda environment inside Google Colab.

!pip install -q condacolab import condacolab condacolab.install()

Install LeRobot

This cell clones the lerobot repository from Hugging Face, installs FFmpeg (version 7.1.1), and installs the package in editable mode.

!git clone https://github.com/huggingface/lerobot.git !conda install ffmpeg=7.1.1 -c conda-forge !cd lerobot && pip install -e .

Weights & Biases login

This cell logs you into Weights & Biases (wandb) to enable experiment tracking and logging.

!wandb login

Start training ACT with LeRobot

This cell runs the train.py script from the lerobot library to train a robot control policy.

Make sure to adjust the following arguments to your setup:

  1. --dataset.repo_id=YOUR_HF_USERNAME/YOUR_DATASET: Replace this with the Hugging Face Hub repo ID where your dataset is stored, e.g., pepijn223/il_gym0.

  2. --policy.type=act: Specifies the policy configuration to use. act refers to configuration_act.py, which will automatically adapt to your dataset’s setup (e.g., number of motors and cameras).

  3. --output_dir=outputs/train/...: Directory where training logs and model checkpoints will be saved.

  4. --job_name=...: A name for this training job, used for logging and Weights & Biases.

  5. --policy.device=cuda: Use cuda if training on an NVIDIA GPU. Use mps for Apple Silicon, or cpu if no GPU is available.

  6. --wandb.enable=true: Enables Weights & Biases for visualizing training progress. You must be logged in via wandb login before running this.

!cd lerobot && python lerobot/scripts/train.py \ --dataset.repo_id=${HF_USER}/il_gym0 \ --policy.type=act \ --output_dir=outputs/train/il_sim_test0 \ --job_name=il_sim_test \ --policy.device=cuda \ --wandb.enable=true

Login into Hugging Face Hub

Now after training is done login into the Hugging Face hub and upload the last checkpoint

!huggingface-cli login
!huggingface-cli upload ${HF_USER}/il_sim_test0 \ /content/lerobot/outputs/train/il_sim_test0/checkpoints/last/pretrained_model