alexgkendall / SegNet-Tutorial

Files for a tutorial to train SegNet for road scenes using the CamVid dataset
http://mi.eng.cam.ac.uk/projects/segnet/tutorial.html
847 stars 517 forks source link

modification of compute_Bn_statistics for lmdb and hdf5 input? other than rgb? #105

Open hftsai opened 7 years ago

hftsai commented 7 years ago

Hi Alex and guys, First thank you all for several previous discussion on similar issues (some are closed) for changing data input for segnet. But sorry i am still stuck so i wonder if anyone would give me a hand.

for my application, i want to adapt segnet for cell segmentation such as the U-net from U Freiburg. (but i'm really bad at this and couldn't get U-net to work )

Right now i'm getting some results following your tutorial with very minimal modification of adapting to 512x512 input image.

However, i am wondering if preconditioning the data first (such as normalization, histogram equalization) could make it better. explicitly i heard about maybe equalization may help.

But i found out that i couldn't get caffe-segnet to accept 8bit, 16bit, 32bit, or normalized RGB( using imageJ) on denseimagedata.

I figured out i could create 8bit data into lmdb (modification of only input layers, now one is data, one is label ) and let the segnet to train. It appears to be convolute. But i think i need more help on how to compute_bn_statistics. I followed several previous issues to modify the compute_bn_statistics

https://github.com/alexgkendall/caffe-segnet/issues/17

https://github.com/alexgkendall/SegNet-Tutorial/issues/77

here is the data input modification i made in train.prototxt

layer {
  name: "data"
  type: "Data"
  top: "data"
  include {
    phase: TRAIN
  }
  data_param {
    source:"/home/davince/SegNet/Ph/8bitlmdb/features"
    batch_size: 1
    backend: LMDB
  }
}

layer {
  name: "label"
  type: "Data"
  top: "label"
  include {
    phase: TRAIN
  }
  data_param {
    source:"/home/davince/SegNet/Ph/8bitlmdb/labels"
    batch_size: 1
    backend: LMDB
  }
}

i have three classes of label (0, background, 1, and 2) so the num_output for conv1_2_D was 3.

I made modification to compute_bn_statistics.py only on the last part as from issues discussed before

print "Calculate BN stats...
    #train_ims, train_labs = extract_dataset(testable_msg)
    #train_size = len(train_ims)
    train_size= 10 #just try to avoid inputdata check as denseimage data
    #minibatch_size = testable_msg.layer[0].dense_image_data_param.batch_size
    minibatch_size = testable_msg.layer[0].data_param.batch_size
    num_iterations = train_size // minibatch_size + train_size % minibatch_size
    in_h, in_w =(512, 512)
    test_net, test_msg = make_test_files(BN_calc_path, args.weights, num_iterations,
                                         in_h, in_w)

But it generates an error. F0613 08:40:33.065414 29467 insert_splits.cpp:35] Unknown blob input data to layer 0

I wonder if anyone could give me some help on what mistake i've made?

i also heard 16bit could be possible with hdf5. But i haven't figure out how to correctly put my data into hdf5. But i would imagine i need to modify the compute_bn_statistics also if i switched to hdf5?

I really appreciate any help in advance.

Thank you.