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 to render instance id segmentation masks #1528

Open
DianCh opened this issue May 3, 2023 · 2 comments
Open

How to render instance id segmentation masks #1528

DianCh opened this issue May 3, 2023 · 2 comments

Comments

@DianCh
Copy link

DianCh commented May 3, 2023

❓ Questions on how to use PyTorch3D

Hi! Thank you for maintaining this wonderful repo! Let's say I have meshes of objects, with their instance ids (or semantic category ids), how can I render the 2d masks of them, with the pixels storing the ids?

Thank you in advance! I'd really appreciate some suggestions.

@bottler
Copy link
Contributor

bottler commented May 9, 2023

You can do this with normal rendering where the channel is the id rather than the color. This works and has been used, although it can use a lot of memory. For the lights, you'll need to use AmbientLights with an explicit ambient_color.

@zhifanzhu
Copy link

zhifanzhu commented Aug 29, 2023

I have just implemented this method. My idea is to keep a record of which face corresponds to which mesh, and replace fragments.pix_to_face with faceid_to_meshid[pix_to_face].
Here's my implementation for anyone interested:

https://github.com/zhifanzhu/libzhifan/blob/master/libzhifan/geometry/instance_id_rendering.py
https://github.com/zhifanzhu/libzhifan/blob/master/tests/geometry/projection_test.py#L201-L241

simple example output
render_instance_id

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

3 participants