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

how do you simplfy the ModelNet40 #1

Open
zshyang opened this issue Sep 10, 2022 · 1 comment
Open

how do you simplfy the ModelNet40 #1

zshyang opened this issue Sep 10, 2022 · 1 comment

Comments

@zshyang
Copy link

zshyang commented Sep 10, 2022

thanks for this repo. how do you simplify the meshes in modelnet40? do you plan to publish the code? if not, could you provide a rough direction? thanks.

@vinitveersingh
Copy link
Contributor

Background

The original ModelNet40 data set contain non-manifold meshes. Therefore, pre-processing them to have a fixed number of faces is non-trivial. Some other works decimate meshes as a quadratic energy minimization problem. However, their decimation strategy had some issues, and I wanted to avoid them

Rough Direction

Firstly, I converted the .off files in ModelNet40 into .obj files using this library. And to ensure all .obj files were triangle meshes, I used the "Turn into a Pure-Triangular mesh" filter in MeshLab. These operations did not change the meshes' topology (except when a mesh was not a triangle mesh) but ensured all further pre-processing went smoothly.

Next, as mentioned in the paper, I used Watertight Manifold. In most cases, Watertight Manifold decimated meshes to have 1024 faces. Sometimes, if the decimation was unsuccessful, I used Watertight Manifold iteratively. However, for a select few meshes, Watertight Manifold does not work. Thus, for those meshes, I utilized Blender to add volume to them before using Watertight Manifold. I have the scripts for these, but as you can imagine, decimation occurs on a per-instance basis. Thus, for reproducibility purposes, you should only use the link I have shared on the GitHub page.

Code:

We will not add the pre-processing code to the official repo. However, I have copied the scripts/code required to pre-process the meshes here. It's in the zip file called ModelNet40_utils.zip.

You'll need to install the following software before you run the scripts.

  1. Linux Ubuntu OS
  2. Python and the libraries imported in the scripts
  3. Antiprism Library (https://www.antiprism.com/programs/off2obj.html) (Please make sure alias is installed in the bashrc)
  4. Watertight Manifold
  5. MeshLab Server (A little different from just MeshLab)
  6. Blender

Please note you will have to change the relative paths in the provided Python scripts based on how you create the folders.

Please find the steps below:

  1. Go to the ModelNet40 website, download the .off files into a folder called ModelNet40-model and run the script clean_off.py.
    You must run clean_off.py because some .off files in the original data set are corrupted and cannot be converted to .obj files using the Antiprism Library directly.

  2. Create a folder called ModelNet40-model-obj. Install the Antiprism Library. Run off2obj.py to convert the .off files in ModelNet40-model to .obj format.

  3. Create a folder called ModelNet40-triangle. Install the Meshlab Server. Run pure_triangle.py. This script converts all mesh to pure triangle formats without changing the shapes of the mesh. This is required since some meshes in the original ModelNet40 are not triangle meshes, and DMC only works on triangle meshes.

  4. Create a folder ModelNet40-waterlight. Install and build Watertight Manifold. Please keep track of the path where it is built. For me the manifold was build and installed at this path ''/media/jakep/Elements/Mesh/Decimation/Manifold/build/manifold". It will be different for you. Change the manifold variable in line 11 to your path. And run waterlight.py

  5. Create a folder ModelNet40-decimate-1024. For me, the simplify run file (of Watertight Manifold) was built and installed at this path "/media/jakep/Elements/Mesh/MeshNet++/Decimate/Manifold/build/simplify". It will be different for you. Change the decimate variable in line 11 to your path. And run decimate.py

The above steps will give you errors for some meshes because they have no volume, and some are just hard to decimate for Watertight Manifold.
I think there are four meshes ( I don't remember which ones) for which you will have to use Blender to add volume. I used a Youtube tutorial for this.
You will have to keep track of other meshes that failed to convert after using Watertight Manifold. You have to write your own python scripts for this and can use the scripts in the sanity_check folder. (For scripts in the sanity_check folder, you need to install the necessary Python libraries.)

The trick to converting the failed meshes is to rerun waterlight.py on the meshes in ModelNet40-waterlight (not ModelNet40-decimate-1024) folder that have been unable to decimate. Sometimes you have to do this multiple times. Then run decimate.py on these failed meshes, and it should work.

If you don't necessarily need 1024 faces and 5096 faces is ok for your datasets, steps 1-5 usually work without failing.

Please let me know if you have any further questions. If these instructions resolve your question, please close this issue.

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

No branches or pull requests

2 participants