Fully Connected DenseNet for Image Segmentation

Overview

Fully Connected DenseNets for Semantic Segmentation

Fully Connected DenseNet for Image Segmentation implementation of the paper The One Hundred Layers Tiramisu : Fully Convolutional DenseNets for Semantic Segmentation

Differences

  • Use of SubPixelConvolution instead of Deconvolution as default method for Upsampling.

Usage :

Simply import the densenet_fc.py script and call the create method:

import densenet_fc as dc

model = DenseNetFCN((32, 32, 3), nb_dense_block=5, growth_rate=16,
                        nb_layers_per_block=4, upsampling_type='upsampling', classes=1)

Requirements

Keras 1.2.2 Theano (master branch) / Tensorflow 1.0+ h5py

Comments
  • keras-contrib pull request

    keras-contrib pull request

    Once #7 is committed and verified to work with theano, I'm hoping to look at extending your keras-contrib densenet.py submission to support densenet-fcn as well.

    Would that be okay with you?

    I'll plan to also include a conversion script for pascal_voc.

    opened by ahundt 6
  • TF bug

    TF bug

    I tried training this in TF and ran into the following bug:

    
    I tensorflow/core/common_runtime/gpu/gpu_device.cc:975] Creating TensorFlow device (/gpu:0) -> (device: 0, name: GeForce GTX 1080, pci bus id: 0000:02:00.0)
    Running with tf training, initializing batches...
    creating densenet model
    Traceback (most recent call last):
      File "densenet_fcn.py", line 134, in <module>
        model = get_model(image_train_size=image_train_size,model_type=model_type,tensor=image_batch)
      File "densenet_fcn.py", line 50, in get_model
        model = densenet_fc.create_fc_dense_net(number_of_classes,image_train_size)
      File "/home/ahundt/src/tf-image-segmentation/tf_image_segmentation/models/densenet_fcn/densenet_fc.py", line 260, in create_fc_dense_net
        x = transition_up_block(x, nb_filters=upsampling_conv, type=upscaling_type, output_shape=out_shape)
      File "/home/ahundt/src/tf-image-segmentation/tf_image_segmentation/models/densenet_fcn/densenet_fc.py", line 97, in transition_up_block
        x = SubPixelUpscaling(r=2, channels=int(nb_filters // 4))(x)
      File "/usr/local/lib/python2.7/dist-packages/Keras-1.2.2-py2.7.egg/keras/engine/topology.py", line 572, in __call__
        self.add_inbound_node(inbound_layers, node_indices, tensor_indices)
      File "/usr/local/lib/python2.7/dist-packages/Keras-1.2.2-py2.7.egg/keras/engine/topology.py", line 635, in add_inbound_node
        Node.create_node(self, inbound_layers, node_indices, tensor_indices)
      File "/usr/local/lib/python2.7/dist-packages/Keras-1.2.2-py2.7.egg/keras/engine/topology.py", line 166, in create_node
        output_tensors = to_list(outbound_layer.call(input_tensors[0], mask=input_masks[0]))
      File "/home/ahundt/src/tf-image-segmentation/tf_image_segmentation/models/densenet_fcn/layers.py", line 70, in call
        y = depth_to_scale_tf(x, self.r, self.channels)
      File "/home/ahundt/src/tf-image-segmentation/tf_image_segmentation/models/densenet_fcn/layers.py", line 48, in depth_to_scale_tf
        Xc = tf.split(3, channels, input)
      File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/ops/array_ops.py", line 1216, in split
        split_dim=axis, num_split=num_or_size_splits, value=value, name=name)
      File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/ops/gen_array_ops.py", line 3426, in _split
        num_split=num_split, name=name)
      File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/framework/op_def_library.py", line 509, in apply_op
        (prefix, dtypes.as_dtype(input_arg.type).name))
    TypeError: Input 'split_dim' of 'Split' Op has type float32 that does not match expected type of int32.
    

    The code successfully trains for a while on pascal-voc with a simpler U-net: https://github.com/ahundt/tf-image-segmentation/blob/ahundt-keras/tf_image_segmentation/recipes/pascal_voc/FCNs/densenet_fcn.py

    opened by ahundt 6
  • Deprecated function call warnings with Keras 2.x.x

    Deprecated function call warnings with Keras 2.x.x

    When using newer versions of Keras, the DenseNet implementation here raises some warnings due to deprecation of some of the Keras calls used. It still works for now, but the Keras wraning states, that from 08/2017, it won't.

    opened by martinsand 3
  • NameError: name 'DenseNetFCN' is not defined

    NameError: name 'DenseNetFCN' is not defined

    I get the following code when I try to run the script.

    `NameError Traceback (most recent call last) in () 1 import densenet_fc as dc 2 ----> 3 model = DenseNetFCN((64, 64, 3), nb_dense_block=5, growth_rate=16, 4 nb_layers_per_block=4, upsampling_type='upsampling', classes=1)

    NameError: name 'DenseNetFCN' is not defined`

    opened by MinuteswithMetrics 2
  • ValueError: Wrong dimensions

    ValueError: Wrong dimensions

    My stack: keras 1.2.2 + tensorflow on python 3.6; keras.json configured correctly to dim_ordering='tf'

    The issue is, I get:

    ValueError Traceback (most recent call last) in () ----> 1 dn.fit(x=mini_trn, y=y_trn, batch_size=32, validation_data=[mini_val, y_val])

    /home/zwerg/anaconda3/lib/python3.6/site-packages/keras/engine/training.py in fit(self, x, y, batch_size, nb_epoch, verbose, callbacks, validation_split, validation_data, shuffle, class_weight, sample_weight, initial_epoch) 1114 class_weight=class_weight, 1115 check_batch_axis=False, -> 1116 batch_size=batch_size) 1117 # prepare validation data 1118 if validation_data:

    /home/zwerg/anaconda3/lib/python3.6/site-packages/keras/engine/training.py in _standardize_user_data(self, x, y, sample_weight, class_weight, check_batch_axis, batch_size) 1031 output_shapes, 1032 check_batch_axis=False, -> 1033 exception_prefix='model target') 1034 sample_weights = standardize_sample_weights(sample_weight, 1035 self.output_names)

    /home/zwerg/anaconda3/lib/python3.6/site-packages/keras/engine/training.py in standardize_input_data(data, names, shapes, check_batch_axis, exception_prefix) 110 ' to have ' + str(len(shapes[i])) + 111 ' dimensions, but got array with shape ' + --> 112 str(array.shape)) 113 for j, (dim, ref_dim) in enumerate(zip(array.shape, shapes[i])): 114 if not j and not check_batch_axis:

    ValueError: Error when checking model target: expected merge_384 to have 4 dimensions, but got array with shape (432, 8)

    I created a dense net using dn = DenseNetFCN(IMAGE_SIZE+(3,), classes=NUM_CLASSES, include_top=False, input_tensor=Input(IMAGE_SIZE+(3,))) with IMAGE_SIZE = (224,224)

    The image tensor shape is 432, 224, 224, 3

    The merge layer 384 in question is configured like: m384 = dn.get_layer('merge_384').get_config() {'arguments': {}, 'concat_axis': -1, 'dot_axes': -1, 'mode': 'concat', 'mode_type': 'raw', 'name': 'merge_384', 'output_mask': None, 'output_mask_type': 'raw', 'output_shape': None, 'output_shape_type': 'raw'}

    Have you got any pointers as to why I might be getting this? I suspect some issue with the backend, but keras is configured correctly to tensorflow.

    opened by iNLyze 2
  • Data and/or example?

    Data and/or example?

    Do you have any dataset and/or working example to use the given model? I am trying to use this on the CamVid dataset used in the original paper, without success..

    opened by Timonzimm 2
  • Average Pooling should be Max Pooling?

    Average Pooling should be Max Pooling?

    It looks like the transition_down_block uses AveragePooling2D when it should be using MaxPooling2D as specified in the paper 3.3. Semantic Segmentation Architecture.

    https://github.com/titu1994/Fully-Connected-DenseNets-Semantic-Segmentation/blob/master/densenet_fc.py#L75

    Though perhaps that's worth making configurable with a flag.

    opened by ahundt 1
  • Minor bug when using tensorflow backend

    Minor bug when using tensorflow backend

    depth_to_scale_tf function does not concatenate channels appropriately. Line 48 at layers.py: Xc = tf.split(3, 3, input) should be replaced by: Xc = tf.split(3, channels, input)

    opened by samtzai 1
  • densenet_fc.py tf support added

    densenet_fc.py tf support added

    add tf support and configure the model so it can actually be used for semantic segmentation upstream: https://github.com/ahundt/tf-image-segmentation/tree/ahundt-keras/tf_image_segmentation/models/densenet_fcn

    densenet_fcn.py is the pascal_voc training script (tf only).

    opened by ahundt 0
  • Model error in initialization

    Model error in initialization

    I run the code as is given in the read me (import and just define the model). But it gives dimension error, saying input dimension should be at least 32x32. I reversed the input order from 32,32,1 to 1,32,32 This error removed but following error occurred: ValueError: "concat" mode can only merge layers with matching output shapes except for the concat axis. Layer shapes: [(None, 64, 2, 2), (None, 368, 3, 3)]

    What may be the problem? Could you help?

    opened by pronot 1
