RobinMagnet / pyFM

Python implementation of Functional Maps
MIT License
101 stars 20 forks source link

IndexError when using with custom meshes #10

Closed Aishani20278 closed 1 year ago

Aishani20278 commented 1 year ago

Hi, upon running the example notebook I receive the following IndexError. Can you please guide. The error occurs in functional mapping section of the example_notebook.ipynb when I replace the objs with my mesh models. Are there any specific conditions that need to be fulfilled for running on different meshes apart from the examples provided ?

File [~/sem2_BTP/pyFM/pyFM/functional.py:244](https://vscode-remote+ssh-002dremote-002b192-002e168-002e3-002e126.vscode-resource.vscode-cdn.net/home/aishani20278/sem2_BTP/pyFM/~/sem2_BTP/pyFM/pyFM/functional.py:244), in FunctionalMapping.preprocess(self, n_ev, n_descr, descr_type, landmarks, subsample_step, k_process, verbose)
    241 self.descr2 = sg.mesh_WKS(self.mesh2, n_descr, k=self.k2)  # (N2, n_descr)
    243 if use_lm:
--> 244     lm_descr1 = sg.mesh_WKS(self.mesh1, n_descr, landmarks=lmks1, k=self.k1)  # (N1, p*n_descr)
    245     lm_descr2 = sg.mesh_WKS(self.mesh2, n_descr, landmarks=lmks2, k=self.k2)  # (N2, p*n_descr)
    247     self.descr1 = np.hstack([self.descr1, lm_descr1])  # (N1, (p+1)*n_descr)

File [~/sem2_BTP/pyFM/pyFM/signatures/WKS_functions.py:118](https://vscode-remote+ssh-002dremote-002b192-002e168-002e3-002e126.vscode-resource.vscode-cdn.net/home/aishani20278/sem2_BTP/pyFM/~/sem2_BTP/pyFM/pyFM/signatures/WKS_functions.py:118), in mesh_WKS(mesh, num_E, landmarks, k)
    115 else:
    116     assert len(mesh.eigenvalues >= k), f"At least ${k}$ eigenvalues should be computed, not {len(mesh.eigenvalues)}"
--> 118 return auto_WKS(mesh.eigenvalues[:k], mesh.eigenvectors[:, :k], num_E, landmarks=landmarks, scaled=True)

File [~/sem2_BTP/pyFM/pyFM/signatures/WKS_functions.py:107](https://vscode-remote+ssh-002dremote-002b192-002e168-002e3-002e126.vscode-resource.vscode-cdn.net/home/aishani20278/sem2_BTP/pyFM/~/sem2_BTP/pyFM/pyFM/signatures/WKS_functions.py:107), in auto_WKS(evals, evects, num_E, landmarks, scaled)
    105     return WKS(abs_ev, evects, energy_list, sigma, scaled=scaled)
    106 else:
--> 107     return lm_WKS(abs_ev, evects, landmarks, energy_list, sigma, scaled=scaled)

File [~/sem2_BTP/pyFM/pyFM/signatures/WKS_functions.py:68](https://vscode-remote+ssh-002dremote-002b192-002e168-002e3-002e126.vscode-resource.vscode-cdn.net/home/aishani20278/sem2_BTP/pyFM/~/sem2_BTP/pyFM/pyFM/signatures/WKS_functions.py:68), in lm_WKS(evals, evects, landmarks, energy_list, sigma, scaled)
     66 e_list = np.asarray(energy_list)
     67 coefs = np.exp(-np.square(e_list[:, None] - np.log(np.abs(evals))[None, :]) / (2*sigma**2))  # (num_E,K)
---> 68 weighted_evects = evects[None, landmarks, :] * coefs[:,None,:]  # (num_E,p,K)
     70 landmarks_WKS = np.einsum('tpk,nk->ptn', weighted_evects, evects)  # (p,num_E,N)
     72 if scaled:

IndexError: index 3177 is out of bounds for axis 0 with size 1345
RobinMagnet commented 1 year ago

Hi, The example notebook use landmarks, which are specific to the given shapes. You would need to input your own (or even simply set them to None). I'd also recommend directly using the ZoomOut algorithm on some initial correspondences instead of using the Functional Map pipeline from the example notebook (see pyFM.refine.zoomout).