说明:
- 记录试验过程以及数据
- 每次更新内容在最上,旧的内容在下,按照时间顺序排列
试验内容:
- 用迁移学习的方法,利用前期获得的视网膜血管分割 'caffemodel' ,在Caffe框架上进行finetune,重新得到 地面裂缝 识别的caffemodel
- 样例图片
-
视网膜血管图片:
-
地面裂缝图片:
-
2017-10-31
实验数据:
总览:
- retina_20171017_21_train_iter_250000.caffemodel (视网膜血管caffemodel)
- solver.prototxt
- train_val.prototxt
- train_val_deploy.prototxt
细览:
- solver.prototxt
net: "C:/Users/M&L/Documents/Python Scripts/TF/data/train_val.prototxt"
test_iter: 100
test_interval: 500
base_lr: 0.001
lr_policy: "step"
gamma: 0.1
stepsize: 40000
display: 20
max_iter: 10000
momentum: 0.9
weight_decay: 0.0005
snapshot: 30000
snapshot_prefix: "C:/Users/M&L/Documents/Python Scripts/TF/data/transfer_20171027_train"
solver_mode: GPU
- train_val.prototxt
name: "RetinaNet"
layer {
type: "Data"
top: "X" # same name as given in create_dataset!
top: "y"
include {
phase:TRAIN
}
data_param {
source: "C:/Users/M&L/Documents/Python Scripts/TF/data/train_lmdb"
batch_size: 128
backend: LMDB
}
}
layer {
type: "Data"
top: "X"
top: "y"
include {
phase: TEST
}
data_param {
source: "C:/Users/M&L/Documents/Python Scripts/TF/data/test_lmdb"
batch_size: 128
backend: LMDB
}
}
layer {
name: "conv1"
type: "Convolution"
bottom: "X"
top: "conv1"
param {
lr_mult: 1
decay_mult: 1
}
param {
lr_mult: 2
decay_mult: 0
}
convolution_param {
num_output: 64
kernel_size: 3
stride: 1
pad: 1
weight_filler {
type: "xavier"
std: 0.01
}
bias_filler {
type: "constant"
value: 0
}
}
}
layer {
name: "relu1"
type: "ReLU"
bottom: "conv1"
top: "conv1"
}
layer {
name: "conv2"
type: "Convolution"
bottom: "conv1"
top: "conv2"
param {
lr_mult: 1
decay_mult: 1
}
param {
lr_mult: 2
decay_mult: 0
}
convolution_param {
num_output: 64
kernel_size: 3
stride: 1
pad: 1
weight_filler {
type: "xavier"
std: 0.01
}
bias_filler {
type: "constant"
value: 0
}
}
}
layer {
name: "relu2"
type: "ReLU"
bottom: "conv2"
top: "conv2"
}
layer {
name: "conv3"
type: "Convolution"
bottom: "conv2"
top: "conv3"
param {
lr_mult: 1
decay_mult: 1
}
param {
lr_mult: 2
decay_mult: 0
}
convolution_param {
num_output: 128
kernel_size: 3
stride: 1
pad: 1
weight_filler {
type: "xavier"
std: 0.01
}
bias_filler {
type: "constant"
value: 0
}
}
}
layer {
name: "relu3"
type: "ReLU"
bottom: "conv3"
top: "conv3"
}
layer {
name: "conv4"
type: "Convolution"
bottom: "conv3"
top: "conv4"
param {
lr_mult: 1
decay_mult: 1
}
param {
lr_mult: 2
decay_mult: 0
}
convolution_param {
num_output: 128
kernel_size: 3
stride: 1
pad: 1
weight_filler {
type: "xavier"
std: 0.01
}
bias_filler {
type: "constant"
value: 0
}
}
}
layer {
name: "relu4"
type: "ReLU"
bottom: "conv4"
top: "conv4"
}
layer {
name: "conv4_1"
type: "Convolution"
bottom: "conv4"
top: "conv4_1"
param {
lr_mult: 1
decay_mult: 1
}
param {
lr_mult: 2
decay_mult: 0
}
convolution_param {
num_output: 256
kernel_size: 3
stride: 1
pad: 1
weight_filler {
type: "xavier"
std: 0.01
}
bias_filler {
type: "constant"
value: 0
}
}
}
layer {
name: "relu4_1"
type: "ReLU"
bottom: "conv4_1"
top: "conv4_1"
}
layer {
name: "conv4_2"
type: "Convolution"
bottom: "conv4_1"
top: "conv4_2"
param {
lr_mult: 1
decay_mult: 1
}
param {
lr_mult: 2
decay_mult: 0
}
convolution_param {
num_output: 256
kernel_size: 3
stride: 1
pad: 1
weight_filler {
type: "xavier"
std: 0.01
}
bias_filler {
type: "constant"
value: 0
}
}
}
layer {
name: "relu4_2"
type: "ReLU"
bottom: "conv4_2"
top: "conv4_2"
}
layer {
name: "fc5-my"
type: "InnerProduct"
bottom: "conv4_2"
top: "fc5-my"
param {
lr_mult: 1
decay_mult: 1
}
param {
lr_mult: 2
decay_mult: 0
}
inner_product_param {
num_output: 512
weight_filler {
type: "xavier"
std: 0.01
}
bias_filler {
type: "constant"
value: 0
}
}
}
layer {
name: "relu5"
type: "ReLU"
bottom: "fc5-my"
top: "fc5-my"
}
layer {
name: "drop5"
type: "Dropout"
bottom: "fc5-my"
top: "fc5-my"
dropout_param {
dropout_ratio: 0.5
}
}
layer {
name: "fc6"
type: "InnerProduct"
bottom: "fc5-my"
top: "fc6"
param {
lr_mult: 1
decay_mult: 1
}
param {
lr_mult: 2
decay_mult: 0
}
inner_product_param {
num_output: 512
weight_filler {
type: "xavier"
std: 0.01
}
bias_filler {
type: "constant"
value: 0
}
}
}
layer {
name: "relu6"
type: "ReLU"
bottom: "fc6"
top: "fc6"
}
layer {
name: "drop6"
type: "Dropout"
bottom: "fc6"
top: "fc6"
dropout_param {
dropout_ratio: 0.5
}
}
layer {
name: "fc7"
type: "InnerProduct"
bottom: "fc6"
top: "fc7"
param {
lr_mult: 1
decay_mult: 1
}
param {
lr_mult: 2
decay_mult: 0
}
inner_product_param {
num_output: 2
weight_filler {
type: "xavier"
std: 0.01
}
bias_filler {
type: "constant"
value: 0
}
}
}
layer {
name: "accuracy"
type: "Accuracy"
bottom: "fc7"
bottom: "y"
top: "accuracy"
include {
phase: TEST
}
}
layer {
name: "accuracy"
type: "Accuracy"
bottom: "fc7"
bottom: "y"
top: "accuracy"
include {
phase: TRAIN
}
}
layer {
name: "loss"
type: "SoftmaxWithLoss"
bottom: "fc7"
bottom: "y"
top: "loss"
}
- train_val_deploy.prototxt
name: "RetinaNet"
input: "data"
input_shape: {
dim: 1
dim: 3
dim: 25
dim: 25
}
layer {
name: "conv1"
type: "Convolution"
bottom: "data"
top: "conv1"
param {
lr_mult: 1
decay_mult: 1
}
param {
lr_mult: 2
decay_mult: 0
}
convolution_param {
num_output: 64
kernel_size: 3
stride: 1
pad: 1
weight_filler {
type: "xavier"
std: 0.01
}
bias_filler {
type: "constant"
value: 0
}
}
}
layer {
name: "relu1"
type: "ReLU"
bottom: "conv1"
top: "conv1"
}
layer {
name: "conv2"
type: "Convolution"
bottom: "conv1"
top: "conv2"
param {
lr_mult: 1
decay_mult: 1
}
param {
lr_mult: 2
decay_mult: 0
}
convolution_param {
num_output: 64
kernel_size: 3
stride: 1
pad: 1
weight_filler {
type: "xavier"
std: 0.01
}
bias_filler {
type: "constant"
value: 0
}
}
}
layer {
name: "relu2"
type: "ReLU"
bottom: "conv2"
top: "conv2"
}
layer {
name: "conv3"
type: "Convolution"
bottom: "conv2"
top: "conv3"
param {
lr_mult: 1
decay_mult: 1
}
param {
lr_mult: 2
decay_mult: 0
}
convolution_param {
num_output: 128
kernel_size: 3
stride: 1
pad: 1
weight_filler {
type: "xavier"
std: 0.01
}
bias_filler {
type: "constant"
value: 0
}
}
}
layer {
name: "relu3"
type: "ReLU"
bottom: "conv3"
top: "conv3"
}
layer {
name: "conv4"
type: "Convolution"
bottom: "conv3"
top: "conv4"
param {
lr_mult: 1
decay_mult: 1
}
param {
lr_mult: 2
decay_mult: 0
}
convolution_param {
num_output: 128
kernel_size: 3
stride: 1
pad: 1
weight_filler {
type: "xavier"
std: 0.01
}
bias_filler {
type: "constant"
value: 0
}
}
}
layer {
name: "relu4"
type: "ReLU"
bottom: "conv4"
top: "conv4"
}
layer {
name: "conv4_1"
type: "Convolution"
bottom: "conv4"
top: "conv4_1"
param {
lr_mult: 1
decay_mult: 1
}
param {
lr_mult: 2
decay_mult: 0
}
convolution_param {
num_output: 256
kernel_size: 3
stride: 1
pad: 1
weight_filler {
type: "xavier"
std: 0.01
}
bias_filler {
type: "constant"
value: 0
}
}
}
layer {
name: "relu4_1"
type: "ReLU"
bottom: "conv4_1"
top: "conv4_1"
}
layer {
name: "conv4_2"
type: "Convolution"
bottom: "conv4_1"
top: "conv4_2"
param {
lr_mult: 1
decay_mult: 1
}
param {
lr_mult: 2
decay_mult: 0
}
convolution_param {
num_output: 256
kernel_size: 3
stride: 1
pad: 1
weight_filler {
type: "xavier"
std: 0.01
}
bias_filler {
type: "constant"
value: 0
}
}
}
layer {
name: "relu4_2"
type: "ReLU"
bottom: "conv4_2"
top: "conv4_2"
}
layer {
name: "fc5"
type: "InnerProduct"
bottom: "conv4_2"
top: "fc5"
param {
lr_mult: 1
decay_mult: 1
}
param {
lr_mult: 2
decay_mult: 0
}
inner_product_param {
num_output: 512
weight_filler {
type: "xavier"
std: 0.01
}
bias_filler {
type: "constant"
value: 0
}
}
}
layer {
name: "relu5"
type: "ReLU"
bottom: "fc5"
top: "fc5"
}
layer {
name: "drop5"
type: "Dropout"
bottom: "fc5"
top: "fc5"
dropout_param {
dropout_ratio: 0.5
}
}
layer {
name: "fc6"
type: "InnerProduct"
bottom: "fc5"
top: "fc6"
param {
lr_mult: 1
decay_mult: 1
}
param {
lr_mult: 2
decay_mult: 0
}
inner_product_param {
num_output: 512
weight_filler {
type: "xavier"
std: 0.01
}
bias_filler {
type: "constant"
value: 0
}
}
}
layer {
name: "relu6"
type: "ReLU"
bottom: "fc6"
top: "fc6"
}
layer {
name: "drop6"
type: "Dropout"
bottom: "fc6"
top: "fc6"
dropout_param {
dropout_ratio: 0.5
}
}
layer {
name: "fc7"
type: "InnerProduct"
bottom: "fc6"
top: "fc7"
param {
lr_mult: 1
decay_mult: 1
}
param {
lr_mult: 2
decay_mult: 0
}
inner_product_param {
num_output: 2
weight_filler {
type: "xavier"
std: 0.01
}
bias_filler {
type: "constant"
value: 0
}
}
}
layer {
name: "result"
type: "Softmax"
bottom: "fc7"
top: "result"
}
图片数据:
序号 | 名称 | 图片大小 | 数量(张) | 标签文件 |
---|---|---|---|---|
1 | img_seg_train | 25*25 | 20520 | train.txt |
2 | img_seg_test | 25*25 | 5016 | test.txt |
3 | img_seg_veri | 25*25 | 1368 | veri.txt |
将图片数据转换成lmdb格式数据:
- 创建一个bat文件:
lmdb.bat
C:\Caffe\caffe-master\Build\x64\Release\convert_imageset.exe --shuffle --resize_width=25 --resize_height=25 img_seg_train\ train.txt train_lmdb --backend="lmdb"
C:\Caffe\caffe-master\Build\x64\Release\convert_imageset.exe --shuffle --resize_width=25 --resize_height=25 img_seg_test\ test.txt test_lmdb --backend="lmdb"
Pause
Finetune训练:
- 创建一个bat文件,进行训练
run.bat
C:\Caffe\caffe-master\Build\x64\Release\caffe.exe train -solver solver.prototxt -weights retina_20171017_21_train_iter_250000.caffemodel
Pause
其中参数:-weights retina_20171017_21_train_iter_250000.caffemodel 就代表进行finetune
试验结果
-
识别效果:
-
标签图片
-
结果图片
-
-
结果分析
1、图片分辨率太低,背景太复杂,导致特征提取不明显
-
loss曲线
- 未画出
更新
2017/11/01
本次更新主要内容:
- 对数据切割的大小进行调整,调整为21*21像素大小
- 考虑到原来数据集较小,通过旋转变换等,将原来图片数据集扩大了三倍,观察是否会有更好的结果,如果结果并不比之前较好,说明迁移学习的方法有待改善
将调整后的数据制作成lmdb文件,重新进行训练,漫长的等待...
更新
2017/11/04
本次更新主要内容:
- 考虑到上次识别效果特别差,猜想是网络结构的原因,故这次试验使用不同的网络架构——LeNet
- 本次试验主要参数:
net: "examples/mnist/lenet_train_test.prototxt"
test_iter: 100
test_interval: 500
base_lr: 0.01
momentum: 0.9
weight_decay: 0.0005
lr_policy: "inv"
gamma: 0.0001
power: 0.75
display: 100
max_iter: 10000
snapshot: 5000
snapshot_prefix: "examples/mnist/lenet"
solver_mode: GPU
试验效果:
- 识别图片&标签图片:
总体来看是被效果还是不错的,准确率为:0.907308
- 曲线图:
总结:
- 视网膜血管图片和道路裂缝图片特征相差太大,不能使用视网膜血管中的网络模型
- 道路裂纹图片中背景复杂,干扰很大,导致在训练时提取特征的困难