Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Making GLAMR actually work and solving all errors! #41

Merged
merged 3 commits into from
Nov 21, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
228 changes: 228 additions & 0 deletions environment.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,228 @@
name: hybrik
channels:
- pytorch3d
- pytorch
- bottler
- iopath
- anaconda
- conda-forge
- nvidia
- defaults
dependencies:
- _libgcc_mutex=0.1=main
- _openmp_mutex=5.1=1_gnu
- blas=1.0=mkl
- brotli-python=1.0.9=py39h6a678d5_7
- bzip2=1.0.8=h7b6447c_0
- c-ares=1.19.1=h5eee18b_0
- ca-certificates=2023.08.22=h06a4308_0
- certifi=2023.7.22=py39h06a4308_0
- cffi=1.15.1=py39h5eee18b_3
- charset-normalizer=2.0.4=pyhd3eb1b0_0
- cryptography=41.0.3=py39hdda0065_0
- cuda=11.6.1=0
- cuda-cccl=11.6.55=hf6102b2_0
- cuda-command-line-tools=11.6.2=0
- cuda-compiler=11.6.2=0
- cuda-cudart=11.6.55=he381448_0
- cuda-cudart-dev=11.6.55=h42ad0f4_0
- cuda-cuobjdump=11.6.124=h2eeebcb_0
- cuda-cupti=11.6.124=h86345e5_0
- cuda-cuxxfilt=11.6.124=hecbf4f6_0
- cuda-driver-dev=11.6.55=0
- cuda-gdb=12.3.52=0
- cuda-libraries=11.6.1=0
- cuda-libraries-dev=11.6.1=0
- cuda-memcheck=11.8.86=0
- cuda-nsight=12.3.52=0
- cuda-nsight-compute=12.3.0=0
- cuda-nvcc=11.6.124=hbba6d2d_0
- cuda-nvdisasm=12.3.52=0
- cuda-nvml-dev=11.6.55=haa9ef22_0
- cuda-nvprof=12.3.52=0
- cuda-nvprune=11.6.124=he22ec0a_0
- cuda-nvrtc=11.6.124=h020bade_0
- cuda-nvrtc-dev=11.6.124=h249d397_0
- cuda-nvtx=11.6.124=h0630a44_0
- cuda-nvvp=12.3.52=0
- cuda-runtime=11.6.1=0
- cuda-samples=11.6.101=h8efea70_0
- cuda-sanitizer-api=12.3.52=0
- cuda-toolkit=11.6.1=0
- cuda-tools=11.6.1=0
- cuda-visual-tools=11.6.1=0
- curl=7.88.1=hdbd6064_2
- expat=2.5.0=h6a678d5_0
- ffmpeg=4.2.2=h20bf706_0
- freetype=2.12.1=h4a9f257_0
- fvcore=0.1.5.post20221221=pyhd8ed1ab_0
- gdbm=1.18=hd4cb3f1_4
- gds-tools=1.8.0.34=0
- gettext=0.21.0=h39681ba_1
- giflib=5.2.1=h5eee18b_3
- git=2.40.1=pl5340h36fbf9e_1
- gmp=6.2.1=h295c915_3
- gnutls=3.6.15=he1e5248_0
- icu=73.1=h6a678d5_0
- idna=3.4=py39h06a4308_0
- intel-openmp=2023.1.0=hdb19cb5_46305
- iopath=0.1.9=py39
- jpeg=9e=h5eee18b_1
- krb5=1.20.1=h143b758_1
- lame=3.100=h7b6447c_0
- lcms2=2.12=h3be6417_0
- ld_impl_linux-64=2.38=h1181459_1
- lerc=3.0=h295c915_0
- libcublas=11.9.2.110=h5e84587_0
- libcublas-dev=11.9.2.110=h5c901ab_0
- libcufft=10.7.1.112=hf425ae0_0
- libcufft-dev=10.7.1.112=ha5ce4c0_0
- libcufile=1.8.0.34=0
- libcufile-dev=1.8.0.34=0
- libcurand=10.3.4.52=0
- libcurand-dev=10.3.4.52=0
- libcurl=7.88.1=h251f7ec_2
- libcusolver=11.3.4.124=h33c3c4e_0
- libcusparse=11.7.2.124=h7538f96_0
- libcusparse-dev=11.7.2.124=hbbe9722_0
- libdeflate=1.17=h5eee18b_1
- libedit=3.1.20221030=h5eee18b_0
- libev=4.33=h7f8727e_1
- libffi=3.4.4=h6a678d5_0
- libgcc-ng=11.2.0=h1234567_1
- libgomp=11.2.0=h1234567_1
- libidn2=2.3.4=h5eee18b_0
- libnghttp2=1.57.0=h2d74bed_0
- libnpp=11.6.3.124=hd2722f0_0
- libnpp-dev=11.6.3.124=h3c42840_0
- libnvjpeg=11.6.2.124=hd473ad6_0
- libnvjpeg-dev=11.6.2.124=hb5906b9_0
- libopus=1.3.1=h7b6447c_0
- libpng=1.6.39=h5eee18b_0
- libssh2=1.10.0=hdbd6064_2
- libstdcxx-ng=11.2.0=h1234567_1
- libtasn1=4.19.0=h5eee18b_0
- libtiff=4.5.1=h6a678d5_0
- libunistring=0.9.10=h27cfd23_0
- libvpx=1.7.0=h439df22_0
- libwebp=1.3.2=h11a3e52_0
- libwebp-base=1.3.2=h5eee18b_0
- libxml2=2.10.4=hf1b16e4_1
- lz4-c=1.9.4=h6a678d5_0
- mkl=2023.1.0=h213fc3f_46343
- mkl-service=2.4.0=py39h5eee18b_1
- mkl_fft=1.3.8=py39h5eee18b_0
- mkl_random=1.2.4=py39hdb19cb5_0
- ncurses=6.4=h6a678d5_0
- nettle=3.7.3=hbbd107a_1
- nsight-compute=2023.3.0.12=0
- nvidiacub=1.10.0=0
- openh264=2.1.1=h4ff587b_0
- openjpeg=2.4.0=h3ad879b_0
- openssl=3.0.12=h7f8727e_0
- pcre2=10.42=hebb0a14_0
- perl=5.34.0=h5eee18b_2
- pip=23.3=py39h06a4308_0
- portalocker=2.3.0=py39h06a4308_1
- pycparser=2.21=pyhd3eb1b0_0
- pyopenssl=23.2.0=py39h06a4308_0
- pysocks=1.7.1=py39h06a4308_0
- python=3.9.18=h955ad1f_0
- python_abi=3.9=2_cp39
- pytorch=1.13.0=py3.9_cuda11.6_cudnn8.3.2_0
- pytorch-cuda=11.6=h867d48c_1
- pytorch-mutex=1.0=cuda
- pytorch3d=0.7.5=py39_cu116_pyt1130
- readline=8.2=h5eee18b_0
- requests=2.31.0=py39h06a4308_0
- setuptools=68.0.0=py39h06a4308_0
- sqlite=3.41.2=h5eee18b_0
- tabulate=0.8.10=py39h06a4308_0
- tbb=2021.8.0=hdb19cb5_0
- termcolor=2.1.0=py39h06a4308_0
- tk=8.6.12=h1ccaba5_0
- torchvision=0.14.0=py39_cu116
- tqdm=4.65.0=py39hb070fc8_0
- typing_extensions=4.7.1=py39h06a4308_0
- urllib3=1.26.18=py39h06a4308_0
- wheel=0.41.2=py39h06a4308_0
- x264=1!157.20191217=h7b6447c_0
- xz=5.4.2=h5eee18b_0
- yacs=0.1.6=pyhd3eb1b0_1
- yaml=0.2.5=h7b6447c_0
- zlib=1.2.13=h5eee18b_0
- zstd=1.5.5=hc292b87_0
- pip:
- aiohttp==3.8.6
- aiosignal==1.3.1
- appdirs==1.4.4
- async-timeout==4.0.3
- attrs==23.1.0
- autograd==1.6.2
- beautifulsoup4==4.12.2
- contourpy==1.2.0
- cycler==0.12.1
- cython==3.0.5
- dill==0.3.7
- ffmpeg-python==0.2.0
- fonttools==4.44.0
- frozenlist==1.4.0
- fsspec==2023.10.0
- future==0.18.3
- h5py==3.1.0
- imageio==2.32.0
- importlib-metadata==6.8.0
- importlib-resources==6.1.1
- imutils==0.5.4
- joblib==1.3.2
- kiwisolver==1.4.5
- lazy-loader==0.3
- lightning-utilities==0.9.0
- llvmlite==0.41.1
- lmdb==1.4.1
- markupsafe==2.1.3
- matplotlib==3.8.1
- meshio==4.4.6
- multidict==6.0.4
- multiprocess==0.70.15
- networkx==3.2.1
- numba==0.58.1
- numpy==1.23.1
- opencv-python==4.8.1.78
- opendr==0.77
- packaging==23.2
- pandas==2.1.2
- pathos==0.3.1
- pillow==10.1.0
- pox==0.3.3
- ppft==1.7.6.7
- progress==1.6
- protobuf==3.19.6
- pydeprecate==0.3.0
- pynvml==11.5.0
- pyparsing==3.1.1
- python-dateutil==2.8.2
- python-graphviz==0.20.1
- pytorch-lightning==0.8.3
- pytube==15.0.0
- pytz==2023.3.post1
- pyvista==0.36.0
- pyyaml==5.4.1
- scikit-image==0.22.0
- scikit-learn==1.3.2
- scipy==1.11.3
- scooby==0.9.2
- seaborn==0.13.0
- six==1.16.0
- soupsieve==2.5
- tb-nightly==2.16.0a20231108
- threadpoolctl==3.2.0
- tifffile==2023.9.26
- torchmetrics==1.2.0
- transforms3d==0.3.1
- tzdata==2023.3
- vtk==9.1.0
- werkzeug==3.0.1
- wslink==1.12.4
- yarl==1.9.2
- zipp==3.17.0
10 changes: 9 additions & 1 deletion global_recon/models/global_recon_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import os
import torch
import numpy as np
from scipy.spatial.transform import Rotation as R
from scipy.interpolate import interp1d
from lib.models.smpl import SMPL, SMPL_MODEL_DIR
from lib.utils.geometry import perspective_projection
Expand Down Expand Up @@ -99,7 +100,14 @@ def init_data(self, in_dict):
new_dict['invis_frames'] = invis_frames = visible == 0
new_dict['frame2ind'] = {f: i for i, f in enumerate(new_dict['frames'])}
new_dict['scale'] = None
smpl_pose_wroot = quaternion_to_angle_axis(torch.tensor(pose_dict[f'smpl_pose_quat_wroot'], device=self.device)).cpu().numpy()

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for you PR and it does save me a lot of time!
However, I think modification here may not be suitable.
In the issue you mentioned, the answerer said that "This probably happens because you use the hrnet version of HybrIK which produces 3x3 rotation matrices, not quaternions". And in my case, I do receive quaternions as the output, which means modification here actually make my code fail.


