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

How to handle unlabelled pixels? #20

Closed aseembits93 closed 8 years ago

aseembits93 commented 8 years ago

I have my own dataset with 2 classes and a lot of pixels don't belong to either of the classes. I have assigned 0 to such pixels in the label image and 1,2 to the classes. I want to train only for labels 1,2 and not 0. Also how do I assign class weight in the softmax layer of the train.prototext file?

arushk1 commented 8 years ago

I guess you'll have to experiment with that. I couldn't find anything on that in the paper or in the description. What do your classes represent?

aseembits93 commented 8 years ago

i have an indoor dataset with two labels, table and floor. If i put num_output 2 in the last layer, it gives an error. so i have to put num_output 3.

alexgkendall commented 8 years ago

Have a look at line 1537 in the segnet model.

If you set table=0, floor=1 and your unlabelled pixels to 2 then you can set num_output=2 with ignore_label=2. Hope this helps!

aseembits93 commented 8 years ago

Thanks @alexgkendall . One more thing, what about 'class_weighting:' for different classes in the softmaxwithloss layer? how do I specify those in my case?

alexgkendall commented 8 years ago

No problem! You should follow the example in segnet.prototxt. You can use the formula in our SegNet paper to compute the values on your dataset.

aseembits93 commented 8 years ago

It's mentioned in the cvpr '08 paper on semantic texton forest, right? how could the weighting be more than 1 as its there in segnet_train.prototext?

ghost commented 8 years ago

Hello, @aseembits93. I believe it's mentioned in this paper (http://arxiv.org/pdf/1511.00561v2.pdf). Please search for "We use median frequency balancing" :-) Hope this helped!

aseembits93 commented 8 years ago

"we weight each pixel by αc = median freq/freq(c) where freq(c) is the number of pixels of class c divided by the total number of pixels in images where c is present, and median freq is the median of these frequencies." .Thanks @dk683 !

krikru commented 7 years ago

Another possibility is to use one-hot class vectors with the dimension 2, corresponding to your two classes. For the don't-care pixels, simply set all the elements in the vector to 0; this will effectively make those pixel have a zero contribution to the loss disregarding the output of the softmax function, i.e. the loss doesn't care what you output for those pixels.

JackieLeeTHU11 commented 7 years ago

@aseembits93 Hello, could please tell me how to realize ''median frequency balancing'' in caffe. I also encounter this problem because of the unbalance classes.