全卷积神经网络 图像语义分割实验:FCN数据集制作,网络模型定义,网络训练(提供数据集和模型文件,以供参考)

http://blog.csdn.net/muyouhang/article/details/53608928

 

更新于2016年12月29. 
下载:自制数据集供参考 
下载: 自己改的网络

论文:《Fully Convolutional Networks for Semantic Segmentation》 
代码:FCN的Caffe 实现 
数据集:PascalVOC

一 数据集制作

PascalVOC数据下载下来后,制作用以图像分割的图像数据集和标签数据集,LMDB或者LEVELDB格式。 
最好resize一下(填充的方式)。 
1. 数据文件夹构成 
包括原始图片和标签图片,如下。 
Class 
这里写图片描述

然后,构建对应的lmdb文件。可以将所有图片4:1分为train:val的比例。每个txt文件列出图像路径就可以,不用给label,因为image的label还是image,在caffe中指定就行。

Img_train.txt
SegmentationImage/002120.png
SegmentationImage/002132.png
SegmentationImage/002142.png
SegmentationImage/002212.png
SegmentationImage/002234.png
SegmentationImage/002260.png
SegmentationImage/002266.png
SegmentationImage/002268.png
SegmentationImage/002273.png
SegmentationImage/002281.png
SegmentationImage/002284.png
SegmentationImage/002293.png
SegmentationImage/002361.png
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
Label_train.txt
SegmentationClass/002120.png
SegmentationClass/002132.png
SegmentationClass/002142.png
SegmentationClass/002212.png
SegmentationClass/002234.png
SegmentationClass/002260.png
SegmentationClass/002266.png
SegmentationClass/002268.png
SegmentationClass/002273.png
SegmentationClass/002281.png
SegmentationClass/002284.png
SegmentationClass/002293.png
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13

注意:label要自己生成,根据SegmentationClass下的gt图片。 
每个类别的像素值如下:

类别名称 R G B 
background 0 0 0 背景 
aeroplane 128 0 0 飞机 
bicycle 0 128 0 
bird 128 128 0 
boat 0 0 128 
bottle 128 0 128 瓶子 
bus 0 128 128 大巴 
car 128 128 128 
cat 64 0 0 猫 
chair 192 0 0 
cow 64 128 0 
diningtable 192 128 0 餐桌 
dog 64 0 128 
horse 192 0 128 
motorbike 64 128 128 
person 192 128 128 
pottedplant 0 64 0 盆栽 
sheep 128 64 0 
sofa 0 192 0 
train 128 192 0 
tvmonitor 0 64 128 显示器 
对数据集中的grand truth 图像进行处理,生成用以训练的label图像。 
需要注意的是,label文件要是gray格式,不然会出错:scores层输出与label的数据尺寸不一致,通道问题导致的。 
然后生成lmdb就行了。数据集准备完毕。 
这里写图片描述

二 网络模型定义

这里主要考虑的是数据输入的问题,指定data和label,如下。

layer {
  name: "data"
  type: "Data"
  top:"data"
  include {
    phase: TRAIN
  }
  transform_param {
scale: 0.00390625
    mean_file: "G:/interest_of_imags_for_recognation/VOC2007/Resize224/Img_train_mean.binaryproto"
  }
  data_param {
    source: "G:/interest_of_imags_for_recognation/VOC2007/Resize224/Img_train"
    batch_size: 1
    backend: LMDB
  }
}
layer {
  name: "label"
  type: "Data"
  top:"label"
  include {
    phase: TRAIN
  }
  transform_param {
scale: 0.00390625
    mean_file: "G:/interest_of_imags_for_recognation/VOC2007/Resize224/Label_train_mean.binaryproto"
  }
  data_param {
    source: "G:/interest_of_imags_for_recognation/VOC2007/Resize224/Label_train"
    batch_size: 1
    backend: LMDB
  }
}
layer {
  name: "data"
  type: "Data"
  top: "data"
  include {
    phase: TEST
  }
  transform_param {
scale: 0.00390625
    mean_file: "G:/interest_of_imags_for_recognation/VOC2007/Resize224/Img_val_mean.binaryproto"
  }
  data_param {
    source: "G:/interest_of_imags_for_recognation/VOC2007/Resize224/Img_val"
    batch_size: 1
    backend: LMDB
  }
}
layer {
  name: "label"
  type: "Data"
  top: "label"
  include {
    phase: TEST
  }
  transform_param {
scale: 0.00390625
    mean_file: "G:/interest_of_imags_for_recognation/VOC2007/Resize224/Label_val_mean.binaryproto"
  }
  data_param {
    source: "G:/interest_of_imags_for_recognation/VOC2007/Resize224/Label_val"
    batch_size: 1
    backend: LMDB
  }
}

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43
  • 44
  • 45
  • 46
  • 47
  • 48
  • 49
  • 50
  • 51
  • 52
  • 53
  • 54
  • 55
  • 56
  • 57
  • 58
  • 59
  • 60
  • 61
  • 62
  • 63
  • 64
  • 65
  • 66
  • 67
  • 68
  • 69
  • 70

三 网络训练

最好fintune,不然loss下降太慢。

posted on 2017-09-29 20:40  `早茶月光  阅读(1514)  评论(0)    收藏  举报

导航