Notebook source code: notebooks/how_to/14_deep_functional_maps_models.ipynb
Run it yourself on binder Binder badge

How to use a Functional Map Model#

Here we show how to instantiate a deep functional map model. We introduce this notion as a model that can compute, given a pair of shapes, a functional maps ina differentiable manner, using learned descriptors.

 In [1]:
from geomfum.dataset import NotebooksDataset
from geomfum.descriptor.learned import FeatureExtractor
from geomfum.forward_functional_map import ForwardFunctionalMap
from geomfum.learning.models import FMNet
from geomfum.shape import TriangleMesh

 In [2]:
dataset = NotebooksDataset()

mesh_a = TriangleMesh.from_file(dataset.get_filename("cat-00"))
mesh_b = TriangleMesh.from_file(dataset.get_filename("lion-00"))
INFO: Data has already been downloaded... using cached file ('/home/ubuntu/.geomfum/data/cat-00.off').
/home/ubuntu/giulio_vigano/geomfum_proj/venv/lib/python3.12/site-packages/tqdm/auto.py:21: TqdmWarning: IProgress not found. Please update jupyter and ipywidgets. See https://ipywidgets.readthedocs.io/en/stable/user_install.html
  from .autonotebook import tqdm as notebook_tqdm
INFO: Data has already been downloaded... using cached file ('/home/ubuntu/.geomfum/data/lion-00.off').
 In [3]:
mesh_a.laplacian.find_spectrum(spectrum_size=100, set_as_basis=True)
mesh_b.laplacian.find_spectrum(spectrum_size=100, set_as_basis=True)

mesh_a.basis.use_k = 20
mesh_b.basis.use_k = 20

 In [4]:
import torch

functional_map_model = FMNet(
    feature_extractor=FeatureExtractor.from_registry(which="diffusionnet")
)

with torch.no_grad():
    output = functional_map_model(mesh_a, mesh_b, as_dict=True)
fmap12, fmap21 = output["fmap12"], output["fmap21"]

fmap12.shape
 Out [4]:
(20, 20)

We can select specific modules for our network

 In [ ]:
fmap_module = ForwardFunctionalMap(1000, 1, False)

feature_extractor = FeatureExtractor.from_registry(which="diffusionnet")

functional_map_model = FMNet(
    feature_extractor=feature_extractor, fmap_module=fmap_module
)
with torch.no_grad():
    fmap12, fmap21 = functional_map_model(mesh_a, mesh_b, as_dict=False)

fmap12.shape
(20, 20)