Giter VIP home page Giter VIP logo

smpl-anthropometry's Introduction

SMPL-Anthropometry

Measure the SMPL/SMPLX body models 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, provide the body models (SMPL or SMPLX) and:

  1. put the SMPL_{GENDER}.pkl (MALE, FEMALE and NEUTRAL) models into the data/smpl folder
  2. put the SMPLX_{GENDER}.pkl (MALE, FEMALE and NEUTRAL) models into the data/smplx folder

๐Ÿƒ Running

First import the necessary libraries:

from measure import MeasureBody
from measurement_definitions import STANDARD_LABELS

Next define the measurer by setting the body model you want to measure with model_type (smpl or smplx):

measurer = MeasureBody(model_type)

Then, there are two ways of using the code for measuring a body model depending on how you want to define the body:

  1. Define the body model using the shape betas and gender gender parameters:
measurer.from_body_model(gender=gender, shape=betas) 
  1. Define the body model using the N x 3 vertices verts (N=6890 if SMPL, and 10475 if SMPLX):
measurer.from_verts(verts=verts) 

ย ย ย ย  ๐Ÿ“ฃ Defining the body using the vertices can be especially useful when the SMPL/SMPLX vertices have been
ย ย ย ย ย ย ย ย ย  further refined to fit a 2D/3D model and do not satsify perfectly a set of shape parameters anymore.

Finally, you can measure the body with:

measurement_names = measurer.all_possible_measurements # or chose subset of measurements 
measurer.measure(measurement_names) 
measurer.label_measurements(STANDARD_LABELS) 

Then, the measurements dictionary can be obtained with measurer.measurements and the labeled measurements can be obtained with measurer.labeled_measurements. 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'
    }

All the measurements are expressed in cm.


You can also compute the mean absolute error (MAE) between two sets of measurements as:

from evaluate import evaluate_mae
MAE = evaluate_mae(measurer1.measurements,measurer2.measurements)

where measurer1 and measurer2 are two intances of the MeasureBody class.


๐Ÿ’ฟ Demos

You can run the measure.py script to measure all the predefined measurements (mentioned above) and visualize the results for a zero-shaped T-posed neutral gender SMPL body model:

python measure.py --measure_neutral_smpl_with_mean_shape

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.

Similarly, you can measure a zero-shaped T-posed neutral gender SMPLX body model with:

python measure.py --measure_neutral_smplx_with_mean_shape

You can run the evaluate.py script to compare two sets of measurements of randomly shaped SMPL bodies as:

python evaluate.py

The output consists of the mean absolute error (MAE) between two sets of measurements.



๐Ÿ“ Notes

Measurement definitions

There are two types of measurements: lenghts and circumferences.

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

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 measurement type, define the measurement in the LENGTHS or CIRCUMFERENCES dict of the appropriate body model (SMPLMeasurementDefinitions or SMPLXMeasurementDefinitions)
    • 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 body model with the plane defined by a point (landmark point) and normal ( vector connecting the two joints)
  4. If the measurement 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 face segmentation located in data/smpl_body_parts_2_faces.json or data/smplx_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 = MeasureBody(model_type) # assume given model type
measurer.from_body_model(shape=betas, gender=gender) # assume given betas and gender

all_measurement_names = measurer.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

Additional visualizations

To visualize the SMPL and SMPLX face segmentation on two separate plots, run:

python visualize.py --visualize_smpl_and_smplx_face_segmentation

To visualize the SMPL and SMPLX joints on the same plot, run:

python visualize.py --visualize_smpl_and_smplx_joints

To visualize the SMPL and SMPLX point segmentations on two side-by-side plots, run:

python visualize.py --visualize_smpl_and_smplx_point_segmentation

NOTE: You need to provide the point_segmentation_meshcapade.json files in the folders data/smpl and data/smplx from here.

To visualize the SMPL and SMPLX landmarks on two side-by-side plots, run:

python visualize.py --visualize_smpl_and_smplx_landmarks


TODO

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

โญ Leave a star if you find this repository useful โญ

smpl-anthropometry's People

Contributors

davidboja avatar dependabot[bot] avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

smpl-anthropometry's Issues

How to input own data?

Hello , I am interested to use your model. I use SHAPY model and PYMAF to output 3D model from 2D images. So I already have 3D obj file with SMPL format.

How can I apply my 3D model to your model to get the body measurement?

Getting weight measurement

Thanks for your outstanding works!!!! Given 3d human mesh, I want to output the body measurement, for instance height and weight. I see that your work can output the height but how about the body's weight?

Is it possible to change Verts Dimension ?

I have a question about whether Is it possible to change Verts Dimension? Because for SMPLX the verts dimension is not the same as SMPL verts. So If I want to use SMPLX, Is it possible to change the verts dimension in your source code?

Thanks.

how can i use the .obj file to measure?

Hello David,
i generated a .objl file from an image using smplx model, i want to measure and get measurements from the generated .obj file. Unfortunately i cant see where should i place the .obj file.

Can visualize T-Pose?

Hi, I am not sure about did your model can visualize the output with the default T pose even though the 3D obj is not in T pose ?
Do you know how to get the T pose from 3D SMPL obj ?

Thanks.

How to generate own json?

Hi, I want to ask how you generate .json? Because SMPL's output is .obj. So, if i want to use my own data, how could i do?

Licence

Hi !
I was wondering if I could use your code in a non-commercial research project.
I could not find a licence in the project, and wanted to make sure it was okay.

Thanks !

How to measure specific body parts?

Hello, how can I measure specific body parts like under bust for women? I know I can edit the code in the measurement definition but I don't have landmark indices for under bust part, how do you get landmarks indices?
Thanks.

How to load my own .pkl file or .obj file to measure?

Hello , Thank you very much for your excellent project. I have used PIXIE and PYMAF to output 3D model from 2D images.
So I already have 3D pkl and obj file with SMPL and SMPLX format.
I have tried as you mentioned on closed issues.
but I have an error.
assert verts.shape == torch.Size([6890,3]), "verts need to be of dimension (6890,3)"
AssertionError: verts need to be of dimension (6890,3)

My obj has 20908 * 3 = 62724 vertices.
so How to I fix it? I am looking forward to hearing from you.

Enable to use SMPLX model

Hello DavidBoja, It's me, Daniel, I hope your everything is going well.
I am an AI & Machine Learning developer. I am so interested in your excellent projects. ๐Ÿฅ‡
I have been studying about 3D human body measurement.
I'd like to help you update your project that SMPLX model can be measured. or have you already revised this project?
If not so, please tell me about detail steps. I will update.
I have already read carefully your suggestion.

(is it ok to use smpl_body_parts_2_faces.json again in measuring SMPLX model?)

By the way, I'd also like to get along with you as a friend.
Could you possibly let me know your any contact info( skype, telegram, discord or email etc)? I will contact through that for more conventional discussion about AI projects.
I will be looking forward to back hearing from you soon. :)
Thanks.

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.