Skip to content

Official PyTorch Implementation of "BodyGen: Advancing Towards Efficient Embodiment Co-Design" [ICLR 2025 Spotlight]

License

Notifications You must be signed in to change notification settings

GenesisOrigin/BodyGen

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

21 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

BodyGen: Advancing Towards Efficient Embodiment Co-Design

· Paper · Code · Website ·

This repository contains the PyTorch implementation of "BodyGen: Advancing Towards Efficient Embodiment Co-Design." (ICLR 2025, Spotlight)



🛠️ Setup

Let's start with python 3.9. It's recommend to create a conda env:

Create a new conda environment

conda create -n BodyGen python=3.9
conda activate BodyGen

Install for MuJoCo Simulator and mujoco-py (Important)

Install mujoco-py following the instruction here.

Set the following environment variable to avoid problems with multiprocess trajectory sampling:

export OMP_NUM_THREADS=1

(Optional) For MacOS user, you can follow the README_FOR_MAC.md to install MuJoCo on M1/M2/M3 Mac, which is helpful for embodied agents visualization.

Install dependencies

pip install -r requirements.txt

Note you may have to follow https://pytorch.org/ setup instructions for installation on your own machine.

👀 Visualization



Please refer to this website for more visualization results. If you want to visualize the pretrained models, please refer to the following section.

(Optional) Pretrained Models for Playing

We also provide pretrained models in BodyGen/pretrained_models for visualization.

  • You can download pretrained models from Google Drive

  • Once the pretrained_models.zip file is downloaded, unzip it under the folder BodyGen of this repo:

unzip pretrained_models.zip

After you unzip the file, an example directory hierarchy is:

assets/
design_opt/
...
pretrained_models/
  |-- cheetah/
  |-- crawler/
  |-- ...
  |-- walker-regular/
...
scripts/

Our pretrained models are also available on Hugging Face. You can download the pretrained models, and place the pretrained_models folder under the root directory (./BodyGen) of this repo.

Interactive Visualization Locally

If you have a GUI display, you can run the following command to visualize the pretrained model:

python design_opt/eval.py --train_dir <path_of_model_folder>

For example, you can use pretrained_models to visualize the co-design embodied agent on cheetah generated by BodyGen:

python design_opt/eval.py --train_dir /Path/to/BodyGen/pretrained_models/cheetah

Press S to slow the agent, and F to speed up.

💻 Training

cd BodyGen
chmod 777 scripts/Run_BodyGen.sh
./scripts/Run_BodyGen.sh

Use the scripts scripts/Run_BodyGen.sh, which contain preconfigured arguments and hyperparameters for all the experiments in the paper. Experiments use Hydra to manage configuration.

Visualizing results requires wandb: configure project name with the project key in BodyGen/design_opt/conf/config.yaml.

As an example of how to run, this runs BodyGen on the crawler environment:

EXPT="crawler"
OMP_NUM_THREADS=1 python -m design_opt.train -m cfg=$EXPT group=$EXPT

Replace crawler with {crawler, terraincrosser, cheetah, swimmer, glider-regular, glider-medium, glider-hard, walker-regular, walker-medium, walker-hard} to train other environments.

  • OMP_NUM_THREADS=1 is essential to prevent CPU ops from hanging.

  • The environment is selected with the cfg= flag, each of which corresponds to a YAML file in BodyGen/design_opt/cfg. See that folder for the list of available experiments.

  • Other hyperparameters are explained in BodyGen/design_opt/conf/config.yaml and our paper.

🙏 Acknowledgement

📚 Citation

If you find our work useful in your research, please consider citing:

@inproceedings{
  lu2025bodygen,
  title={BodyGen: Advancing Towards Efficient Embodiment Co-Design},
  author={Haofei Lu and Zhe Wu and Junliang Xing and Jianshu Li and Ruoyu Li and Zhe Li and Yuanchun Shi},
  booktitle={The Thirteenth International Conference on Learning Representations},
  year={2025},
  url={https://openreview.net/forum?id=cTR17xl89h}
}

🏷️ License

Please see the license for further details.

About

Official PyTorch Implementation of "BodyGen: Advancing Towards Efficient Embodiment Co-Design" [ICLR 2025 Spotlight]

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published