Problem about the final result
NightQing opened this issue · 3 comments
Hi,xtudbxk:
I trained a model by using the training code, and evaluated on https://github.com/xtudbxk/semantic-segmentation-metrics. But finally, I get mIoU=0.471 which is lower than 0.502. In training code, i didn't change any thing, the final model is "norm-77999". In evaluation code, I changed the network
def create_network(self):
if "init_model_path" in self.config:
self.load_init_model()
with tf.name_scope("vgg") as scope:
# build block
block = self.build_block("input",["conv1_1","relu1_1","conv1_2","relu1_2","pool1"])
block = self.build_block(block,["conv2_1","relu2_1","conv2_2","relu2_2","pool2"])
block = self.build_block(block,["conv3_1","relu3_1","conv3_2","relu3_2","conv3_3","relu3_3","pool3"])
block = self.build_block(block,["conv4_1","relu4_1","conv4_2","relu4_2","conv4_3","relu4_3","pool4"])
block = self.build_block(block,["conv5_1","relu5_1","conv5_2","relu5_2","conv5_3","relu5_3","pool5","pool5a"])
fc1 = self.build_fc(block,["fc6_1","relu6_1","drop6_1","fc7_1","relu7_1","drop7_1","fc8_1"], dilate_rate=6)
fc2 = self.build_fc(block,["fc6_2","relu6_2","drop6_2","fc7_2","relu7_2","drop7_2","fc8_2"], dilate_rate=12)
fc3 = self.build_fc(block,["fc6_3","relu6_3","drop6_3","fc7_3","relu7_3","drop7_3","fc8_3"], dilate_rate=18)
fc4 = self.build_fc(block,["fc6_4","relu6_4","drop6_4","fc7_4","relu7_4","drop7_4","fc8_4"], dilate_rate=24)
#self.net["fc8"] = (self.net[fc1]+self.net[fc2]+self.net[fc3]+self.net[fc4])/4.0
self.net["fc8"] = self.net[fc1]+self.net[fc2]+self.net[fc3]+self.net[fc4]
return self.net["fc8"] # note that the output is a log-number
to
def create_network(self):
if "init_model_path" in self.config:
self.load_init_model()
with tf.name_scope("vgg") as scope:
# build block
block = self.build_block("input",["conv1_1","relu1_1","conv1_2","relu1_2","pool1"])
block = self.build_block(block,["conv2_1","relu2_1","conv2_2","relu2_2","pool2"])
block = self.build_block(block,["conv3_1","relu3_1","conv3_2","relu3_2","conv3_3","relu3_3","pool3"])
block = self.build_block(block,["conv4_1","relu4_1","conv4_2","relu4_2","conv4_3","relu4_3","pool4"])
block = self.build_block(block,["conv5_1","relu5_1","conv5_2","relu5_2","conv5_3","relu5_3","pool5","pool5a"])
fc = self.build_fc(block, ["fc6", "relu6", "drop6", "fc7", "relu7", "drop7", "fc8"])
return self.net[fc] # note that the output is a log-number
and I also change build_fc
def build_fc(self,last_layer, layer_lists,dilate_rate):
for layer in layer_lists:
if layer.startswith("fc"):
with tf.name_scope(layer) as scope:
weights,bias = self.get_weights_and_bias(layer)
if layer.startswith("fc6"):
self.net[layer] = tf.nn.atrous_conv2d( self.net[last_layer], weights, rate=dilate_rate, padding="SAME", name="conv")
else:
self.net[layer] = tf.nn.conv2d( self.net[last_layer], weights, strides = [1,1,1,1], padding="SAME", name="conv")
self.net[layer] = tf.nn.bias_add( self.net[layer], bias, name="bias")
last_layer = layer
if layer.startswith("batch_norm"):
with tf.name_scope(layer) as scope:
self.net[layer] = tf.contrib.layers.batch_norm(self.net[last_layer])
last_layer = layer
if layer.startswith("relu"):
with tf.name_scope(layer) as scope:
self.net[layer] = tf.nn.relu( self.net[last_layer])
last_layer = layer
if layer.startswith("drop"):
with tf.name_scope(layer) as scope:
self.net[layer] = tf.nn.dropout( self.net[last_layer],self.net["drop_prob"])
last_layer = layer
return last_layer
to
def build_fc(self, last_layer, layer_lists):
for layer in layer_lists:
if layer.startswith("fc"):
with tf.name_scope(layer) as scope:
weights,bias = self.get_weights_and_bias(layer)
if layer.startswith("fc6"):
self.net[layer] = tf.nn.atrous_conv2d( self.net[last_layer], weights, rate=12, padding="SAME", name="conv")
else:
self.net[layer] = tf.nn.conv2d( self.net[last_layer], weights, strides = [1,1,1,1], padding="SAME", name="conv")
self.net[layer] = tf.nn.bias_add( self.net[layer], bias, name="bias")
last_layer = layer
if layer.startswith("batch_norm"):
with tf.name_scope(layer) as scope:
self.net[layer] = tf.contrib.layers.batch_norm(self.net[last_layer])
last_layer = layer
if layer.startswith("relu"):
with tf.name_scope(layer) as scope:
self.net[layer] = tf.nn.relu( self.net[last_layer])
last_layer = layer
if layer.startswith("drop"):
with tf.name_scope(layer) as scope:
self.net[layer] = tf.nn.dropout( self.net[last_layer],self.net["drop_prob"])
last_layer = layer
return last_layer
Is there angthing wrong? Thank you.
I don't think there is any erros in your code. And since I update the evaluation code, all the miou of my experiment drops a little. And I just test my model using my new evaluation code, the final miou is also about 48%. So I just think there is a little error in my old evaluation code. Sorry to confuse you.
And for improving the the performance, I think the poly learning policy and using tag to clean all the probability of not-existing labels may do help. I just plan to do some more experiment to check my thought in a few days.
One more thing, if you use fixed input_size for testing, you may get a better score.
Thank you. I will also do some try. Waiting for your good news.