我已经使用 SYNTHIA 数据集(RAND-CITYSCAPES 子集)使用标签图像的第一个通道进行语义分割,如上一篇文章中所建议的那样:
在数据集的 README 文件中,它说第二个通道专用于实例分割:
“GT/LABELS:包含 png 文件的文件夹(每个图像一个)。注释在两个通道中给出。第一个通道包含该像素的类(见下表)。第二个通道包含那些实例的唯一 ID动态物体(汽车、行人等)。”
然后,我尝试使用我编写的以下代码读取实例和语义分割图:
def read_synthia_label(path):
raw_label = np.asarray(imageio.imread(path, format='PNG-FI'))
seg_label = Image.fromarray(np.uint8(raw_label[:,:,0]))
inst_label = Image.fromarray(np.uint16(raw_label[:,:,1]))
return seg_label, inst_label
但是,当我检查标签的一致性时,我观察到同一图像中同一实例标签的分割标签并不相同。即以下断言抛出错误:
with PathManager.open(instance_id_file, "rb") as f:
inst_image = np.asarray(Image.open(f), order="F")
with PathManager.open(segmentation_file, "rb") as f:
segm_image = np.asarray(Image.open(f), order="F")
flattened_inst_ids = np.unique(inst_image)
for instance_id in flattened_inst_ids:
inds_for_same_inst = np.where(instance_id == inst_image.ravel())[0]
assert(segm_image.ravel()[inds_for_same_inst[0]] == segm_image.ravel()[inds_for_same_inst[-1]]) # throws error
我是否以错误的方式阅读实例分割?有没有人使用过 SYNTHIA 进行实例分割?我在网上找不到任何关于此的文档,因此将不胜感激。