【问题标题】:How labelling works in image segmentation [SegNet]标签在图像分割中的工作原理 [SegNet]
【发布时间】:2018-10-18 01:32:11
【问题描述】:

我正在尝试了解在 keras 中使用 SegNet 实现的图像分割。我已经阅读了使用 Conv 和 Deconv 架构以及使用 Dilated conv 层的原始论文。但是,我无法理解像素标签的工作原理。

我正在考虑以下实现: https://github.com/nicolov/segmentation_keras

这里用到了pascal数据集属性:

21 类:

# 0=background
# 1=aeroplane, 2=bicycle, 3=bird, 4=boat, 5=bottle
# 6=bus, 7=car, 8=cat, 9=chair, 10=cow
# 11=diningtable, 12=dog, 13=horse, 14=motorbike, 15=person
# 16=potted plant, 17=sheep, 18=sofa, 19=train, 20=tv/monitor

类由以下表示:

pascal_nclasses = 21
pascal_palette = np.array([(0, 0, 0)
    , (128, 0, 0), (0, 128, 0), (128, 128, 0), (0, 0, 128), (128, 0, 128)
    , (0, 128, 128), (128, 128, 128), (64, 0, 0), (192, 0, 0), (64, 128, 0)
    , (192, 128, 0), (64, 0, 128), (192, 0, 128), (64, 128, 128), (192, 128, 128)
    , (0, 64, 0), (128, 64, 0), (0, 192, 0), (128, 192, 0), (0, 64, 128)], dtype=np.uint8)

我试图打开猫和船的标记图像,因为猫只在 R 空间中,船只在蓝色。我使用以下来显示标记的图像:

船用:

label = cv2.imread("2008_000120.png")
label = np.multiply(label, 100)
cv2.imshow("kk", label[:,:,2])
cv2.waitKey(0)

对于猫:

label = cv2.imread("2008_000056.png")
label = np.multiply(label, 100)
cv2.imshow("kk", label[:,:,0])
cv2.waitKey(0)

但是,无论我选择哪个空间,两张图像总是会得到相同的结果。即下面的代码也给出了相同的结果

船用:

label = cv2.imread("2008_000120.png")
label = np.multiply(label, 100)
cv2.imshow("kk", label[:,:,1]) # changed to Green space
cv2.waitKey(0)

对于猫:

label = cv2.imread("2008_000056.png")
label = np.multiply(label, 100)
cv2.imshow("kk", label[:,:,1]) # changed to Green space
cv2.waitKey(0)

我的假设是我只会看到红色空间中的猫和蓝色空间中的船。但是,所有情况下的输出:

我现在很困惑这些像素是如何标记的,以及它们是如何被读取的,以及如何在创建 logits 的过程中唯一地用于与类别配对。

如果有人可以解释或放置一些相关链接来理解这个过程,那就太好了。我尝试搜索,但大多数教程只讨论 CNN 架构,而不是标签过程或这些标签在 CNN 中的使用方式。

我附上了猫和船的标记图像以供参考。

【问题讨论】:

    标签: image-processing tensorflow keras computer-vision image-segmentation


    【解决方案1】:

    标签只是二进制图像掩码,因此是单通道图像。标签图像每个位置的像素值会根据每个像素的类别而变化。因此,当像素处没有对象时,它的值为 0,否则为 1-20,具体取决于类别。

    语义分割是一项分类任务,因此您尝试将每个像素分类为一个类别(在本例中,类别标签为 0-20)。

    您的模型将生成输出图像,并且您希望在每个输出图像像素和每个标签图像像素之间执行 softmax 交叉熵。

    在多类情况下,您有 K 个类别(例如此处 K=21),每个像素将有 K 个通道,并且您在每个像素的通道上执行 softmax 交叉熵。为什么每个班级都有一个频道?想想在分类中,我们为 K 个类别生成一个长度为 K 的向量,并将其与长度为 K 的一个热向量进行比较。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2018-08-13
      • 2017-12-24
      • 2016-03-18
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2023-03-30
      • 1970-01-01
      相关资源
      最近更新 更多