Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NME calculation #13

Open
HOMGH opened this issue Oct 14, 2020 · 9 comments
Open

NME calculation #13

HOMGH opened this issue Oct 14, 2020 · 9 comments

Comments

@HOMGH
Copy link

HOMGH commented Oct 14, 2020

Hi @reshow . Thank you for sharing the pytoch version of PRNet. I had a question regarding calculating NME. using PRNet we would have 43k vertices in our predicted 3D mesh. but for AFLW2000 the number of vertices is 53k (or 39k for reduced version). So how can we calculate NME when we have different number of vertices? Any idea about that?
Thanks :)

@reshow
Copy link
Owner

reshow commented Nov 26, 2020

The 43k (or 64k if the foreface mask is not used) vertices is transformed from 53k vertices (as in processor.py, runPosemap). I think an inverse transformation of that may help to obtain the 53k vertices.

Or you can transform the 53k vetices of 3DDFA into 64k vertices of PRNet and then calculate NME.

@Shiyu555
Copy link

Shiyu555 commented Dec 1, 2020

hi,I still don't know how to calculate bbox when calculating 3D NME,d=sqrt( (max_x-min_x)*(max_y-min_y)) is right?
but I find that in your github code d=np.sqrt((maxx - minx) ** 2 + (maxy - miny) ** 2 + (maxz - minz) ** 2)
Hoping for your reply,thanks!

@reshow
Copy link
Owner

reshow commented Dec 1, 2020

hi,I still don't know how to calculate bbox when calculating 3D NME,d=sqrt( (max_x-min_x)*(max_y-min_y)) is right?
but I find that in your github code d=np.sqrt((maxx - minx) ** 2 + (maxy - miny) ** 2 + (maxz - minz) ** 2)
Hoping for your reply,thanks!

It should be d=np.sqrt((maxx - minx) ** 2 + (maxy - miny) ** 2). I give 2 ways to calculate NME since it is not always the same in different works.
You can refer to the repo of 3DDFA https://github.com/cleardusk/3DDFA/blob/master/benchmark/benchmarkCrop.m , line 30-43 and https://github.com/XgTu/2DASL/blob/master/evaluation/nme_for_alignment_68pts_2d.m , line 46.

@reshow
Copy link
Owner

reshow commented Dec 1, 2020

hi,I still don't know how to calculate bbox when calculating 3D NME,d=sqrt( (max_x-min_x)*(max_y-min_y)) is right?
but I find that in your github code d=np.sqrt((maxx - minx) ** 2 + (maxy - miny) ** 2 + (maxz - minz) ** 2)
Hoping for your reply,thanks!

I checked my codes again, and found that "d=np.sqrt((maxx - minx) ** 2 + (maxy - miny) ** 2 + (maxz - minz) ** 2) " is not used anywhere.
I'm sorry to have confused you. But I can't update this repo in the near future, just forget it.

@Shiyu555
Copy link

Shiyu555 commented Dec 1, 2020

hi,I still don't know how to calculate bbox when calculating 3D NME,d=sqrt( (max_x-min_x)*(max_y-min_y)) is right?
but I find that in your github code d=np.sqrt((maxx - minx) ** 2 + (maxy - miny) ** 2 + (maxz - minz) ** 2)
Hoping for your reply,thanks!

I checked my codes again, and found that "d=np.sqrt((maxx - minx) ** 2 + (maxy - miny) ** 2 + (maxz - minz) ** 2) " is not used anywhere.
I'm sorry to have confused you. But I can't update this repo in the near future, just forget it.

Thank you for your prompt reply!
I'm reading PRNET code recently,and I'm confused how the author's NME results are calculated.
In loss.py,line 39,40"pred[i, 2] = pred[i, 2] - torch.mean(pred[i, 2])""gt[i, 2] = gt[i, 2] - torch.mean(gt[i, 2])".Why subtract the mean?I didn't find the corresponding code in 2DASL

@reshow
Copy link
Owner

reshow commented Dec 4, 2020

hi,I still don't know how to calculate bbox when calculating 3D NME,d=sqrt( (max_x-min_x)*(max_y-min_y)) is right?
but I find that in your github code d=np.sqrt((maxx - minx) ** 2 + (maxy - miny) ** 2 + (maxz - minz) ** 2)
Hoping for your reply,thanks!

