If metadata has asigned colors, use them in draw_dataset_dict.
Summary:
Trying to address issue
Pull Request resolved:
@@ -490,6 +490,11 @@ class Visualizer:
boxes = [BoxMode.convert(x["bbox"], x["bbox_mode"], BoxMode.XYXY_ABS) for x in annos]
labels = [x["category_id"] for x in annos]
+ colors = None
+ if self._instance_mode == ColorMode.SEGMENTATION and self.metadata.get("thing_colors"):
+ colors = [
+ self._jitter([x / 255 for x in self.metadata.thing_colors[c]]) for c in labels
+ ]
names = self.metadata.get("thing_classes", None)
if names:
labels = [names[i] for i in labels]
@@ -497,7 +502,9 @@ class Visualizer:
"{}".format(i) + ("|crowd" if a.get("iscrowd", 0) else "")
for i, a in zip(labels, annos)
]
- self.overlay_instances(labels=labels, boxes=boxes, masks=masks, keypoints=keypts)
+ self.overlay_instances(
+ labels=labels, boxes=boxes, masks=masks, keypoints=keypts, assigned_colors=colors
+ )
sem_seg = dic.get("sem_seg", None)
if sem_seg is None and "sem_seg_file_name" in dic:
