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

Mapping pixel to label #18

Closed
ghost opened this issue May 20, 2022 · 2 comments
Closed

Mapping pixel to label #18

ghost opened this issue May 20, 2022 · 2 comments

Comments

@ghost
Copy link

ghost commented May 20, 2022

Hi @mhamilton723, thank you for the great work.

I was wondering if there is any mapping between the image colormap and the label, when trying an image at test time ?

Referring to the colab notebok you published, it seems that linear_pred give the pixelwise prediction but when I checked the shape of model.label_cmap it shows (512, 3) which doesn't seems to match with the number of label that I get from get_class_labels(model.cfg.dataset_name)

I'm not sure to be using the right approach but basically 'm missing the link between the colormaps and the class labels.

Thank you for your reply and again great work.

@mhamilton723
Copy link
Owner

Hey @skabongo2022, thanks for reaching out.

model.label_cmap maps a class label to a color for pretty plotting. Here's some usage:

plot_cluster = (model.label_cmap[

To unpack this example:

plot_cluster = (model.label_cmap[
    model.test_cluster_metrics.map_clusters(
        saved_data["cluster_preds"][img_num])]).astype(np.uint8)

saved_data["cluster_preds"][img_num]: cluster predictions of shape [H,W] of (torch.long) encoding K classes
model.test_cluster_metrics.map_clusters(...):after running through the examples and adding them to the cluster metrics, this function allows one to map clusters to labels according to the proper hungarian matching. Outputs a [H,W] tensor with K classes (now shuffled to match the ontology)
model.label_cmap[...]: the final mapping that takes a class label array [H,W] and maps it to a color [H,W,3]. Sometimes we use pascal voc coloring, but for cityscapes we use their coloring method explicitly. Hope this helps!

@ghost
Copy link
Author

ghost commented May 31, 2022

Hi @mhamilton723, thank you for the reply.

I will close the issue for now and might re-open it if I still have questions/issues

Thank you for your availability.

This issue was closed.
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

1 participant