简体   繁体   English

使用 SYNTHIA 数据集进行实例分割

[英]Using SYNTHIA dataset for instance segmentation

I haved used SYNTHIA dataset (RAND-CITYSCAPES subset) for semantic segmentation using the first channel of the label image as suggested in the previous post:我已经使用 SYNTHIA 数据集(RAND-CITYSCAPES 子集)使用标签图像的第一个通道进行语义分割,如上一篇文章中所述:

How to read the label(annotation) file from Synthia Dataset? 如何从 Synthia 数据集中读取标签(注释)文件? . .

In the README file of the dataset, it says the second channel is devoted for the instance segmentation:在数据集的 README 文件中,它说第二个通道专门用于实例分割:

"GT/LABELS: folder containing png files (one per image). Annotations are given in two channels. The first channel contains the class of that pixel (see the table below). The second channel contains the unique ID of the instance for those objects that are dynamic (cars, pedestrians, etc.)." “GT/LABELS:包含 png 文件的文件夹(每个图像一个。注释在两个通道中给出。第一个通道包含该像素的类(见下表)。第二个通道包含那些实例的唯一 ID动态物体(汽车、行人等)。”

Then, I try to read the instance and semantic segmentation maps using the following code I wrote:然后,我尝试使用我编写的以下代码读取实例和语义分割图:

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

However, when I check the consistency of the labels, I observed that segmentation labels for the same instance label within the same image are not the same.但是,当我检查标签的一致性时,我观察到同一图像中相同实例标签的分割标签并不相同。 Ie the following assert throws error:即以下断言引发错误:

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   

Am I reading the instance segmentation in the wrong way?我是否以错误的方式阅读实例分割? Had anyone ever used SYNTHIA for instance segmentation?有没有人使用过 SYNTHIA 进行实例分割? I could not find any documentation on this on the web, so any help would be appreciated.我在网上找不到任何有关此的文档,因此将不胜感激。

I experienced the same behavior you described in SYNTHIA VIDEO SEQUENCES.我遇到了您在 SYNTHIA VIDEO SEQUENCES 中描述的相同行为。

However, this is an issue just for some classes.然而,这只是一些类的问题。 For dynamic objects, as stated in README (see below), the segmentation labels for the same instance label within the same image are the same, ie, consistent.对于动态对象,如README中所述(见下文),同一图像内同一实例标签的分割标签是相同的,即一致的。

README:自述文件:

  • GT/LABELS: folder containing png files (one per image). GT/LABELS:包含 png 文件的文件夹(每个图像一个)。 Annotations are given in two channels.注释在两个通道中给出。 The first channel contains the class of that pixel (see the table below).第一个通道包含该像素的类别(见下表)。 The second channel contains the unique ID of the instance for those objects that are dynamic ( cars, pedestrians, etc. ).第二个通道包含动态对象(汽车、行人等)的实例的唯一 ID。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM