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 real_label can convert rgb mask image to one-channel id mask? #25

Closed
LilyDaytoy opened this issue Sep 15, 2022 · 2 comments
Closed

Comments

@LilyDaytoy
Copy link

LilyDaytoy commented Sep 15, 2022

Hi, thanks for this wonderful work!
I would like to ask that, in demo.py,

    def read_label(self, label_name, squeeze_idx=None):
        label_path = os.path.join(self.label_root, self.seq_name, label_name)
        label = Image.open(label_path)
        label = np.array(label, dtype=np.uint8)
        if self.single_obj:
            label = (label > 0).astype(np.uint8)
        elif squeeze_idx is not None:
            squeezed_label = label * 0
            for idx in range(len(squeeze_idx)):
                obj_id = squeeze_idx[idx]
                if obj_id == 0:
                    continue
                mask = label == obj_id
                squeezed_label += (mask * idx).astype(np.uint8)
            label = squeezed_label
        return label

why the rgb mask goes through the codes below

label = Image.open(label_path)
label = np.array(label, dtype=np.uint8)

and can be converted to a one-channel id mask? How should I enocode a mask image so that I could achieve this effect? Thanks!

@z-x-yang
Copy link
Collaborator

The mask files are not in rgb but are one-channel images, whose colors are from the attached palette information.

@LilyDaytoy
Copy link
Author

Ohh, I see, the mask is 'P' mode pillow image, thanks!

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