eth-ait / aitviewer

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

How to specify model_type for smplx ? #29

Closed garrisonz closed 1 year ago

garrisonz commented 1 year ago

quickstart code

from aitviewer.renderables.smpl import SMPLSequence
from aitviewer.models.smpl import SMPLLayer
from aitviewer.viewer import Viewer
from aitviewer.configuration import CONFIG as C

C.update_conf({"smplx_models": '~/w/code/smplx/models'})

if __name__ == '__main__':
    v = Viewer()
    smpl_layer = SMPLLayer(model_type="smpl", gender="neutral")

    v.scene.add(SMPLSequence.t_pose(smpl_layer))
    v.run()

but return a error

$ python aitviewer_u/quickstart.py
Traceback (most recent call last):
  File "C:\Users\zyp\w\code\aitviewer_u\quickstart.py", line 11, in <module>
    smpl_layer = SMPLLayer(model_type="smpl", gender="neutral")
  File "C:\Users\zyp\w\sw\anaconda\envs\aitv\lib\site-packages\aitviewer\models\smpl.py", line 63, in __init__
    self.bm = smplx.create(
  File "C:\Users\zyp\w\sw\anaconda\envs\aitv\lib\site-packages\smplx\body_models.py", line 2410, in create
    raise ValueError(f'Unknown model type {model_type}, exiting!')
ValueError: Unknown model type models, exiting!

fyi, the tree output of ~/w/code/smplx/models

zyp@pc ~/w/code/smplx/models (main)
$ tree
.
|-- smpl
|   `-- SMPL_NEUTRAL.pkl
`-- smplx
    |-- SMPLX_FEMALE.npz
    |-- SMPLX_FEMALE.pkl
    |-- SMPLX_MALE.npz
    |-- SMPLX_MALE.pkl
    |-- SMPLX_NEUTRAL.npz
    |-- SMPLX_NEUTRAL.pkl
    |-- smplx_npz.zip
    `-- version.txt
garrisonz commented 1 year ago

The error is disappear, when I set the path in Windows path format

 C.update_conf({"smplx_models": 'C:/Users/zyp/w/code/smplx/models'})
kaufManu commented 1 year ago

To clarify what happened: When we create the SMPL layer, we just forward it to the smplx.create function. This function checks whether the configuration parameter C.smplx_models is a directory or not. In your case, os.path.isdir returned False, which lead to this error. Are you on Windows? In that case the ~ character might have caused this because this character has no special meaning on Windows, so this path indeed does not exist.