Spaces:
Build error
Build error
File size: 8,297 Bytes
c5f8b57 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 |
# Motion VQ-Trans
Pytorch implementation of paper "Generating Human Motion from Textual Descriptions with High Quality Discrete Representation"
[[Notebook Demo]](https://colab.research.google.com/drive/1tAHlmcpKcjg_zZrqKku7AfpqdVAIFrF8?usp=sharing)
![teaser](img/Teaser.png)
If our project is helpful for your research, please consider citing : (todo)
```
@inproceedings{shen2020ransac,
title={RANSAC-Flow: generic two-stage image alignment},
author={Shen, Xi and Darmon, Fran{\c{c}}ois and Efros, Alexei A and Aubry, Mathieu},
booktitle={16th European Conference on Computer Vision}
year={2020}
}
```
## Table of Content
* [1. Visual Results](#1-visual-results)
* [2. Installation](#2-installation)
* [3. Quick Start](#3-quick-start)
* [4. Train](#4-train)
* [5. Evaluation](#5-evaluation)
* [6. Motion Render](#6-motion-render)
* [7. Acknowledgement](#7-acknowledgement)
* [8. ChangLog](#8-changlog)
## 1. Visual Results (More results can be found in our project page (todo))
![visualization](img/ALLvis.png)
## 2. Installation
### 2.1. Environment
<!-- Our model can be learnt in a **single GPU GeForce GTX 1080Ti** (12G).
Install Pytorch adapted to your CUDA version :
* [Pytorch 1.2.0](https://pytorch.org/get-started/previous-versions/#linux-and-windows-1)
* [Torchvision 0.4.0](https://pytorch.org/get-started/previous-versions/#linux-and-windows-1)
Other dependencies (tqdm, visdom, pandas, kornia, opencv-python) :
``` Bash
bash requirement.sh
``` -->
Our model can be learnt in a **single GPU V100-32G**
```bash
conda env create -f environment.yml
conda activate VQTrans
```
The code was tested on Python 3.8 and PyTorch 1.8.1.
### 2.2. Dependencies
```bash
bash dataset/prepare/download_glove.sh
```
### 2.3. Datasets
We are using two 3D human motion-language dataset: HumanML3D and KIT-ML. For both datasets, you could find the details as well as download link [[here]](https://github.com/EricGuo5513/HumanML3D).
Take HumanML3D for an example, the file directory should look like this:
```
./dataset/HumanML3D/
βββ new_joint_vecs/
βββ texts/
βββ Mean.npy # same as in [HumanML3D](https://github.com/EricGuo5513/HumanML3D)
βββ Std.npy # same as in [HumanML3D](https://github.com/EricGuo5513/HumanML3D)
βββ train.txt
βββ val.txt
βββ test.txt
βββ train_val.txt
βββall.txt
```
### 2.4. Motion & text feature extractors:
We use the same extractors provided by [t2m](https://github.com/EricGuo5513/text-to-motion) to evaluate our generated motions. Please download the extractors.
```bash
bash dataset/prepare/download_extractor.sh
```
### 2.5. Pre-trained models
The pretrained model files will be stored in the 'pretrained' folder:
```bash
bash dataset/prepare/download_model.sh
```
<!-- Quick download :
``` Bash
cd model/pretrained
bash download_model.sh
```
For more details of the pre-trained models, see [here](https://github.com/XiSHEN0220/RANSAC-Flow/blob/master/model/pretrained) -->
### 2.6. Render motion (optional)
If you want to render the generated motion, you need to install:
```bash
sudo sh dataset/prepare/download_smpl.sh
conda install -c menpo osmesa
conda install h5py
conda install -c conda-forge shapely pyrender trimesh mapbox_earcut
```
## 3. Quick Start
A quick start guide of how to use our code is available in [demo.ipynb](https://colab.research.google.com/drive/1tAHlmcpKcjg_zZrqKku7AfpqdVAIFrF8?usp=sharing)
<p align="center">
<img src="img/demo.png" width="400px" alt="demo">
</p>
## 4. Train
Note that, for kit dataset, just need to set '--dataname kit'.
### 4.1. VQ-VAE
The results are saved in the folder output_vqfinal.
<details>
<summary>
VQ training
</summary>
```bash
python3 train_vq.py \
--batch-size 256 \
--lr 2e-4 \
--total-iter 300000 \
--lr-scheduler 200000 \
--nb-code 512 \
--down-t 2 \
--depth 3 \
--dilation-growth-rate 3 \
--out-dir output \
--dataname t2m \
--vq-act relu \
--quantizer ema_reset \
--loss-vel 0.5 \
--recons-loss l1_smooth \
--exp-name VQVAE
```
</details>
### 4.2. Motion-Transformer
The results are saved in the folder output_transformer.
<details>
<summary>
MoTrans training
</summary>
```bash
python3 train_t2m_trans.py \
--exp-name VQTransformer \
--batch-size 128 \
--num-layers 9 \
--embed-dim-gpt 1024 \
--nb-code 512 \
--n-head-gpt 16 \
--block-size 51 \
--ff-rate 4 \
--drop-out-rate 0.1 \
--resume-pth output/VQVAE/net_last.pth \
--vq-name VQVAE \
--out-dir output \
--total-iter 300000 \
--lr-scheduler 150000 \
--lr 0.0001 \
--dataname t2m \
--down-t 2 \
--depth 3 \
--quantizer ema_reset \
--eval-iter 10000 \
--pkeep 0.5 \
--dilation-growth-rate 3 \
--vq-act relu
```
</details>
## 5. Evaluation
### 5.1. VQ-VAE
<details>
<summary>
VQ eval
</summary>
```bash
python3 VQ_eval.py \
--batch-size 256 \
--lr 2e-4 \
--total-iter 300000 \
--lr-scheduler 200000 \
--nb-code 512 \
--down-t 2 \
--depth 3 \
--dilation-growth-rate 3 \
--out-dir output \
--dataname t2m \
--vq-act relu \
--quantizer ema_reset \
--loss-vel 0.5 \
--recons-loss l1_smooth \
--exp-name TEST_VQVAE \
--resume-pth output/VQVAE/net_last.pth
```
</details>
### 5.2. Motion-Transformer
<details>
<summary>
MoTrans eval
</summary>
```bash
python3 GPT_eval_multi.py \
--exp-name TEST_VQTransformer \
--batch-size 128 \
--num-layers 9 \
--embed-dim-gpt 1024 \
--nb-code 512 \
--n-head-gpt 16 \
--block-size 51 \
--ff-rate 4 \
--drop-out-rate 0.1 \
--resume-pth output/VQVAE/net_last.pth \
--vq-name VQVAE \
--out-dir output \
--total-iter 300000 \
--lr-scheduler 150000 \
--lr 0.0001 \
--dataname t2m \
--down-t 2 \
--depth 3 \
--quantizer ema_reset \
--eval-iter 10000 \
--pkeep 0.5 \
--dilation-growth-rate 3 \
--vq-act relu \
--resume-gpt output/VQTransformer/net_best_fid.pth
```
</details>
## 6. Motion Render
<details>
<summary>
Motion Render
</summary>
You should input the npy folder address and the motion names. Here is an example:
```bash
python3 render_final.py --filedir output/TEST_VQTransformer/ --motion-list 000019 005485
```
</details>
### 7. Acknowledgement
We appreciate helps from :
* Public code like [text-to-motion](https://github.com/EricGuo5513/text-to-motion), [TM2T](https://github.com/EricGuo5513/TM2T) etc.
### 8. ChangLog
<!-- # VQGPT
```
# VQ during training OT
/apdcephfs_cq2/share_1290939/jirozhang/anaconda3/envs/motionclip/bin/python3 train_251_cnn_all.py \
--batch-size 128 \
--exp-name xxxxxx \
--lr 2e-4 \
--total-iter 300000 \
--lr-scheduler 200000 \
--nb-code 512 \
--down-t 2 \
--depth 5 \
--out-dir /apdcephfs_cq2/share_1290939/jirozhang/VQCNN_HUMAN/ \
--dataname t2m \
--vq-act relu \
--quantizer ot \
--ot-temperature 1 \
--ot-eps 0.5 \
--commit 0.001 \
```
```
# VQ251 training baseline
/apdcephfs_cq2/share_1290939/jirozhang/anaconda3/envs/motionclip/bin/python3 train_251_cnn_all.py \
--batch-size 128 \
--exp-name VQ263_300K_512cb_down4_t2m_ema_relu_test \
--lr 2e-4 \
--total-iter 300000 \
--lr-scheduler 200000 \
--nb-code 512 \
--down-t 2 \
--depth 5 \
--out-dir /apdcephfs_cq2/share_1290939/jirozhang/VQCNN_HUMAN/ \
--dataname t2m \
--vq-act relu \
--quantizer ema \
```
```bash
# gpt training + noise
/apdcephfs_cq2/share_1290939/jirozhang/anaconda3/envs/motionclip/bin/python3 train_gpt_cnn_noise.py \
--exp-name GPT_VQ_300K_512cb_down4_t2m_ema_relu_bs128_ws64_fid_mask1_08 \
--batch-size 128 \
--num-layers 4 \
--block-size 51 \
--n-head-gpt 8 \
--ff-rate 4 \
--drop-out-rate 0.1 \
--resume-pth output_vqhuman/VQ_300K_512cb_down4_t2m_ema_relu_bs128_ws64/net_best_fid.pth \
--vq-name VQ_300K_512cb_down4_t2m_ema_relu_bs128_ws64_fid_mask1_08 \
--total-iter 300000 \
--lr-scheduler 150000 \
--lr 0.0001 \
--if-auxloss \
--dataname t2m \
--down-t 2 \
--depth 5 \
--quantizer ema \
--eval-iter 5000 \
--pkeep 0.8
```
### Visualize VQ (Arch Taming) in HTML
* Generate motion. This will save generated motions in `./visual_results/vel05_taming_l1s`
```
python vis.py --dataname t2m --resume-pth /apdcephfs_cq2/share_1290939/jirozhang/VQ_t2m_bailando_relu_NoNorm_dilate3_vel05_taming_l1s/net_last.pth --visual-name vel05_taming_l1s --vis-gt --nb-vis 20
```
* Make a Webpage. Go to visual_html.py, modify the name, then run :
```
python visual_html.py
``` -->
|