Closed TharHtetAungg closed 1 year ago
Hi,
Depending on the output of SHAPY and PYMAF you can do the following:
betas
and gender gender
parameters as your SHAPY or PYMAF outputs:smpl_path = "/SMPL-Anthropometry/data/SMPL"
measurer = MeasureSMPL(smpl_path=smpl_path)
measurer.from_smpl(gender=gender, shape=betas)
measurement_names = MeasurementDefinitions.possible_measurements
measurer.measure(measurement_names)
measurer.label_measurements(STANDARD_LABELS)
verts
of shape 6890x3 as your SHAPY or PYMAF outputs:
smpl_path = "/SMPL-Anthropometry/data/SMPL"
measurer = MeasureSMPL(smpl_path=smpl_path)
measurer.from_verts(verts=verts)
measurement_names = MeasurementDefinitions.possible_measurements measurer.measure(measurement_names) measurer.label_measurements(STANDARD_LABELS)
Then, the `measurer.measurements` and `measurer.labeled_measurements` are python dictionaries of your measurements.
Thank you for getting back to me. So the file format for verts is .npz file format right?
By the way, Is there any other way that can measure from 3D obj file?
So the file format for verts is .npz file format right?
The SMPL package uses pytorch as its standard for vectors/matrices/tensors. Therefore, if you have a .npz
file on your disk with the vertices, you can load them with numpy and then convert them into a torch tensor -- something like torch.from_numpy(loaded_numpy_vertices)
. As I mentioned however, the dimensions of the vertices needs to be (6890,3)
.
By the way, Is there any other way that can measure from 3D obj file?
Sure, load your .obj
file with trimesh -- something like verts = trimesh.load(scan_path, process=False).vertices
-- and then convert the verts
into a torch tensor as noted above torch.from_numpy(fitted_smpl)
.
Thank you for your fast response.
I have a problem when I run measure.py, it keeps showing me about .pkl file is not exist. But I just want to use verts. So I have to provide both PKL file from SMPL and my own data file?
I run the code on Google Colab. If you have google colab, please share it with me.
Error " Path /content/SMPL-Anthropometry/data/SMPL/smpl/SMPL_NEUTRAL.pkl does not exist!"
As the README says:
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.
Even if you initialize your body model using from_verts
, you still need to provide the SMPL body models because the code extracts the joint regressor from the SMPL body model in order to be able to find the joints from the provided vertices. The joints are needed to find some measurements.
This could in theory be avoided -- by rewriting the code and putting the joint regressor in this repository -- but I do not want to do that since I do not own licences to distribute their models. You can download their models from here.
I already check with my verts and it is match with your verts format. But I don't know how to put your code into measurement.py ? Becasue it keep showing me verts is not defined.
smpl_path = "/SMPL-Anthropometry/data/SMPL"
measurer = MeasureSMPL(smpl_path=smpl_path)
measurer.from_verts(verts=verts)
measurement_names = MeasurementDefinitions.possible_measurements
measurer.measure(measurement_names)
measurer.label_measurements(STANDARD_LABELS)
I put it in here but verts are not defined .
Could you also please tell me where should I put this in Measuremet.py " load your .obj file with trimesh -- something like verts = trimesh.load(scan_path, process=False).vertices -- and then convert the verts into a torch tensor as noted above torch.from_numpy(fitted_smpl)."
I update the internal code like this but the program is not working.
@Daktha123 Did you already solve that? I am still stuck at "measurer.from_verts(verts=verts)". I don't know how to add "verts" to the internal code.
@Daktha123 The second image code looks all right to me at first glance. You don't need the imports there but I guess they shouldn't hurt. I can't help you if I don't know what's actually wrong -- "program is not working" is not specific enough.
@NaToh5 You need to load the verts -- these are YOUR vertices that you should have. You can add them to the code as @Daktha123 did in the second image.
I added these codes in measure.py . The program is working now and it load the verts perfectly. Could you please check it is correct ? Btw how can I show the measurement with 2D image like your show in the measurment_visulization.
scan_path = "/content/SMPL-Anthropometry/data/SMPL/smpl/John_0_smpl.obj"
verts = trimesh.load(scan_path, process=False).vertices
verts_tensor = torch.from_numpy(verts)
verts = verts_tensor.float()
from measure import MeasureSMPL
from measurement_definitions import MeasurementDefinitions, STANDARD_LABELS
smpl_path = "/content/SMPL-Anthropometry/data/SMPL"
measurer = MeasureSMPL(smpl_path=smpl_path)
measurer.from_verts(verts=verts_tensor)
@Daktha123
Yes, it looks good; you don't need the line verts = verts_tensor.float()
.
To get the visualizations you can use:
measurer.visualize()
This uses the plotly package and opens a visualization in the browser you can rotate.
If I don't use "*verts = verts_tensor.float()" I got this error " RuntimeError: expected scalar type Float but found Double ". That's why I use that code. Do you think that code might (verts = verts_tensor.float()) have a problem with the measurement process?
And also " measurer.visualize() " this is not working. Even I run measure.py the output only shows this
I need like this :
Updated : I already got the measurement visualization. I have to use local IDE to run the code , so that it will lead to browser to show the measurement visualization. Google Colab is not showing for the measurement visualization. Thank you for everything @DavidBoja
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?