Skip to content

Download links and conversion scripts for SMPL-family of models (SMPL, SMPLX, SMPLH/MANO) to automatically remove Python2/Chumpy dependencies. Just download files and run cleaning script

Notifications You must be signed in to change notification settings

keatonkraiger/SMPL_2_Python3

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

SMPL Models to Python 3 Converter

Download links and conversion scripts for SMPL-family of models (SMPL, SMPLX, SMPLH/MANO). Removes Python 2/Chumpy dependencies and makes them compatible with Python 3 so you can directly load them with Numpy/Pickle. The output is created in the format expected by smplx package, aitviewer, and similar packages.

├── smpl
│   ├── SMPL_FEMALE.pkl
│   └── SMPL_MALE.pkl
│   └── SMPL_NEUTRAL.pkl
├── smplh
│   ├── SMPLH_FEMALE.pkl
│   └── SMPLH_MALE.pkl
├── mano
|   ├── MANO_RIGHT.pkl
|   └── MANO_LEFT.pkl
└── smplx
    ├── SMPLX_FEMALE.pkl
    ├── SMPLX_FEMALE.npz
    ├── SMPLX_MALE.pkl
    ├── SMPLX_MALE.npz
    ├── SMPLX_NEUTRAL.pkl
    └── SMPLX_NEUTRAL.npz

Requirements

This script was tested with Python 3.11.13. You should download this repo and install the required packages using pip:

git clone https://github.com/keatonkraiger/SMPL_to_python3.git
cd SMPL_to_python3
pip install -r requirements.txt

Downloads

To download all of the SMPL-family models, follow these steps:

  1. Download the SMPL v1.1.0 files from SMPL Website
  2. Download the SMPLX with removed head bun (I do the NPZ+PKL) from the SMPLX Website
  3. Download the SMPLH model ("version ready to load by the smplx python package") from the MANO Website
  4. Download MANO ("Models & Code") from the MANO Website
  5. Place each downloaded zip file in the zips/ folder. It should look like this:
SMPL_to_python3/
├── convert_smpl.py
├── chumpy/
├── requirements.txt
├── test.py
└── zips/
    ├── mano_v1_2.zip # MANO
    ├── SMPL_python_v.1.1.0.zip # SMPL
    ├── smplx_lock_head.tar.bz2 # SMPLX with NPZ+PKL
    ├── smplx.zip # SMPLH, why they named it this I have no idea
    ├── ...
    ├── smplx_lockedhead_20230207.zip # optional SMPLX with only NPZ
    └── smplh.tar.xz # optional Extended SMPL+H used for manual merging

Merging SMPL+H and MANO: The SMPLH model version ready to load by the smplx python package (from the MANO Website) already has MANO merged in. If you download that you do not need to perform the merging. If you still want to do the merging or need access to the neutral model, you should download SMPLH ("Extended SMPL+H model used in AMASS project") from the MANO Website and use the --merge_mano flag when running the conversion script.

Converting the Models

To convert the models to Python 3 compatible files, run the following:

python convert_smpl.py  

Some options you can use:

  • --zips_path: Path to the directory containing the downloaded zip files. Default is zips.
  • --output_path: Path to the directory where the converted models will be saved. Default is models.
  • --merge_mano: Inclusion will merge the MANO and SMPL+H models
  • --convert_csc_matrix: Inclusion will convert the Scipy sparse csc_matrix to a dense numpy array.
  • --save_as_npz: Inclusion will save the output files as .npz instead of .pkl. Default is saving as .pkl.

You can test the conversions with:

python test.py --models_path models

Modifying the Chumpy Source Code

Only do this if the provided chumpy code in the chumpy/ folder does not work for you. You should also remove the chumpy/ folder.

Because Chumpy is now abandoned (and was never really that useful), there are a few things that will go wrong when trying to open the SMPL models. Luckily, the modifications needed to the Chumpy source code are minimal. First install Chumpy via pip:

pip install chumpy==0.70 
  1. Locate the Chumpy installation directory. You can find it by running the following command in Python:
    import chumpy
    print(chumpy.__file__)
    If you can't even import chumpy, there may be an AttributeError that tells you where it is installed.
  2. Make the following changes:
    1. In path/to/chumpy/__init__.py, change line 11 from:
      from numpy import bool, int, float, complex, object, unicode, str, nan, inf
      to:
        #from numpy import bool, int, float, complex, object, unicode, str, nan, inf
    2. In path/to/chumpy/ch.py, change line 1203 from:
          def _depends_on(func):
              want_out = 'out' in inspect.getargspec(func).args
      to:
          def _depends_on(func):
              want_out = 'out' in inspect.getfullargspec(func).args
      Note: Commenting it out worked as well (i.e #want_out = ...).

For example, in my case:

import chumpy
print(chumpy.__file__)
# Output: /home/keaton/miniconda3/lib/python3.11/site-packages/chumpy/__init__.py

Then I made the following modifications:

Chumpy's init.py modification Chumpy's ch.py modification

Thanks

It would be nice for SMPL to be updated to Python 3 officially and centralized.

About

Download links and conversion scripts for SMPL-family of models (SMPL, SMPLX, SMPLH/MANO) to automatically remove Python2/Chumpy dependencies. Just download files and run cleaning script

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages