Closed chongchongmao closed 7 months ago
这个在预测结果上palatte指定和gt一样就可以了,应该不难设置的。
因为论文需要,这个问题我解决了: 把 PaddleSeg\paddleseg\utils\visualize.py中的 get_color_map_list替换成如下即可:
def get_color_map_list(num_classes, custom_color=None): """ Returns the color map for visualizing the segmentation mask, which can support arbitrary number of classes.
Args:
num_classes (int): Number of classes.
custom_color (list, optional): Save images with a custom color map. Default: None, use paddleseg's default color map.
Returns:
(list). The color map.
"""
# Cityscapes predefined colors for 19 classes
CITYSCAPES_PALETTE = [
(128, 64, 128),
(244, 35, 232),
(70, 70, 70),
(102, 102, 156),
(190, 153, 153),
(153, 153, 153),
(250, 170, 30),
(220, 220, 0),
(107, 142, 35),
(152, 251, 152),
(70, 130, 180),
(220, 20, 60),
(255, 0, 0),
(0, 0, 142),
(0, 0, 70),
(0, 60, 100),
(0, 80, 100),
(0, 0, 230),
(119, 11, 32)
]
color_map = []
# First, use the custom color or Cityscapes palette
if custom_color:
color_map.extend(custom_color)
else:
color_map.extend(CITYSCAPES_PALETTE)
# Then, use the default way to generate rest of the colors
while len(color_map) < num_classes:
idx = len(color_map)
j = 0
lab = idx
r = 0
g = 0
b = 0
while lab:
r |= (((lab >> 0) & 1) << (7 - j))
g |= (((lab >> 1) & 1) << (7 - j))
b |= (((lab >> 2) & 1) << (7 - j))
j += 1
lab >>= 3
color_map.append((r, g, b))
return [item for sublist in color_map for item in sublist][:num_classes * 3]
感谢感谢
毛冲冲 @.*** |
---|
---- 回复的原邮件 ---- | 发件人 | @.> | | 日期 | 2023年08月29日 17:21 | | 收件人 | @.> | | 抄送至 | @.>@.> | | 主题 | Re: [PaddlePaddle/PaddleSeg] 是否可以将语义分割数据集cityscapes和Camvid等数据集的预测时类别的custom_color的取值给出,使得预测的结果颜色与给的groundtruth一样。 (Issue #3343) |
因为论文需要,这个问题我解决了: 把 PaddleSeg\paddleseg\utils\visualize.py中的 get_color_map_list替换成如下即可:
def get_color_map_list(num_classes, custom_color=None): """ Returns the color map for visualizing the segmentation mask, which can support arbitrary number of classes.
Args: num_classes (int): Number of classes. custom_color (list, optional): Save images with a custom color map. Default: None, use paddleseg's default color map.
Returns: (list). The color map. """
CITYSCAPES_PALETTE = [ (128, 64, 128), (244, 35, 232), (70, 70, 70), (102, 102, 156), (190, 153, 153), (153, 153, 153), (250, 170, 30), (220, 220, 0), (107, 142, 35), (152, 251, 152), (70, 130, 180), (220, 20, 60), (255, 0, 0), (0, 0, 142), (0, 0, 70), (0, 60, 100), (0, 80, 100), (0, 0, 230), (119, 11, 32) ]
color_map = []
if custom_color: color_map.extend(custom_color) else: color_map.extend(CITYSCAPES_PALETTE)
while len(color_map) < num_classes: idx = len(color_map) j = 0 lab = idx r = 0 g = 0 b = 0 while lab: r |= (((lab >> 0) & 1) << (7 - j)) g |= (((lab >> 1) & 1) << (7 - j)) b |= (((lab >> 2) & 1) << (7 - j)) j += 1 lab >>= 3 color_map.append((r, g, b))
return [item for sublist in color_map for item in sublist][:num_classes * 3]
— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you authored the thread.Message ID: @.***>
问题确认 Search before asking
需求描述 Feature Description
是否愿意提交PR Are you willing to submit a PR?