alexgkendall / caffe-segnet

Implementation of SegNet: A Deep Convolutional Encoder-Decoder Architecture for Semantic Pixel-Wise Labelling
http://mi.eng.cam.ac.uk/projects/segnet/
Other
1.08k stars 452 forks source link

Train image with 4 classes. Predictions only showing two classes #66

Open Darienzhangyy opened 8 years ago

Darienzhangyy commented 8 years ago

I have tried to train on my own data, which only has 4 classes. To be more specific, some images have 3 classes, some have 4 classes.

The training process works fine. I am also able to make predictions and the prediction looks VERY close to the ground truth! However, two of the classes are always missing in prediction. May I ask what may probably cause this? Do I need to modify compute_bn_statistics.py? Thanks~

Here is some modifications in my segnet_ train.prototxt(last few layers): layer { bottom: "conv1_2_D" top: "conv1_1_D" name: "conv1_1_D" type: "Convolution" param { lr_mult: 1 decay_mult: 1 } param { lr_mult: 2 decay_mult: 0 } convolution_param { weight_filler { type: "msra" } bias_filler { type: "constant" } num_output: 4#11 pad: 1 kernel_size: 3 } } layer { name: "loss" type: "SoftmaxWithLoss" bottom: "conv1_1_D" bottom: "label" top: "loss" softmax_param {engine: CAFFE} loss_param: { weight_by_label_freqs: true

ignore_label: 11

class_weighting: 0.25

class_weighting: 0.25

class_weighting: 0.25

class_weighting: 0.25

class_weighting: 0.2595

class_weighting: 0.1826

class_weighting: 4.5640

class_weighting: 0.1417

class_weighting: 0.9051

class_weighting: 0.3826

class_weighting: 9.6446

class_weighting: 1.8418
class_weighting: 0.6823
class_weighting: 6.2478

class_weighting: 7.3614 } }

segnet_inference(last few layers): layer { bottom: "conv1_2_D" top: "conv1_1_D" name: "conv1_1_D" type: "Convolution" param { lr_mult: 1 decay_mult: 1 } param { lr_mult: 2 decay_mult: 0 } convolution_param { weight_filler { type: "msra" } bias_filler { type: "constant" } num_output: 4#11 pad: 1 kernel_size: 3 } }

I have also modified test_segmentation_camvid.py:
CLASS1 = [128,0,0] CLASS2 = [0,128,0] CLASS3 = [0,0,128] background = [0,0,0]

label_colours = np.array([ CLASS1,CLASS2, CLASS3, background])
for l in range(0,4):
    r[ind==l] = label_colours[l,0]
    g[ind==l] = label_colours[l,1]
    b[ind==l] = label_colours[l,2]
    r_gt[label==l] = label_colours[l,0]
    g_gt[label==l] = label_colours[l,1]
    b_gt[label==l] = label_colours[l,2]
tangwudu commented 8 years ago

Hi Darienzhangyy, did you figure out the reason behind this? I was wondering how to compute the weight of different class? Could you enlighten me?

Nirmitee commented 7 years ago

I would like to know how have you assigned class weighting values?

defenceVT commented 7 years ago

@Darienzhangyy hello,how do you annotate your own dataset?

shivamsardana commented 7 years ago

@Darienzhangyy can you please explain class weighting?

Nirmitee commented 7 years ago

Hi, A matlab script can be used to create annotations, such that each class in your image reperesents a particular label. So using a matlab script, try to label every pixel in your image. Eg: if road is one class, then all the pixels belonging to the road class will br labeled as 1. If tree is another class label it as 2. So every class should have a label, so that it can be classified by the system. You will have to write a matlab script for it.

On Aug 2, 2017 4:04 PM, "Shivam Sardana" notifications@github.com wrote:

@Darienzhangyy https://github.com/darienzhangyy can you please explain class weighting?

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/alexgkendall/caffe-segnet/issues/66#issuecomment-319634947, or mute the thread https://github.com/notifications/unsubscribe-auth/AUXv5IU8PL5CoZjQAy_qZVG4p-prEcoiks5sUFC3gaJpZM4JbHqe .

ArunJ1 commented 5 years ago

I really dont know why similar topics of this nature are not being answered