2

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?

S.EB
  • 1,966
  • 4
  • 29
  • 54
  • As far as I see, you just have to run the `solve.py` script you want, and that's it. – hbaderts Dec 18 '16 at 14:29
  • @hbaderts Thank you very much for your answer, do you know how can I learn whole network and layers? and how can I apply it on my specific data? I will be thankful if you know any resource for fine-tuning introduce to me. Thanks once again. – S.EB Dec 18 '16 at 15:02
  • @hbaderts how can I download caffemodel? thanks – S.EB Dec 19 '16 at 06:53
  • @hbaderts if you elaborate on your answer it would be very helpful. – Jonathan Dec 27 '17 at 05:37
  • @S.EB if you figured it out, then please post the answer. It'll help future learners. – Jonathan Dec 27 '17 at 05:38
  • @Shai sure, thank you – S.EB Dec 28 '17 at 13:18
  • @Jonathan I added answer, please have a look, I hope it is helpful. P.S. **Shai** has helped me a lot to finally run `fcn8s`. Thanks for his help and guidance – S.EB Dec 28 '17 at 13:23

1 Answers1

2

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

Community
  • 1
  • 1
S.EB
  • 1,966
  • 4
  • 29
  • 54
  • This is really helpful! Thank you! Do you know how to make the data set in the first place? I've asked that question on SO but I've not gotten any responses yet. I looked through some existing data sets and don't quite understand what's going on. So for instance, I have the original image, the same image with the pixels of the object of interest being illuminated (labeled in a certain way I suppose) and then a text file. But how exactly is it formated? Here is the question I asked: https://stackoverflow.com/questions/47964716/how-to-format-a-data-set-for-fully-convolutional-networks – Jonathan Dec 28 '17 at 19:04
  • Also, can you please what the intuition is behind points 5 and 6? – Jonathan Dec 28 '17 at 20:27
  • 1
    @Jonathan I am sorry for late reply, I updated the answer and shared the link for creating the lmdb data for segmentation. – S.EB Jun 24 '18 at 02:48