(self, classes=EMBODIED_CATE, init_file=None, verbose=False)
| 858 | """ |
| 859 | |
| 860 | def __init__(self, classes=EMBODIED_CATE, init_file=None, verbose=False): |
| 861 | self.color_map = dict() |
| 862 | self.verbose = verbose |
| 863 | if init_file is not None: |
| 864 | with open(init_file, 'r') as f: |
| 865 | pre_data = f.readlines() |
| 866 | for ins in pre_data: |
| 867 | s = ins.strip() |
| 868 | cate = s.split('[')[0].strip() |
| 869 | color = eval(s[len(cate):]) |
| 870 | self.color_map[cate] = color |
| 871 | else: |
| 872 | from .default_color_map import DEFAULT_COLOR_MAP |
| 873 | self.color_map = DEFAULT_COLOR_MAP |
| 874 | |
| 875 | self.classes = classes |
| 876 | self.color_pool = COCO_COLOR |
| 877 | |
| 878 | for label in classes: |
| 879 | if label not in self.color_map: |
| 880 | x = random.choice(self.color_pool) |
| 881 | self.color_map[label] = x['color'] |
| 882 | |
| 883 | self.inv_color_map = dict() |
| 884 | for key, value in self.color_map.items(): |
| 885 | color_idx = value[0] * 256 * 256 + value[1] * 256 + value[2] |
| 886 | if color_idx in self.inv_color_map: |
| 887 | self.inv_color_map[color_idx].append(key) |
| 888 | else: |
| 889 | self.inv_color_map[color_idx] = [key] |
| 890 | |
| 891 | self.visible_label = set() |
| 892 | |
| 893 | def save(self, out_file): |
| 894 | """Save the colormap to the output path. |
nothing calls this directly
no outgoing calls
no test coverage detected