MarvinTeichmann / KittiSeg

A Kitti Road Segmentation model implemented in tensorflow.
MIT License
910 stars 404 forks source link

removing non compatible operations for tf lite conversion #171

Open StuvX opened 6 years ago

StuvX commented 6 years ago

I'm trying to covert my saved model to tf lite, but seem to run into issues with tf.split - can anybody explain why we need to split and reverse the image channels at the beginning of the network from RGB to BGR (under submodules/tensorflow-fcn/vgg8_fcn.py, lines 59 to 67)?

The code is as follows:

        red, green, blue = tf.split(rgb, 3, 3)
        # assert red.get_shape().as_list()[1:] == [224, 224, 1]
        # assert green.get_shape().as_list()[1:] == [224, 224, 1]
        # assert blue.get_shape().as_list()[1:] == [224, 224, 1]
        bgr = tf.concat([
            blue - VGG_MEAN[0],
            green - VGG_MEAN[1],
            red - VGG_MEAN[2],
        ], 3)

If I can simply remove the split operation and subtract the VGG mean using a matrix operation it will save me some headaches (apart from having to retrain my model).

zhanghanbin3159 commented 6 years ago

172 I meet the similarity problem

StuvX commented 6 years ago

Ok - the channel reversal is becuase the weights are loaded from the caffe model, but i took it out and my network learned as well as if it was reversed. However, the transpose function needed for FCN is not supported byTFlite