Rename smpl->smplpytorch.

This commit is contained in:
gulvarol
2019-07-16 15:41:45 +02:00
parent 6c67b6de28
commit 6f67ac4199
17 changed files with 35 additions and 19 deletions

4
.gitignore vendored
View File

@ -3,8 +3,10 @@
*_bak.py *_bak.py
.cache/ .cache/
.egg-info
__pycache__/ __pycache__/
build/ build/
dist/ dist/
smpl/native/models/*.pkl image.png
smplpytorch/native/models/*.pkl

View File

@ -7,18 +7,31 @@ It can be integrated into any architecture as a differentiable layer to predict
The code is adapted from the [manopth](https://github.com/hassony2/manopth) repository by [Yana Hasson](https://github.com/hassony2). The code is adapted from the [manopth](https://github.com/hassony2/manopth) repository by [Yana Hasson](https://github.com/hassony2).
<p align="center"> <p align="center">
<img src="image.png" alt="smpl" width="300"/> <img src="assets/image.png" alt="smpl" width="300"/>
</p> </p>
## Setting up
* Dependencies: ## Setup
* Install the dependencies listed in [environment.yml](environment.yml)
* In an existing conda environment, `conda env update -f environment.yml` ### 1. The `smplpytorch` package
* In a new environment, `conda env create -f environment.yml`, will create a conda environment named `smplpytorch` * **Run without installing:** You will need to install the dependencies listed in [environment.yml](environment.yml):
* Download SMPL pickle files: * `conda env update -f environment.yml` in an existing environment, or
* `conda env create -f environment.yml`, for a new `smplpytorch` environment
* **Install:** To import `SMPL_Layer` in another project with `from smplpytorch.pytorch.smpl_layer import SMPL_Layer` do one of the following.
* Option 1: This should automatically install the dependencies.
``` bash
git clone https://github.com/gulvarol/smplpytorch.git
cd smplpytorch
pip install .
```
* Option 2: You can install `smplpytorch` from [PyPI](https://pypi.org/project/smplpytorch/). Additionally, you might need to install [chumpy](https://github.com/hassony2/chumpy.git).
``` bash
pip install smplpytorch
```
### 2. Download SMPL pickle files
* Download the models from the [SMPL website](http://smpl.is.tue.mpg.de/) by choosing "SMPL for Python users". Note that you need to comply with the [SMPL model license](http://smpl.is.tue.mpg.de/license_model). * Download the models from the [SMPL website](http://smpl.is.tue.mpg.de/) by choosing "SMPL for Python users". Note that you need to comply with the [SMPL model license](http://smpl.is.tue.mpg.de/license_model).
* Extract and copy the `models` folder into the `smpl/native/` folder. * Extract and copy the `models` folder into the `smplpytorch/native/` folder (or set the `model_root` parameter accordingly).
## Demo ## Demo

BIN
assets/image.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 109 KiB

View File

@ -1,6 +1,6 @@
import torch import torch
from smpl.pytorch.smpl_layer import SMPL_Layer from smplpytorch.pytorch.smpl_layer import SMPL_Layer
from display_utils import display_model from display_utils import display_model
@ -12,7 +12,7 @@ if __name__ == '__main__':
smpl_layer = SMPL_Layer( smpl_layer = SMPL_Layer(
center_idx=0, center_idx=0,
gender='neutral', gender='neutral',
model_root='smpl/native/models') model_root='smplpytorch/native/models')
# Generate random pose and shape parameters # Generate random pose and shape parameters
pose_params = torch.rand(batch_size, 72) * 0.2 pose_params = torch.rand(batch_size, 72) * 0.2

View File

@ -6,5 +6,6 @@ dependencies:
- matplotlib - matplotlib
- numpy - numpy
- pytorch - pytorch
- pip
- pip: - pip:
- git+https://github.com/hassony2/chumpy.git - git+https://github.com/hassony2/chumpy.git

View File

@ -1,6 +1,5 @@
import setuptools import setuptools
with open("README.md", "r") as fh: with open("README.md", "r") as fh:
long_description = fh.read() long_description = fh.read()
@ -12,7 +11,7 @@ REQUIREMENTS = [
"chumpy @ git+ssh://git@github.com/hassony2/chumpy"] "chumpy @ git+ssh://git@github.com/hassony2/chumpy"]
setuptools.setup( setuptools.setup(
name="smpl-pytorch", name="smplpytorch",
version="0.0.1", version="0.0.1",
author="Gul Varol", author="Gul Varol",
author_email="gulvarols@gmail.com", author_email="gulvarols@gmail.com",
@ -21,7 +20,7 @@ setuptools.setup(
description="SMPL human body layer for PyTorch is a differentiable PyTorch layer", description="SMPL human body layer for PyTorch is a differentiable PyTorch layer",
long_description=long_description, long_description=long_description,
long_description_content_type="text/markdown", long_description_content_type="text/markdown",
url="https://github.com/gulvarol/smpl-pytorch", url="https://github.com/gulvarol/smplpytorch",
packages=setuptools.find_packages(), packages=setuptools.find_packages(),
classifiers=[ classifiers=[
"Programming Language :: Python :: 3", "Programming Language :: Python :: 3",

1
smplpytorch/__init__.py Normal file
View File

@ -0,0 +1 @@
name = "smplpytorch"

View File

@ -3,7 +3,7 @@ def ready_arguments(fname_or_dict):
import pickle import pickle
import chumpy as ch import chumpy as ch
from chumpy.ch import MatVecMult from chumpy.ch import MatVecMult
from smpl.native.webuser.posemapper import posemap from smplpytorch.native.webuser.posemapper import posemap
if not isinstance(fname_or_dict, dict): if not isinstance(fname_or_dict, dict):
dd = pickle.load(open(fname_or_dict, 'rb'), encoding='latin1') dd = pickle.load(open(fname_or_dict, 'rb'), encoding='latin1')

View File

@ -4,9 +4,9 @@ import numpy as np
import torch import torch
from torch.nn import Module from torch.nn import Module
from smpl.native.webuser.serialization import ready_arguments from smplpytorch.native.webuser.serialization import ready_arguments
from smpl.pytorch import rodrigues_layer from smplpytorch.pytorch import rodrigues_layer
from smpl.pytorch.tensutils import (th_posemap_axisang, th_with_zeros, th_pack, make_list, subtract_flat_id) from smplpytorch.pytorch.tensutils import (th_posemap_axisang, th_with_zeros, th_pack, make_list, subtract_flat_id)
class SMPL_Layer(Module): class SMPL_Layer(Module):

View File

@ -1,6 +1,6 @@
import torch import torch
from smpl.pytorch import rodrigues_layer from smplpytorch.pytorch import rodrigues_layer
def th_posemap_axisang(pose_vectors): def th_posemap_axisang(pose_vectors):