This is a Tensorflow implementation of Fully Convolutional Networks in Tensorflow. The network can be applied directly or finetuned using tensorflow training code.
Deconvolution Layers are initialized as bilinear upsampling. Conv and FCN layer weights using VGG weights. Numpy load is used to read VGG weights. No Caffe or Kaffe-Tensorflow is required to run this. The .npy file for VGG16 however need to be downloaded before using this needwork.
No Pascal VOC finetuning was applied to the weights. The model is meant to be finetuned on your own data. The model can be applied to an image directly (see test_fcn32_vgg.py
) but the result will be rather coarse.
python test_fcn32_vgg.py
to test the implementation.
Use this to build the VGG object for finetuning:
vgg = vgg16.Vgg16()
vgg.build(images, train=True, num_classes=num_classes, random_init_fc8=True)
The images
is a tensor with shape [None, h, w, 3]
. Where h
and w
can have arbitrary size.
Trick: the tensor can be a placeholder, a variable or even a constant.
Be aware, that num_classes
influences the way score_fr
(the original fc8
layer) is initialized. For finetuning I recommend using the option random_init_fc8=True
.
For training use vgg.build(images, train=True, num_classes=num_classes)
were images is q queue yielding image batches. Use a softmax_cross_entropy loss function on top of the output of vgg.up. An Implementation of the loss function can be found in loss.py
.
For example the one provided by TensorVision
Currently the following Models are provided:
- FCN32
Weights were generated using Caffe to Tensorflow. The VGG implementation is based on tensorflow-vgg16 and numpy loading is based on tensorflow-vgg. You do not need any of the above cited code to run the model, not do you need caffe.
Provide finetuned FCN weights.