Created
April 8, 2020 16:39
-
-
Save wkentaro/41a34ff837e3a1b318ed0b81485d50fe to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env python | |
| import gdown | |
| import numpy as np | |
| import scipy.io | |
| import corvus_segmentation_models | |
| mat_file = gdown.cached_download( | |
| "https://github.com/ankurhanda/nyuv2-meta-data/raw/master/classMapping40.mat", | |
| quiet=True, | |
| ) | |
| mat_40 = scipy.io.loadmat( | |
| mat_file, squeeze_me=True, chars_as_strings=True, struct_as_record=True | |
| ) | |
| mat_file = gdown.cached_download( | |
| "https://github.com/ankurhanda/nyuv2-meta-data/raw/master/class13Mapping.mat", | |
| quiet=True, | |
| ) | |
| mat_13 = scipy.io.loadmat( | |
| mat_file, squeeze_me=True, chars_as_strings=True, struct_as_record=True | |
| ) | |
| class_mapping_40 = mat_40["mapClass"] | |
| class_mapping_13 = [] | |
| for cls_id_40 in class_mapping_40: | |
| cls_id_13 = mat_13["classMapping13"]["labels13"].item()[cls_id_40 - 1] | |
| class_mapping_13.append(cls_id_13) | |
| class_mapping_13 = np.r_[[0], np.array(class_mapping_13)] | |
| class_names_13 = np.r_[ | |
| ["__background__"], mat_13["classMapping13"]["classNames"].item() | |
| ] | |
| dataset = corvus_segmentation_models.datasets.NyuDepthV2Dataset("all") | |
| for cls_id, cls_name in enumerate(dataset.class_names): | |
| cls_id_13 = class_mapping_13[cls_id] | |
| cls_name_13 = class_names_13[cls_id_13] | |
| print(f"{cls_id:03d}: {cls_name:s} -> {cls_id_13:02d}: {cls_name_13:s}") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment