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

instances mask and category #4

Open
chengzheng-nreal opened this issue Jun 1, 2023 · 2 comments
Open

instances mask and category #4

chengzheng-nreal opened this issue Jun 1, 2023 · 2 comments

Comments

@chengzheng-nreal
Copy link

Thank you very much for the open source dataset, there is a problem, I found that there is only instance information in the instance_id_maps folder, the instance mask is 0, how do I get the category and mask corresponding to each instance?

@nikitakaraevv
Copy link
Contributor

nikitakaraevv commented Jun 6, 2023

Hi @chengzheng-nreal, thanks for reaching out!
Your observation is indeed correct. At first glance, instance masks may appear empty because they are encoded as integers starting from 0. However, this is not the case.

Instance masks can be visualized by multiplying their values by a certain factor. In the case of three instances (0,1,2), you can multiply by 128.

You can try the following code snippet to visualize instance masks:

from PIL import Image
import matplotlib.pyplot as plt
import numpy as np

img_path = './dynamic_replica/test/cb2501-3_obj_source_right/images/cb2501-3_obj_source_right-0899.png'
instance_map_path = img_path.replace('images','instance_id_maps').replace('right-','right_')

img = Image.open(img_path)
instance_map = Image.open(instance_map_path)

plt.imshow(img)
plt.imshow(np.array(instance_map)*128)
Screenshot 2023-06-06 at 14 28 20 Screenshot 2023-06-06 at 14 28 30

Does it solve your problem?

@chengzheng-nreal
Copy link
Author

Hi @chengzheng-nreal, thanks for reaching out! Your observation is indeed correct. At first glance, instance masks may appear empty because they are encoded as integers starting from 0. However, this is not the case.

Instance masks can be visualized by multiplying their values by a certain factor. In the case of three instances (0,1,2), you can multiply by 128.

You can try the following code snippet to visualize instance masks:

from PIL import Image
import matplotlib.pyplot as plt
import numpy as np

img_path = './dynamic_replica/test/cb2501-3_obj_source_right/images/cb2501-3_obj_source_right-0899.png'
instance_map_path = img_path.replace('images','instance_id_maps').replace('right-','right_')

img = Image.open(img_path)
instance_map = Image.open(instance_map_path)

plt.imshow(img)
plt.imshow(np.array(instance_map)*128)

Screenshot 2023-06-06 at 14 28 20 Screenshot 2023-06-06 at 14 28 30
Does it solve your problem?

Thank you very much for your reply, which has solved most of my problems, I found that I made a mistake earlier cv2.imread read uint8, should read uint16. Now another question is how do I know which instances are people, I want to automatically filter out the instances of people

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