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

Implementation Wrap ScalableFM #9

Draft
wants to merge 7 commits into
base: main
Choose a base branch
from
Draft

Implementation Wrap ScalableFM #9

wants to merge 7 commits into from

Conversation

gviga
Copy link
Collaborator

@gviga gviga commented Dec 11, 2024

I'have implemented a function in wrap in which I wrapped the functions of Scalable FM imtegrated with our Hiarchical mesh approach.

Note: This is mainly a test on how to work. Some bad practices will be changed in the future.

I'have implemented a function in wrap in which I wrapped the functions of Scalable FM imtegrated with our Hiarchical mesh approach.
@gviga gviga requested a review from luisfpereira December 11, 2024 08:51
@gviga gviga self-assigned this Dec 11, 2024
@GiLonga GiLonga closed this Dec 11, 2024
@luisfpereira luisfpereira reopened this Dec 11, 2024
@GiLonga GiLonga closed this Dec 11, 2024
@GiLonga GiLonga reopened this Dec 11, 2024
@luisfpereira luisfpereira marked this pull request as draft December 11, 2024 16:21
@luisfpereira luisfpereira force-pushed the scalable-fm branch 3 times, most recently from 1ed1c52 to 6768dce Compare December 17, 2024 02:36
@luisfpereira
Copy link
Owner

luisfpereira commented Dec 17, 2024

Quick note on linting (see c886676): I expect linting to be automatically done by ruff. In visual studio you (@GiLonga, @gviga) can accomplish that by installing this extension.

@luisfpereira
Copy link
Owner

luisfpereira commented Dec 17, 2024

@gviga, I'll try to justify the changes I've done in 415cd8d. Please let me know what you think (I'm open to undo anything you don't agree with).

As we've discussed in the last meeting, if we sample, we need a Sampler (something that has a sample method taking a shape and outputting an array). Therefore, I've added: BaseSampler, PoissonSampler, and NearestNeighborIndexSamplex.

As you would expect, we do not implement any PoissonSampler, but instead wrap pymeshlab for that. I've registered it, so we can do e.g. PoissonSampler.from_registry(n_samples=1000).

Additionally, I've realized LargeMesh.process_mesh does not expect coordinates coming from a sampler, but indices. Therefore, I've added NearestNeighborsIndexSampler, which takes a Sampler and then finds the closest points in the original mesh to the samples.
I find the naming quite misleading here, but I'm not inspired to come up with something better. All ears for ideas!

With the current approach there's not a lot of changes: we delete LargeMesh.knn_query and LargeMesh.poisson_sample and replace two lines of code in LargeMesh.process_mesh by a simpler one.
Nevertheless, I find this approach appealing for the following reasons:

  1. we can sample any mesh without having to instantiate LargeMesh

  2. we can easily plug in a different sampler (who wants to implement e.g. farthest point sampling?!)

  3. due to 1., testing of samplers becomes much easier

  4. we clearly know what parameters are used for what (e.g. n_samples is used to instantiate a sampler at init and not at process_mesh time; for this is obvious, but it is not always the case)

I already have other ideas on how to improve this code... but leaving that for another day.

@GiLonga
Copy link
Collaborator

GiLonga commented Dec 17, 2024

@luisfpereira @gviga About 2) I was thinking to add a sampler based on distance functions, similar to what’s done in pyfm, with both Geodesic and Euclidean options. This addition is also useful for our S4A project. Just a thing, I was thinking of farthest point sampling as a method of the Shape class, and then the euclidean distance for PointCloud and finally the geodesic for TriangleMesh (and the TriangleMesh would inherit from PointCloud).

@luisfpereira
Copy link
Owner

@GiLonga, my two cents on this:

Great idea to have a sampler based on distances.
If distance is computed explicitly, I think we should follow a geomstats-like format, i.e. a distance/metric is something we can equip a Shape (seen as a manifold/metric space) with. This because there's a multitude of distances we can put on a shape, so we want to do it by composition instead of inheritance.

I don't see sampling as a method of the Shape class, though later, if you really want that, we can do something like:

class Shape:
  def sample(self):
    return self._sampler.sample(self)

(btw, really appreciate the suggestions! adding it to our tasks)

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

Successfully merging this pull request may close these issues.

3 participants