|
| 1 | +# Learning Physically Simulated Tennis Skills from Broadcast Videos |
| 2 | + |
| 3 | +<strong>Haotian zhang</strong>, Ye Yuan, Viktor Makoviychuk, Yunrong Guo, Sanja Fidler, Xue Bin Peng, Kayvon Fatahalian |
| 4 | + |
| 5 | +SIGGRAPH 2023 (best paper honorable mention) |
| 6 | + |
| 7 | +[Paper](https://research.nvidia.com/labs/toronto-ai/vid2player3d/data/tennis_skills_main.pdf) | |
| 8 | +[Project](https://research.nvidia.com/labs/toronto-ai/vid2player3d/) | |
| 9 | +[Video](https://youtu.be/ZZVKrNs7_mk) |
| 10 | + |
| 11 | +<img src="doc/teaser.png"/> |
| 12 | + |
| 13 | +# The current release provides the implementation of the controller, including the low-level imitation policy, motion embedding and the high-level planning policy, as well as the environment setup in IsaacGym. Unfortunately, the demo can NOT run because the trained models are currently not available due to legal issues. |
| 14 | + |
| 15 | +# Environment setup |
| 16 | + |
| 17 | +### 1. Download IsaacGym and create python virtual env |
| 18 | +You can download IsaacGym Preview Release 4 from the official [site](https://developer.nvidia.com/isaac-gym). |
| 19 | +Then download Miniconda3 from [here](https://repo.anaconda.com/miniconda/Miniconda3-py37_23.1.0-1-Linux-x86_64.sh). |
| 20 | +Create a conda virtual env named `rlgpu` by running `create_conda_env_rlgpu.sh` from IsaacGym, either python3.7 or python3.8 works. |
| 21 | +Note you might need to run the following command or add it to your `.bashrc` if you encounter the error `ImportError: libpython3.7m.so.1.0: cannot open shared object file: No such file or directory` when running IsaacGym. |
| 22 | +``` |
| 23 | +export LD_LIBRARY_PATH=<YOUR CONDA PATH>envs/rlgpu/lib/ |
| 24 | +``` |
| 25 | + |
| 26 | +### 2. Install dependencies |
| 27 | +Enter the created virtual env and run the install script. |
| 28 | +``` |
| 29 | +conda activate rlgpu |
| 30 | +bash install.sh |
| 31 | +``` |
| 32 | + |
| 33 | +### 3. Install [smpl_visualizer](https://github.com/Haotianz94/smpl_visualizer) for visualizing results |
| 34 | +Git clone and then run |
| 35 | +``` |
| 36 | +bash install.sh |
| 37 | +``` |
| 38 | + |
| 39 | +### 4. Download data/checkpoints |
| 40 | + |
| 41 | +Download [data](https://drive.google.com/drive/folders/1kkM9tl1T3dXZbvh5oYHSerL0JkgaL1Mi?usp=sharing) into `vid2player3d/data`. |
| 42 | + |
| 43 | +Download checkpoints of motion VAE and trained polices into `vid2player3d/results` (currently unavailable). |
| 44 | + |
| 45 | +Download SMPL [models](https://download.is.tue.mpg.de/download.php?domain=smpl&sfile=SMPL_python_v.1.0.0.zip) (male and female models) into `smpl_visualizer/data/smpl` after registering and rename the files as `SMPL_MALE.pkl` and `SMPL_FEMALE.pkl`. |
| 46 | + |
| 47 | +# Test with trained policies |
| 48 | +### Single player |
| 49 | +In the single player setting, the player will react to consecutive incoming tennis balls from the other side. |
| 50 | +The script below runs the simulation and renders the result online. The simulation will be reset after 300 frames. You can change the player by chaning`--cfg` to `djokovic` or `nadal`. |
| 51 | +``` |
| 52 | +python vid2player/run.py --cfg federer --rl_device cuda:0 --test --num_envs 1 --episode_length 300 --seed 0 --checkpoint latest --enable_shadow |
| 53 | +``` |
| 54 | + |
| 55 | +The script below will run the simulations in batch and render the result videos offline and saved into `out/video`. You can also change `--record` to `--record_scenepic`, which will save the result into an interactive html file under `out/html`. Note that the saved html file is large and may take seconds to load. |
| 56 | +``` |
| 57 | +python vid2player/run.py --cfg federer --rl_device cuda:0 --test --num_envs 8192 --episode_length 300 --seed 0 --checkpoint latest --select_best --enable_shadow --num_rec_frames 300 --num_eg 5 --record --headless |
| 58 | +``` |
| 59 | + |
| 60 | +### Dual player |
| 61 | +In the dual player setting, the two players will play tennis rally against each other. |
| 62 | +The script below runs the simulation and renders the result online. The simulation will be reset if the ball is missed or out. You can change the players by changing `--cfg` to `nadal_djokovic`. More player settings will be added soon. |
| 63 | +``` |
| 64 | +python vid2player/run.py --cfg federer_djokovic --rl_device cuda:0 --test --num_envs 2 --episode_length 10000 --seed 0 --checkpoint latest --enable_shadow |
| 65 | +``` |
| 66 | + |
| 67 | +The script below will run the simulations in batch and render the result videos offline and saved into `out/video`. |
| 68 | +``` |
| 69 | +python vid2player/run.py --cfg federer_djokovic --rl_device cuda:0 --test --num_envs 8192 --episode_length 10000 --seed 0 --checkpoint latest --enable_shadow --headless --num_rec_frames 600 --num_eg 5 --record |
| 70 | +``` |
| 71 | + |
| 72 | + |
| 73 | +# Retrain the high-level policy |
| 74 | +We also provide code for training the high-level policy using Federer's motion VAE. As described in the paper, we design a curriculum trained in three stages. You can run the following script to execute the curriculum training. |
| 75 | +The script assumes a GPU with memory >= 24GB and it takes about 2 days to finish on a single A5000. |
| 76 | +``` |
| 77 | +python vid2player/run.py --cfg federer_train_stage_1 --rl_device cuda:0 --headless |
| 78 | +python vid2player/run.py --cfg federer_train_stage_2 --rl_device cuda:0 --headless |
| 79 | +python vid2player/run.py --cfg federer_train_stage_3 --rl_device cuda:0 --headless |
| 80 | +``` |
| 81 | + |
| 82 | + |
| 83 | +# Citation |
| 84 | +``` |
| 85 | +@article{ |
| 86 | + zhang2023vid2player3d, |
| 87 | + author = {Zhang, Haotian and Yuan, Ye and Makoviychuk, Viktor and Guo, Yunrong and Fidler, Sanja and Peng, Xue Bin and Fatahalian, Kayvon}, |
| 88 | + title = {Learning Physically Simulated Tennis Skills from Broadcast Videos}, |
| 89 | + journal = {ACM Trans. Graph.}, |
| 90 | + issue_date = {August 2023}, |
| 91 | + numpages = {14}, |
| 92 | + doi = {10.1145/3592408}, |
| 93 | + publisher = {ACM}, |
| 94 | + address = {New York, NY, USA}, |
| 95 | + keywords = {physics-based character animation, imitation learning, reinforcement learning}, |
| 96 | +} |
| 97 | +``` |
| 98 | + |
| 99 | +# Contact |
| 100 | +For any question regarding this project, please contact Haotian Zhang via [email protected]. |
0 commit comments