{"id":13443679,"url":"https://github.com/nmwsharp/learned-triangulation","last_synced_at":"2025-05-12T09:31:32.162Z","repository":{"id":92922830,"uuid":"280464257","full_name":"nmwsharp/learned-triangulation","owner":"nmwsharp","description":"Source code for \"PointTriNet: Learned Triangulation of 3D Point Sets\", by Nicholas Sharp and Maks Ovsjanikov at ECCV 2020","archived":false,"fork":false,"pushed_at":"2021-05-13T05:43:27.000Z","size":15673,"stargazers_count":113,"open_issues_count":6,"forks_count":15,"subscribers_count":6,"default_branch":"master","last_synced_at":"2025-04-01T05:11:14.529Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/nmwsharp.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2020-07-17T15:46:17.000Z","updated_at":"2025-03-13T06:43:49.000Z","dependencies_parsed_at":null,"dependency_job_id":"3dbf8520-1208-4e5b-95bb-5f57be443093","html_url":"https://github.com/nmwsharp/learned-triangulation","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nmwsharp%2Flearned-triangulation","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nmwsharp%2Flearned-triangulation/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nmwsharp%2Flearned-triangulation/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nmwsharp%2Flearned-triangulation/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/nmwsharp","download_url":"https://codeload.github.com/nmwsharp/learned-triangulation/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253709148,"owners_count":21951108,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-07-31T03:02:06.939Z","updated_at":"2025-05-12T09:31:27.142Z","avatar_url":"https://github.com/nmwsharp.png","language":"Python","funding_links":[],"categories":["Python"],"sub_categories":[],"readme":"Source code \u0026 pretrained model for \"[PointTriNet: Learned Triangulation of 3D Point Sets](https://nmwsharp.com/research/learned-triangulation/)\", by [Nicholas Sharp](https://nmwsharp.com/) and [Maks Ovsjanikov](http://www.lix.polytechnique.fr/~maks/) at ECCV 2020.\n\n- PDF: [link](https://nmwsharp.com/media/papers/learned-triangulation/learned_triangulation.pdf)\n- Project: [link](https://nmwsharp.com/research/learned-triangulation/)\n- Talk: [link](https://www.youtube.com/watch?v=PoNT0u_wz4Y)\n\n\n![demo gif](https://github.com/nmwsharp/learned-triangulation/blob/master/teaser.gif)\n\n## Example: Generate a mesh\n\n\nThe script `main_generate_mesh.py` applies a trained model to triangulate a point set. A set of pretrained weights are included in `saved_models/`\n\n```sh\npython src/main_generate_mesh.py saved_models/model_state_dict.pth path/to/points.ply\n```\n\nCheck out the `--help` flag on the script for arguments. In particular, the script can either take a point cloud directly as input, or take a mesh as input and uniformly sample points with `--sample_cloud`.\n\nNote that by default, the script opens up a GUI (using [Polyscope](http://polyscope.run/)) to show results. To skip the GUI and just write out the resulting mesh, use:\n\n```sh\npython src/main_generate_mesh.py path_to_your_cloud_or_mesh.ply --output result\n```\n\n## Example: Integrating with code\n\nIf you want to integrate PointTriNet in to your own codebase, the `PointTriNet_Mesher` from `point_tri_net.py` encapsulates all the functionality of the method. It's a `torch.nn.Module`, so you can make it a member of other modules, load weights, etc.\n\nTo create the model, load weights, and triangulate a point set, just call:\n\n```python\n\nmodel = PointTriNet_Mesher()\nmodel.load_state_dict(torch.load(some_path))\nmodel.eval()\n\nsamples = # your (B,V,3) torch tensor of point positions\n\nwith torch.no_grad():\n  candidate_triangles, candidate_probs = model.predict_mesh(samples)\n  # candidate_triangles is a (B, F, 3) index tensor, predicted triangles\n  # candidate_probs is a (B, F) float tensor of [0,1] probabilities for each triangle\n\n  # You are probably interested in only the high-probability triangles. For example,\n  # get the high-probability triangles from the 0th batch entry like\n  b = 0\n  prob_thresh = 0.9\n  high_prob_faces = candidate_triangles[b, candidate_probs[b,:] \u003e prob_thresh, :]\n\n\n```\n\n## Example: Generate data \u0026 train the model\n\n**Prerequisite**: a collection of shapes to train on; we use the training set (all classes) of ShapeNet v2, which you can download on your own. Note that we _do not_ train PointTriNet to match the triangulation of existing meshes, we're just using meshes as a convenient data source from which to sample point cloud patches.\n\n**Step 1** Sample point cloud patches as training (and validation) data\n\n```shell\npython src/generate_local_points_dataset.py --input_dir=/path/to/train_meshes/ --output_dir=data/train/ --n_samples=20000\n\npython src/generate_local_points_dataset.py --input_dir=/path/to/val_meshes/ --output_dir=data/val/ --n_samples=5000\n```\n\n**Step 2** Train the model\n\n```sh\npython src/main_train_model.py\n```\n\nWith default parameters, this will train for 3 epochs on the dataset above, using \u003c 8GB gpu memory and taking ~6hrs on an RTX 2070 GPU. Checkpoints will be saved in `./training_runs`, along with tensorboard logging.\n\nNote that this script has paths at the top relative to the expected directory layout of this repo. If you want to use a different directory layout, you can update the paths.\n\n## Dependencies\n\nDepends on `pytorch`, `torch-scatter`, `libigl`, and `polyscope`, along with some other typical numerical components. The code is pretty standard, and there shouldn't be any particularly strict version requirements on these dependencies; any recent version should work fine.\n\nFor completeness, an `environment.yml` file is included (which is a superset of the required packages).\n\n## Citation\n\nIf this code contributes to academic work, please cite:\n\n```bib\n@inproceedings{sharp2020ptn,\n  title={\"PointTriNet: Learned Triangulation of 3D Point Sets\"},\n  author={Sharp, Nicholas and Ovsjanikov, Maks},\n  booktitle={Proceedings of the European Conference on Computer Vision (ECCV)},\n  pages={},\n  year={2020}\n}\n```\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnmwsharp%2Flearned-triangulation","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnmwsharp%2Flearned-triangulation","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnmwsharp%2Flearned-triangulation/lists"}