## Credits: https://github.com/NVlabs/GLAMR/issues/34#issuecomment-1671664667
hybrik_poses_rot = pose_dict['smpl_pose_quat_wroot']
batch_size = hybrik_poses_rot.shape[0]
smpl_pose_wroot = R.as_rotvec(R.from_matrix(hybrik_poses_rot.reshape((-1, 3, 3)))).reshape((batch_size, -1, 3))
smpl_pose_wroot = smpl_pose_wroot.astype(np.float32)
# smpl_pose_wroot = quaternion_to_angle_axis(torch.tensor(pose_dict[f'smpl_pose_quat_wroot'], device=self.device)).cpu().numpy()
# new_dict['smpl_pose'] = smpl_pose_wroot[:, 1:].reshape(-1, 69)
new_dict['smpl_pose'] = smpl_pose_wroot[:, 1:].reshape(-1, 69)
if idx in in_dict['gt']:
new_dict['smpl_pose_gt'] = in_dict['gt'][idx]['pose'][:, 3:]
Expand Down
5 changes: 3 additions & 2 deletions global_recon/run_demo.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,10 +110,11 @@
visualizer = GReconVisualizer(out_dict, coord='world', verbose=False, show_camera=False,
render_cam_pos=render_specs.get('cam_pos', None), render_cam_focus=render_specs.get('cam_focus', None))
visualizer.save_animation_as_video(video_world, window_size=render_specs.get('wsize', (int(1.5 * img_h), img_h)), cleanup=True, crf=5)

print(f'Saved results at: {video_world}')
log.info(f'saving cam animation for {seq_name}')
visualizer = GReconVisualizer(out_dict, coord='cam_in_world', verbose=False, background_img_dir=frame_dir)
visualizer.save_animation_as_video(video_cam, window_size=(img_w, img_h), cleanup=True)

log.info(f'saving side-by-side animation for {seq_name}')
hstack_video_arr([pose_est_video, video_cam, video_world], video_sbs, text_arr=[pose_est_model_name, 'GLAMR (Cam)', 'GLAMR (World)'], text_color='blue', text_size=img_h // 16, verbose=False)
hstack_video_arr([pose_est_video, video_cam, video_world], video_sbs, verbose=False)
print(f'Saved results at: {video_sbs}')