From 3b056b3c00599ce2546d0e94b4fb4da89f676479 Mon Sep 17 00:00:00 2001 From: LWShowTime <51390653+LWShowTime@users.noreply.github.com> Date: Thu, 14 Nov 2024 16:44:01 +0800 Subject: [PATCH] visualizer's sem_seg function dtype uint8 cannot handle classes more than 256 Update visualizer.py --- detectron2/utils/visualizer.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/detectron2/utils/visualizer.py b/detectron2/utils/visualizer.py index bb6c24ee97..c64f8ee676 100644 --- a/detectron2/utils/visualizer.py +++ b/detectron2/utils/visualizer.py @@ -600,7 +600,9 @@ def draw_dataset_dict(self, dic): if sem_seg is None and "sem_seg_file_name" in dic: with PathManager.open(dic["sem_seg_file_name"], "rb") as f: sem_seg = Image.open(f) - sem_seg = np.asarray(sem_seg, dtype="uint8") + # sem_seg = np.asarray(sem_seg, dtype="uint8") + # The dtype uint8 is 0-255 which is not suitable for GT visualization of Pascal Context 459 whose class num is more than 256 and make the visualization text wrong! + sem_seg = np.asarray(sem_seg, dtype=np.int16) if sem_seg is not None: self.draw_sem_seg(sem_seg, area_threshold=0, alpha=0.5)