Giter VIP home page Giter VIP logo

smpl-anthropometry's Introduction

SMPL-Anthropometry

Measure the SMPL body model and visualize the measurements and landmarks.


Getting started

You can use a docker container to facilitate running the code. Run in terminal:

cd docker
sh build.sh
sh docker_run.sh CODE_PATH

by adjusting the CODE_PATH to the SMPL-Anthropometry directory location. This creates a smpl-anthropometry-container container.

If you do not want to use a docker container, you can also just install the necessary packages from docker/requirements.txt into your own enviroment.

Next, you need to provide the SMPL body models SMPL_{GENDER}.pkl (MALE, FEMALE and NEUTRAL), and put them into the data/SMPL/smpl folder.


Running

You can use the measure.py script to measure all the predefined measurements and visualize the results.

python measure.py

The output consists of a dictionary of measurements expressed in cm, the labeled measurements using standard labels, and the viualization of the measurements in the browser, as in the Figure above. The script measures a toy-example zero-shaped T-posed SMPL body model -- adapt the script to your needs.

The list of the predefined measurements along with its standard literature labels are:

STANDARD_MEASUREMENT = {
    'A': 'head circumference',
    'B': 'neck circumference',
    'C': 'shoulder to crotch height',
    'D': 'chest circumference',
    'E': 'waist circumference',
    'F': 'hip circumference',
    'G': 'wrist right circumference',
    'H': 'bicep right circumference',
    'I': 'forearm right circumference',
    'J': 'arm right length',
    'K': 'inside leg height',
    'L': 'thigh left circumference',
    'M': 'calf left circumference',
    'N': 'ankle left circumference',
    'O': 'shoulder breadth',
    'P': 'height'
    }

You can use the evaluate.py script to compare two sets of measurements.

python evaluate.py

The output consists of the mean absolute error (MAE) between two sets of measurements. The script compares a toy-example of two sets of measurements of two SMPL body models -- adapt to your needs.



Notes

Measurement definitions

There are two types of measurements: lenghts and circumferences.

  1. Lengths are defined as distances between landmark points defined on the SMPL body
  2. Circumferences are defiend as plane cuts of the SMPL body

To define a new measurement:

  1. Open measurement_definitions.py
  2. add the new measurement to the measurement_types dict and set its type: LENGTH or CIRCUMFERENCE
  3. depending on the type, define the measurement in the LENGTHS or CIRCUMFERENCES dict
    • LENGTHS are defined using 2 landmarks - the measurement is found as the distance between the landmarks
    • CIRCUMFERENCES are defined with landmarks and joints - the measurement is found by cutting the SMPL model with the plane defined by a point (landmark point) and normal ( vector connecting the two joints)
  4. If the body part is a CIRCUMFERENCE, a possible issue that arises is that the plane cutting results in multiple body part slices. To alleviate that, define the body part where the measurement should be located in CIRCUMFERENCE_TO_BODYPARTS dict. This way, only the slice in the corresponding body part is used for finding the measurement. The body parts are defined by the SMPL face segmentation located in data/smpl_body_parts_2_faces.json.

Measurement normalization

If a body model has unknown scale (ex. the body was regressed from an image), the measurements can be height-normalized as so:

measurer = MeasureSMPL()
measurer.from_smpl(shape=betas, gender=gender) # assume given betas and gender

all_measurement_names = MeasurementDefinitions.possible_measurements
measurer.measure(all_measurement_names)
new_height = 175
measurer.height_normalize_measurements(new_height)

This creates a dict of measurements measurer.height_normalized_measurements where each measurement was normalized with:

new_measurement = (old_measurement / old_height) * new_height

Body model

The body model can be defined by:

  • the SMPL shape parameters β using:
MeasureSMPL(...).from_smpl(betas, gender)
  • the 6890 SMPL vertices, without the shape parameters, using
MeasureSMPL(...).from_verts(verts)

The latter can be especially useful when the SMPL vertices have been further refined to fit a 2D/3D model and do not satsify perfectly a set of shape parameters anymore.



TODO

  • Implement other body models (SMPL-X, STAR, ...)
  • Add height normalization for the measurements
  • Allow posed and shaped body models as inputs, and measure them after unposing

smpl-anthropometry's People

Contributors

davidboja avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.