Fully Convolutional DenseNets for semantic segmentation.
The developer of this repository has not created any items for sale yet. Need a bug fixed? Help with integration? A different license? Create a request here:
This repo contains the code to train and evaluate FC-DenseNets as described in The One Hundred Layers Tiramisu: Fully Convolutional DenseNets for Semantic Segmentation. We investigate the use of Densely Connected Convolutional Networks for semantic segmentation, and report state of the art results on datasets such as CamVid.
The data loader is now available here : https://github.com/fvisin/dataset_loaders Thanks a lot to Francesco Visin, please cite if you use his data loader. Some adaptations may be do on the actual code, I hope to find some time to modify it !
The data-loader we used for the experiments will be released later. If you do want to train models now, you need to create a function loaddata which returns 3 iterators (for training, validation and test). When applying next(), the iterator returns two values X, Y where X is the batch of input images (shape= (batchsize, 3, nrows, ncols), dtype=float32) and Y the batch of target segmentation maps (shape=(batchsize, nrows, n_cols), dtype=int32) where each pixel in Y is an int indicating the class of the pixel.
The iterator must also have the following methods (so they are not python iterators) : getnclasses (returns the number of classes), getnsamples (returns the number of examples in the set), getnbatches (returns the number of batches necessary to see the entire set) and getvoidlabels (returns a list containing the classes associated to void). It might be easier to change directly the files train.py and test.py.
The architecture of the model is defined in FC-DenseNet.py. To train a model, you need to prepare a configuration file (folder config) where all the parameters needed for creating and training your model are precised. DenseNets contain lot of connections making graph optimization difficult for Theano. We strongly recommend to use the flags described further.
To train the FC-DenseNet103 model, use the command :
THEANO_FLAGS='device=cuda,optimizer=fast_compile,optimizer_including=fusion' python train.py -c config/FC-DenseNet103.py -e experiment_name. All the logs of the experiments are stored in the folder experiment_name.
On a Titan X 12GB, for the model FC-DenseNet103 (see folder config), compilation takes around 400 sec and 1 epoch 120 sec for training and 40 sec for validation.
We publish the weights of our model FC-DenseNet103. Metrics claimed in the paper (jaccard and accuracy) can be verified running
THEANO_FLAGS='device=cuda,optimizer=fast_compile,optimizer_including=fusion' python test.py
There is a small error with the "m" number in the Table 2 of the paper (that you may understand when running the code!). All values from the bottleneck to the last block (880, 1072, 800 and 368) should be incremented by 16 (896, 1088, 816 and 384).
Here how we compute this value representing the number of feature maps concatenated into the "stack" : - First convolution : m=48 - In the downsampling part + bottleneck, m[B] = m[B-1] + nlayers[B] * growthrate [linear growth]. First block : m = 48 + 4x16 = 112. Second block m = 112 + 5x16 = 192. Until the bottleneck : m = 656 + 15x16 = 896. - In the upsampling part, m[B] is the sum of 3 terms : the m value corresponding to same resolution in the downsampling part (skip connection), the number of feature maps from the upsampled block (nlayers[B-1] * growthrate) and the number of feature maps in the new block (nlayers[B] * growthrate). First upsampling, m = 656 + 15x16 + 12x16 = 1088. Second upsampling, m = 464 + 12x16 + 10x16 = 816. Third upsampling, m = 304 + 10x16 + 7x16 = 576, Fourth upsampling, m = 192 + 7x16 + 5x16 = 384 and fifth upsampling, m = 112 + 5x16 + 4x16 = 256