fcn voc-fcn32s training 手起刀落
這一篇是想訓練fcn.berkleyvision.org/voc-fcn32s,
但是照著網路教學,瞎跑都不能得到低的 loss 跟 高 mean accuracy
如果好心人經過可以指點一二,真心感激不盡~
1. github : fcn. berkelyvision
- https://github.com/shelhamer/fcn.berkeleyvision.org.git
- ├── data
│ ├── pascal
│ │ ├── classes.txt
│ │ ├── README.md
│ │ ├── seg11valid.txt
README.md 有提供下載以下兩個資料庫的網址
- test dataset:
- VOCtrainval_11-May-2012
- training dataset :
- benchmark.tgz (我是從官網下載,有一天連進去就載下來了)
- ilsvrc-nets/README.md 有寫
- VGG_ILSVRC_16_layers_deploy.prototxt
- caffemodel_url: http://www.cs.bu.edu/groups/ivc/data/SOS/VGG16_SalObjSub.caffemodel
https://gist.github.com/jimmie33/27c1c0a7736ba66c2395
- fcn.berkeleyvison
- ├── infer.py
├── score.py
├── surgery.py
├── vis.py
├── voc_layers.py
- voc-fcn8s
- ├── voc-fcn8s
│ ├── deploy.prototxt
- ├── caffemodel-url
├── solver.prototxt
├── solve.py
├── net.py ---> 執行net.py 會產生train.prototxt, deploy.prototxt.
├── train.prototxt
└── val.prototxt - ├── deploy.prototxt
- ├── infer.py
├── score.py
├── surgery.py
├── vis.py
├── voc_layers.py
5. Result:
>>> 2019-11-04 21:12:46.816136 Begin seg tests
>>> 2019-11-04 21:13:38.519890 Iteration 100000 loss 14785045.613111412
>>> 2019-11-04 21:13:38.519979 Iteration 100000 overall accuracy 0.7519151040535762
>>> 2019-11-04 21:13:38.520038 Iteration 100000 mean accuracy 0.047619047619047616
>>> 2019-11-04 21:13:38.520189 Iteration 100000 mean IU 0.035805481145408394
>>> 2019-11-04 21:13:38.520283 Iteration 100000 fwavacc 0.5653763237039003
real 373m22.532s
user 291m2.600s
sys 71m55.303s
6. caffemodel 用過 vgg16-fcn.caffemodel 和 vgg_ilsvrc_16_layers_deploy.prototxt
├── ilsvrc-nets
│ ├── README.md
│ ├── vgg16-fcn.caffemodel
│ └── vgg_ilsvrc_16_layers_deploy.prototxt
6.1 Result
>>> 2019-10-28 23:09:09.807761 Begin seg tests
>>> 2019-10-28 23:10:03.737844 Iteration 100000 loss 204808.4506119438
>>> 2019-10-28 23:10:03.737958 Iteration 100000 overall accuracy 0.7519151040535762
>>> 2019-10-28 23:10:03.738027 Iteration 100000 mean accuracy 0.047619047619047616
>>> 2019-10-28 23:10:03.738209 Iteration 100000 mean IU 0.035805481145408394
>>> 2019-10-28 23:10:03.738317 Iteration 100000 fwavacc 0.5653763237039003
--------------------------------------------------------------------------------------------------------
2019/11/19 result
voc-fcn32s fixed learning rate
>>> 2019-11-19 11:17:32.511732 Begin seg tests
>>> 2019-11-19 11:18:40.850477 Iteration 400000 loss 110037.21422411047
>>> 2019-11-19 11:18:40.883480 Iteration 400000 overall accuracy 0.7997448944020139
>>> 2019-11-19 11:18:40.884994 Iteration 400000 mean accuracy 0.39614343211991015
>>> 2019-11-19 11:18:40.886317 Iteration 400000 mean IU 0.3090150660161627
>>> 2019-11-19 11:18:40.886498 Iteration 400000 fwavacc 0.6698493403057357
real 1477m49.550s
user 1067m49.814s
sys 262m44.040s
WARNING: Logging before InitGoogleLogging() is written to STDERR
I1118 10:41:06.658674 3580 upgrade_proto.cpp:1113] snapshot_prefix was a directory and is replaced to snapshot/train_mean/solver
I1118 10:41:06.658700 3580 solver.cpp:45] Initializing solver from parameters:
train_net: "train.prototxt"
test_net: "val.prototxt"
test_iter: 5105
test_interval: 999999999
base_lr: 1e-14
display: 20
max_iter: 100000
lr_policy: "fixed"
momentum: 0.99
weight_decay: 0.0005
snapshot: 4000
snapshot_prefix: "snapshot/train_mean/solver"
test_initialization: false
average_loss: 20
iter_size: 1
I1118 10:41:06.680038 3580 solver.cpp:92] Creating training net from train_net file: train.prototxt
I1118 10:41:06.714169 3580 net.cpp:53] Initializing net from parameters:
state {
phase: TRAIN
}
layer {
name: "data"
type: "Python"
top: "data"
top: "label"
python_param {
module: "voc_layers"
layer: "SBDDSegDataLayer"
param_str: "{\'sbdd_dir\': \'/home/zoey/fcn.berkeleyvision.org/data/pascal/benchmark_RELEASE/dataset\', \'seed\': 1337, \'split\': \'train\', \'mean\': (72.5249, 82.9668, 73.1944)}"
--------------------------------------------------------------------------------------------------------
2019/11/26 fcn16s result
>>> 2019-11-26 08:47:00.978160 Begin seg tests
>>> 2019-11-26 08:47:54.618272 Iteration 400000 loss 52454.30979355522
>>> 2019-11-26 08:47:54.618347 Iteration 400000 overall accuracy 0.8988595064042302
>>> 2019-11-26 08:47:54.618378 Iteration 400000 mean accuracy 0.7665972274429271
>>> 2019-11-26 08:47:54.618493 Iteration 400000 mean IU 0.610513842937149
>>> 2019-11-26 08:47:54.618590 Iteration 400000 fwavacc 0.8290560953274788
real 1393m40.017s
user 1057m28.505s
sys 263m40.896s
train_net: "train.prototxt"
test_net: "val.prototxt"
test_iter: 5105
# make test net, but don't invoke it from the solver itself
test_interval: 999999999
display: 20
average_loss: 20
lr_policy: "fixed"
# lr for unnormalized softmax
base_lr: 1e-12
# high momentum
momentum: 0.99
# no gradient accumulation
iter_size: 1
max_iter: 100000
weight_decay: 0.0005
snapshot: 16000
snapshot_prefix: "snapshot/train"
test_initialization: false
----------------------------------------------------------------------------------------------------
2019/11/27 fcn8s result
ary proto file snapshot/train/solver_iter_400000.solverstate
>>> 2019-11-27 09:56:14.725841 Begin seg tests
>>> 2019-11-27 09:57:08.472657 Iteration 400000 loss 52320.597529286926
>>> 2019-11-27 09:57:08.472755 Iteration 400000 overall accuracy 0.8992662322465721
>>> 2019-11-27 09:57:08.472821 Iteration 400000 mean accuracy 0.7735758690259322
>>> 2019-11-27 09:57:08.473015 Iteration 400000 mean IU 0.6134128305071153
>>> 2019-11-27 09:57:08.473153 Iteration 400000 fwavacc 0.8305588046072755
real 1400m26.232s
user 1063m17.779s
sys 263m38.287s
--------------------------------------------------------------------------------------------------
2019/11/27 fcn8s-atonce result
>>> 2019-11-29 03:44:02.948359 Begin seg tests
>>> 2019-11-29 03:44:57.677574 Iteration 600000 loss 73545.70225838992
>>> 2019-11-29 03:44:57.677653 Iteration 600000 overall accuracy 0.9367826556673325
>>> 2019-11-29 03:44:57.677707 Iteration 600000 mean accuracy 0.8225041223763434
>>> 2019-11-29 03:44:57.677886 Iteration 600000 mean IU 0.7184923129601997
>>> 2019-11-29 03:44:57.678008 Iteration 600000 fwavacc 0.885896417975581
real 2112m24.997s
user 1614m12.777s
sys 395m18.724s
[參考]
- FCN学习:Semantic Segmentation
- 介紹了Fcn 裡面 cnn layer 的參數跟影像大小的算法。
- infer.py,不用自己設置,現在新的voc_palette = vis.make_palette(21)
就可以直接生成21個顏色,跟論文的順序是一樣的。 - 手把手在自己的数据集cityscapes上训练FCN
- 最佳训练的流程是 FCN-32s -> FCN-16s -> FCN 8s,FCN-32s我们用VGG16-fcn从头训练,收敛后Copy weights训练FCN-16s ..至 FCN-8s. 如果一步到FCN-8s也是可以的
- solve.py 的修改,是參考這裡的。
vgg_weights = '../ilsvrc-nets/vgg16-fcn.caffemodel' vgg_proto = '../ilsvrc-nets/VGG_ILSVRC_16_layers_deploy.prototxt'
vgg_net = caffe.Net(vgg_proto, vgg_weights, caffe.TRAIN) surgery.transplant(solver.net, vgg_net) del vgg_net
- FCN网络的训练——以SIFT-Flow 数据集为例
- 一般情况下不要直接修改test.prototxt和trainval.prototxt,而是执行net.py这个脚本,执行完成后也不要将
test.prototxt
和trainval.prototxt
中的fc6
和fc7
替换为其他名称. - deploy.prototxt这个文件,可以从test.prototxt或者trainval.prototxt复制,然后删除最后一层loss层
- FCN 的简单实现
- 這邊用pytorch調參數。
- 這網誌告訴我們4.1 solve.py , 注意是传入的测试集对应的test.txt,不是训练集对应的train.txt。
- AI 從頭學(三四):FCN
- 這網誌很多讀書心得,應該要從頭好好看的
留言
張貼留言