pvnieo / SURFMNet-pytorch

A pytorch implementation of: "Unsupervised Deep Learning for Structured Shape Matching"
MIT License
16 stars 2 forks source link

Point-to-point correspondence reconstruction #3

Closed ihmc3jn09hk closed 3 years ago

ihmc3jn09hk commented 3 years ago

Hi @pvnieo

I am having a hard time on reconstructing the point-to-point (p2p) correspondence from the trained model. In order to verify the issue, I tried to train a super-tiny dataset contains, 000.off and 001.off (from the provided data-zoo) only , with either basis-count=40, 60, 100, 120 each at 4000 iterations and 1500 vertices.

Neither of the cases could reproduce an appropriate p2p map.

The following is a snapshot for that part

  ...
  feat_x, _, evecs_x, evecs_trans_x = dataset.loader(args.shapeX) #path to 000.mat
  feat_y, _, evecs_y, evecs_trans_y = dataset.loader(args.shapeY) #path to 001.mat
  ...
  C1, C2, feat_1, feat_2 = surfmnet(feat_x, feat_y, evecs_trans_x, evecs_trans_y)
  FM_t = torch.transpose(C1, 1, 2)

  P = torch.bmm(evecs_x, FM_t)
  P = P.cpu().detach()

  tree = KDTree(P[0])  # Tree on (n1,k2)
  p2p = tree.query(evecs_y, k=1, return_distance=False).flatten()  # (n2,)
  ...

Do you have any idea ?

Edit:

When preprocessing, the old/new sqrt areas are identical, is it normal?

pvnieo commented 3 years ago

Hi @ihmc3jn09hk , Some datasets in the zoo are already preprocessed so the shape area is equal to one, so that's not a problem.

Concerning your question, here a way to obtain the p2p map:

from sklearn.neighbors import NearestNeighbors

neigh = NearestNeighbors(n_jobs=-1)
neigh.fit(np.matmul(evecs_x, C1.transpose()))
p2p = neigh.kneighbors(evecs_y, 1, return_distance=False).flatten()

I'm using sklearn because it's faster, but you can use numpy as well. Hope this answer your question.

ihmc3jn09hk commented 3 years ago

Hi @ihmc3jn09hk , Some datasets in the zoo are already preprocessed so the shape area is equal to one, so that's not a problem.

Concerning your question, here a way to obtain the p2p map:

from sklearn.neighbors import NearestNeighbors

neigh = NearestNeighbors(n_jobs=-1)
neigh.fit(np.matmul(evecs_x, C1.transpose()))
p2p = neigh.kneighbors(evecs_y, 1, return_distance=False).flatten()

I'm using sklearn because it's faster, but you can use numpy as well. Hope this answer your question.

Thanks @pvnieo , I have tried the suggested one with some modifications as following to resolve some error. But the out p2p is identical to the one I had before. I think the problem is pin-pointed to my trained-weights. It would be kind if you can share what parameters you used for training and a result sample overfit weight file for me to test my machine is broken ?

Shame, this part is my implementation problem. With the weights, the output p2p for all 1500 matches is just a single point in shape X.

Finally got it working for the tiny set. The code works in training mode while I was using evaluation for the whole time. The training curves are for k=60 and k=120. image