How did you run FCN code semantic segmentation?

852 views Asked by At

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.

Is there any step by step guidance for running?

1

There are 1 answers

3
S.EB On BEST ANSWER

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:

  1. 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)

  2. 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.

  3. Download the .caffemodel from the url that authors have provided,

  4. 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

  5. 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):

    layer { name: "score_5classes" type: "Convolution" bottom: "score" top: "score_5classes" convolution_param { num_output: 5 pad: 0 kernel_size: 1 } }

  6. 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 } }

  7. 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