eth-ait / aitviewer

A set of tools to visualize and interact with sequences of 3D data.
MIT License
527 stars 47 forks source link

Fail loading SMPL-H #1

Closed Okaerikoto closed 2 years ago

Okaerikoto commented 2 years ago

I am trying to execute the script load_amass.py.

It expects .pkl models for SMPL-H, but the models SMPL-H for amass were released as .npz.

From MANO Download page, which models should I download, the first link or the second? [1] Models & Code [2] Extended SMPL+H model (used in AMASS project)

Whether I try to load the first version (.pkl) or the second version (.npz), I get the following error:

  File "visualize_seq.py", line 27, in <module>
    seq_amass = SMPLSequence.from_amass(
  File "/home/mkeller2/.pyenv/versions/skel_release_env/lib/python3.8/site-packages/aitviewer/renderables/smpl.py", line 154, in from_amass
    smpl_layer = SMPLLayer(model_type='smplh', gender=body_data['gender'].item(), device=C.device)
  File "/home/mkeller2/.pyenv/versions/skel_release_env/lib/python3.8/site-packages/aitviewer/models/smpl.py", line 56, in __init__
    self.bm = smplx.create(C.smplx_models, model_type=model_type,
  File "/home/mkeller2/.pyenv/versions/skel_release_env/lib/python3.8/site-packages/smplx/body_models.py", line 2405, in create
    return SMPLH(model_path, ext="npz", **kwargs)
  File "/home/mkeller2/.pyenv/versions/skel_release_env/lib/python3.8/site-packages/smplx/body_models.py", line 602, in __init__
    left_hand_components = data_struct.hands_componentsl[:num_pca_comps]
AttributeError: 'Struct' object has no attribute 'hands_componentsl'
kaufManu commented 2 years ago

Hmm, that also just confused me a little bit. I think there are both .pkl and .npz versions of SMPL-H. When you download [1] you can find the .pkl versions in the models/ subfolder. This is how I got them. Note that you have to preprocess them according to the notes in the smplx project.

If you download [2] then you'll indeed get .npz files. By default, we expect .pkl files, because we essentially just wrap the smplx.create function and that function expects .pkl by default. However, it can also load .npz files, so you should be able to load the .npz version if you change SMPLSequence.from_amass to load the SMPL layer as follows

smpl_layer = SMPLLayer(model_type='smplh', gender=body_data['gender'].item(), device=C.device, ext='npz')

Can you try if that works for you? If so, I can quickly push a change that exposes this parameter to the .from_amass function.

Okaerikoto commented 2 years ago

Thanks for the answer, that worked (download the first version + using the script as pointed in notes in the smplx project. Cool demo, thanks for releasing this :).