Owner
Somshubra Majumdar
Interested in Machine Learning, Deep Learning and Data Science in general
Somshubra Majumdar
A PyTorch implementation of DenseNet.

A PyTorch Implementation of DenseNet This is a PyTorch implementation of the DenseNet-BC architecture as described in the paper Densely Connected Conv

Brandon Amos 771 Dec 15, 2022
DenseNet Implementation in Keras with ImageNet Pretrained Models

DenseNet-Keras with ImageNet Pretrained Models This is an Keras implementation of DenseNet with ImageNet pretrained weights. The weights are converted

Felix Yu 568 Oct 31, 2022
(IEEE TIP 2021) Regularized Densely-connected Pyramid Network for Salient Instance Segmentation

RDPNet IEEE TIP 2021: Regularized Densely-connected Pyramid Network for Salient Instance Segmentation PyTorch training and testing code are available.

Yu-Huan Wu 41 Oct 21, 2022
A PyTorch implementation for V-Net: Fully Convolutional Neural Networks for Volumetric Medical Image Segmentation

A PyTorch implementation of V-Net Vnet is a PyTorch implementation of the paper V-Net: Fully Convolutional Neural Networks for Volumetric Medical Imag

Matthew Macy 606 Dec 21, 2022
EDCNN: Edge enhancement-based Densely Connected Network with Compound Loss for Low-Dose CT Denoising

