Closed Starry-lei closed 11 months ago
Hi Lei,
thanks for the interest in our code!
The PMF algorithm assumes that the input correspondences are noisy, but somehow accurate. So, you may verify your input correspondences. Furthermore, you can try different values of the variance "var" as this parameter depends on the scale of your data.
To test the PMF function, you could also start with a toy example where you already know the GT correspondences. Then, you could add some noise to the correspondences (e.g. making them non-injective) and use PMF to correct the augmented correspondences.
I hope this helps.
Best, Alex
Hi Alex, thank you very much for your suggestions. I am still wondering if there is any trick to finding a proper "var" parameter, which as far as I know is used to describe the noise distribution of each pair of correspondence. I am using the GT correspondence of the toy example "lion2cat" for testing, the lion shape has 5000 vertices, and the cat has 7207 vertices.
But the refinement using PMF destroys the GT correspondence like the following: the var is 1250(in S3M, var=1000 for 4000-vertex-shape) I also tried some other vars, but it seems the GT correspondence can not survive the refinement:
And also, for double-checking, in the code, the parameter points_x
is not needed, right? dist_x
is calculated using dijkstra
algorithm.
` def pmf( corres_idx: torch.Tensor, dist_x: torch.Tensor, dist_y: torch.Tensor, var ) -> np.ndarray:
Implementation of product manifold filter (PMF).
Args:
points_x: points of shape x
points_y: points of shape y
corres_idx: non-bijective correspondences between x and y
dist_x: geodesic distance of shape x
dist_y: geodesic distance of shape y
var: Variance of Gaussian Kernel
Returns:
bij_corres: bijective correspondences between x and y
k_x = torch.exp(-torch.pow(dist_x[:, corres_idx[:, 0]], 2) / (2 * var))
k_y = torch.exp(-torch.pow(dist_y[:, corres_idx[:, 1]], 2) / (2 * var))
density = torch.matmul(k_y, torch.transpose(k_x, 0, 1))
density = density.cpu().numpy().astype(np.float64)
bij_corres = auction_solve(density, problem="max")["sol"]
return bij_corres
`
Best, Lei
It would be highly appreciated if you could provide a simple example of how PMF can work. (^o^)/ thanks~
You are right, the parameters points_x
and points_y
are not needed, I'll change the code later.
If you check the corresponding paper https://arxiv.org/abs/1701.00669 , you see that the number of vertices of the two shapes must be equal. So, you may need to downsample the shape of the cat. The reason is that the result of the algorithm is a permutation matrix which provides bijective correspondences. But this is not possible if the number of vertices is different.
I can provide a simple toy example of PMF later.
I prepared a little toy example. The zip folder contains python file with the associating code which was copied from this repo. Furthermore, it contains the bunny.ply as toy mesh.
Just run the python file test_pmf.py in your S3M python environment and you'll see an example where PMF works. You can also vary the variance and the amount of variation between the two shapes to see their impact. For example, by setting var = 100 you won't get the correct correspondences.
The variance depends on the scale of the distances and therefore on the scale of the shapes. You have to try out some values (The larger the size of the shapes, the larger the variance).
I hope this helps :)
Thank you so much for your great help! (^o^)/
Hi, thanks to your great work, I am just copy the pmf code and use it in refinement of the example code of PyFM, it seems the code doesnt work.
do you have any suggestions for testing this function correctly?
many thanks in advance lei