I checked my codes again, and found that "d=np.sqrt((maxx - minx) ** 2 + (maxy - miny) ** 2 + (maxz - minz) ** 2) " is not used anywhere.
I'm sorry to have confused you. But I can't update this repo in the near future, just forget it.

Thank you for your prompt reply!
I'm reading PRNET code recently,and I'm confused how the author's NME results are calculated.
In loss.py,line 39,40"pred[i, 2] = pred[i, 2] - torch.mean(pred[i, 2])""gt[i, 2] = gt[i, 2] - torch.mean(gt[i, 2])".Why subtract the mean?I didn't find the corresponding code in 2DASL

2D to 3D reconstruction is a ill-posed problem. In PRNet, the 3D to 2D projection is assumed to be a weakly perspective projection. So the absolute value of the coordinates on the z-axis is meaningless, but the relative value is meaningful. So I subtract the mean.

@Shiyu555
Copy link

Shiyu555 commented Dec 4, 2020

hi,I still don't know how to calculate bbox when calculating 3D NME,d=sqrt( (max_x-min_x)*(max_y-min_y)) is right?
but I find that in your github code d=np.sqrt((maxx - minx) ** 2 + (maxy - miny) ** 2 + (maxz - minz) ** 2)
Hoping for your reply,thanks!

I checked my codes again, and found that "d=np.sqrt((maxx - minx) ** 2 + (maxy - miny) ** 2 + (maxz - minz) ** 2) " is not used anywhere.
I'm sorry to have confused you. But I can't update this repo in the near future, just forget it.

Thank you for your prompt reply!
I'm reading PRNET code recently,and I'm confused how the author's NME results are calculated.
In loss.py,line 39,40"pred[i, 2] = pred[i, 2] - torch.mean(pred[i, 2])""gt[i, 2] = gt[i, 2] - torch.mean(gt[i, 2])".Why subtract the mean?I didn't find the corresponding code in 2DASL

2D to 3D reconstruction is a ill-posed problem. In PRNet, the 3D to 2D projection is assumed to be a weakly perspective projection. So the absolute value of the coordinates on the z-axis is meaningless, but the relative value is meaningful. So I subtract the mean.

oh,I see. Thanks for your help and patience!

@reshow
Copy link
Owner

reshow commented Dec 4, 2020

hi,I still don't know how to calculate bbox when calculating 3D NME,d=sqrt( (max_x-min_x)*(max_y-min_y)) is right?
but I find that in your github code d=np.sqrt((maxx - minx) ** 2 + (maxy - miny) ** 2 + (maxz - minz) ** 2)
Hoping for your reply,thanks!

I checked my codes again, and found that "d=np.sqrt((maxx - minx) ** 2 + (maxy - miny) ** 2 + (maxz - minz) ** 2) " is not used anywhere.
I'm sorry to have confused you. But I can't update this repo in the near future, just forget it.

Thank you for your prompt reply!
I'm reading PRNET code recently,and I'm confused how the author's NME results are calculated.
In loss.py,line 39,40"pred[i, 2] = pred[i, 2] - torch.mean(pred[i, 2])""gt[i, 2] = gt[i, 2] - torch.mean(gt[i, 2])".Why subtract the mean?I didn't find the corresponding code in 2DASL

2D to 3D reconstruction is a ill-posed problem. In PRNet, the 3D to 2D projection is assumed to be a weakly perspective projection. So the absolute value of the coordinates on the z-axis is meaningless, but the relative value is meaningful. So I subtract the mean.

oh,I see. Thanks for your help and patience!

: )

@HOMGH
Copy link
Author

HOMGH commented Jul 16, 2021

The 43k (or 64k if the foreface mask is not used) vertices is transformed from 53k vertices (as in processor.py, runPosemap). I think an inverse transformation of that may help to obtain the 53k vertices.

Or you can transform the 53k vetices of 3DDFA into 64k vertices of PRNet and then calculate NME.

Hi @reshow , I'm still struggling with NME calculation of PRNet on AFLW2000 dataset. The PRNet output has 43K vertices and AFLW2000 groundtruth has 53K. As you mentioned 43K vertices are transformed from 53k vertices. So, in order to have the same number of vertices, can we transform 53K vertices of AFLW2000 to 43K and calculate the NME? Is it correct?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants