【发布时间】: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