I wanted to run the [FCN code][1] for semantic segmentation. However, I am beginner in Caffe and I did not know from which point should I start running the code.
Since I could not get that much help here, I am posting the steps here. It might be helpful for those who are inexperienced (like me). It took long time for me to figure out how to run it and get the results. you may be able to run it successfully, but similar to my case, the results was blank image for long time and finally found out that how setting should be.
I could perform successfully FCN8s on my data and I did the following steps:
Divide the data into two sets (train, validation) and the labels as well for the corresponding images in both train and validation (4 folder altogether: train_img_lmdb, train_label_lmdb, val_img_lmdb and val_label_lmdb)
Convert your data (each of them separately) into LMDB format (if it is not RGB, convert it using cv2 function), you will have 4 lmdb folders including data.mdb and lock.mdb. the sample code is available here.
Download the .caffemodel from the url that authors have provided,
Change the path to the path of your lmdb files in the train_val.ptototxt file, you should have 4 data layer that source is the path to the train_img_lmdb, train_label_lmdb, val_img_lmdb and val_label_lmdb, similar to this link
Add a convolution layer after this line (here, I have five classes, then change the num_output based on the number of classes in ground truth images):
Since I could not get that much help here, I am posting the steps here. It might be helpful for those who are inexperienced (like me). It took long time for me to figure out how to run it and get the results. you may be able to run it successfully, but similar to my case, the results was blank image for long time and finally found out that how setting should be.
I could perform successfully FCN8s on my data and I did the following steps:
Divide the data into two sets (train, validation) and the labels as well for the corresponding images in both train and validation (4 folder altogether:
train_img_lmdb
,train_label_lmdb
,val_img_lmdb
andval_label_lmdb
)Convert your data (each of them separately) into LMDB format (if it is not RGB, convert it using cv2 function), you will have 4 lmdb folders including
data.mdb
andlock.mdb
. the sample code is available here.Download the
.caffemodel
from the url that authors have provided,Change the path to the path of your lmdb files in the
train_val.ptototxt
file, you should have 4 data layer thatsource
is the path to thetrain_img_lmdb
,train_label_lmdb
,val_img_lmdb
andval_label_lmdb
, similar to this linkAdd a
convolution
layer after this line (here, I have five classes, then change thenum_output
based on the number of classes in ground truth images):layer { name: "score_5classes" type: "Convolution" bottom: "score" top: "score_5classes" convolution_param { num_output: 5 pad: 0 kernel_size: 1 } }
change loss layer as follows(just according what name you have in bottom layer):
layer { name: "loss" type: "SoftmaxWithLoss" bottom: "score_5classes" bottom: "label" top: "loss" loss_param { normalize: true } }
Run the model to start training in you have pycaffe and installed
caffe
environment.caffe train -solver=/path/to/solver.prototxt -weights /path/to/pre-trained/model/fcn8s-heavy-pascal.caffemodel 2>&1 | tee /path/to/save/training/log/file/fcn8_exp1.log
I hope it is helpful. Thanks for @Shai's helps