EDCNN: Edge enhancement-based Densely Connected Network with Compound Loss for Low-Dose CT Denoising By Tengfei Liang, Yi Jin, Yidong Li, Tao Wang. Th

workingcoder 115 Jan 5, 2023
PyTorch implementation of Densely Connected Time Delay Neural Network

Densely Connected Time Delay Neural Network PyTorch implementation of Densely Connected Time Delay Neural Network (D-TDNN) in our paper "Densely Conne

Ya-Qi Yu 64 Oct 11, 2022
Densely Connected Search Space for More Flexible Neural Architecture Search (CVPR2020)

DenseNAS The code of the CVPR2020 paper Densely Connected Search Space for More Flexible Neural Architecture Search. Neural architecture search (NAS)

Jamin Fong 291 Nov 18, 2022
BMW TechOffice MUNICH 148 Dec 21, 2022
Dewarping Document Image By Displacement Flow Estimation with Fully Convolutional Network.

Dewarping Document Image By Displacement Flow Estimation with Fully Convolutional Network

null 111 Dec 27, 2022
FPGA: Fast Patch-Free Global Learning Framework for Fully End-to-End Hyperspectral Image Classification

FPGA & FreeNet Fast Patch-Free Global Learning Framework for Fully End-to-End Hyperspectral Image Classification by Zhuo Zheng, Yanfei Zhong, Ailong M

Zhuo Zheng 92 Jan 3, 2023
Dewarping Document Image By Displacement Flow Estimation with Fully Convolutional Network

Dewarping Document Image By Displacement Flow Estimation with Fully Convolutional Network

null 39 Aug 2, 2021
Segmentation in Style: Unsupervised Semantic Image Segmentation with Stylegan and CLIP

Segmentation in Style: Unsupervised Semantic Image Segmentation with Stylegan and CLIP Abstract: We introduce a method that allows to automatically se

Daniil Pakhomov 134 Dec 19, 2022
Multi-atlas segmentation (MAS) is a promising framework for medical image segmentation

Multi-atlas segmentation (MAS) is a promising framework for medical image segmentation. Generally, MAS methods register multiple atlases, i.e., medical images with corresponding labels, to a target image;

NanYoMy 13 Oct 9, 2022
Copy Paste positive polyp using poisson image blending for medical image segmentation

Copy Paste positive polyp using poisson image blending for medical image segmentation According poisson image blending I've completely used it for bio

Phạm Vũ Hùng 2 Oct 19, 2021
U-Net Implementation: Convolutional Networks for Biomedical Image Segmentation" using the Carvana Image Masking Dataset in PyTorch

U-Net Implementation By Christopher Ley This is my interpretation and implementation of the famous paper "U-Net: Convolutional Networks for Biomedical

Christopher Ley 1 Jan 6, 2022
Build fully-functioning computer vision models with PyTorch

Detecto is a Python package that allows you to build fully-functioning computer vision and object detection models with just 5 lines of code. Inferenc

Alan Bi 576 Dec 29, 2022
End-to-End Object Detection with Fully Convolutional Network

This project provides an implementation for "End-to-End Object Detection with Fully Convolutional Network" on PyTorch.

null 472 Dec 22, 2022
Code for How To Create A Fully Automated AI Based Trading System With Python

AI Based Trading System This code works as a boilerplate for an AI based trading system with yfinance as data source and RobinHood or Alpaca as broker

Rubén 196 Jan 5, 2023
ICLR21 Tent: Fully Test-Time Adaptation by Entropy Minimization

⛺️ Tent: Fully Test-Time Adaptation by Entropy Minimization This is the official project repository for Tent: Fully-Test Time Adaptation by Entropy Mi

Dequan Wang 204 Dec 25, 2022