Giter Site home page Giter Site logo

cell_counting_v2's Introduction

cell_counting_v2

The repository includes the code for training cell counting applications. (Keras + Tensorflow)

Dataset can be downloaded here : http://www.robots.ox.ac.uk/~vgg/research/counting/index_org.html

Related Papers:

[1] Microscopy Cell Counting with Fully Convolutional Regression Networks.

http://www.robots.ox.ac.uk/~vgg/publications/2015/Xie15/weidi15.pdf

[2] U-Net: Convolutional Networks for Biomedical Image Segmentation.

https://arxiv.org/abs/1505.04597

To make the training easier, I added Batch Normalization to all architectures (FCRN-A and U-Net simple version).

Though still contains tiny difference with the original Matconvnet implementation, for instance, upsampling in Keras is implemented by repeating elements, instead of bilinear upsampling. So, to mimic the bilinear upsampling, I did upsampling + convolution. Also, more data augmentation needs to be added. Nevertheless. I'm able to get similar results as reported in the paper.

In all architectures, they follow the fully convolutional idea, each architecture consists of a down-sampling path, followed by an up-sampling path. During the first several layers, the structure resembles the cannonical classification CNN, as convolution, ReLU, and max pooling are repeatedly applied to the input image and feature maps. In the second half of the architecture, spatial resolution is recovered by performing up-sampling, convolution, eventually mapping the intermediate feature representation back to the original resolution.

In the U-net version, low-level feature representations are fused during upsampling, aiming to compensate the information loss due to max pooling. Here, I only gave a very simple example here (64 kernels for all layers), not tuned for any dataset.

As people know, Deep Learning is developing extremely fast today, both papers were published two years ago, which is quite "old". If people are interested in cell counting, feel free to edit on this.

cell_counting_v2's People

Contributors

weidixie avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

cell_counting_v2's Issues

How to escape all zeros prediction?

How to escape all zero prediction?

I use 128x128 input and seems network converges to all zeros prediction.

Here I have similar issue for semantic segmentation task, but it arises only for larger image size(512x512)
ZFTurbo/ZF_UNET_224_Pretrained_Model#10

Also I see some multiplier 100.0 in our code, is it crucial to network convergence? Also after applying gaussian smoothing max value will lower about 16.

img2 = 100.0 * (img2_[:,:,0] > 0)

How to deal with varying object scale?

klhad

Any ideas how to deal with varying object scale? Putting gaussian with fixed sigma in not very good solution when scale of object is different across image?

Not working in Tensorflow 1.2.1?

Should I fix my system or fix the code?

$ python train.py
Using TensorFlow backend.
------------------------------
Creating and compiling the fully convolutional regression networks.
------------------------------
Traceback (most recent call last):
  File "train.py", line 116, in <module>
    train_(base_path)
  File "train.py", line 77, in train_
    model = buildModel_U_net(input_dim = (256,256,3))
  File "/data/lisa/exp/cohenjos/workspace/cell_counting_v2/model.py", line 167, in buildModel_U_net
    act_ = U_net_base (input_, nb_filter = 64 )
  File "/data/lisa/exp/cohenjos/workspace/cell_counting_v2/model.py", line 127, in U_net_base
    up4 = merge([UpSampling2D(size=(2, 2))(block4), block3], mode='concat', concat_axis=-1)
  File "/u/cohenjos/.local/lib/python2.7/site-packages/keras/engine/topology.py", line 1680, in merge
    name=name)
  File "/u/cohenjos/.local/lib/python2.7/site-packages/keras/engine/topology.py", line 1301, in __init__
    self.add_inbound_node(layers, node_indices, tensor_indices)
  File "/u/cohenjos/.local/lib/python2.7/site-packages/keras/engine/topology.py", line 635, in add_inbound_n
ode
    Node.create_node(self, inbound_layers, node_indices, tensor_indices)
  File "/u/cohenjos/.local/lib/python2.7/site-packages/keras/engine/topology.py", line 172, in create_node
    output_tensors = to_list(outbound_layer.call(input_tensors, mask=input_masks))
  File "/u/cohenjos/.local/lib/python2.7/site-packages/keras/engine/topology.py", line 1394, in call
    return K.concatenate(inputs, axis=self.concat_axis)
  File "/u/cohenjos/.local/lib/python2.7/site-packages/keras/backend/tensorflow_backend.py", line 1427, in c
oncatenate
    return tf.concat(axis, [to_dense(x) for x in tensors])
  File "/u/cohenjos/.local/lib/python2.7/site-packages/tensorflow/python/ops/array_ops.py", line 1043, in co
ncat
    dtype=dtypes.int32).get_shape(
  File "/u/cohenjos/.local/lib/python2.7/site-packages/tensorflow/python/framework/ops.py", line 676, in con
vert_to_tensor
    as_ref=False)
  File "/u/cohenjos/.local/lib/python2.7/site-packages/tensorflow/python/framework/ops.py", line 741, in int
ernal_convert_to_tensor
    ret = conversion_func(value, dtype=dtype, name=name, as_ref=as_ref)
  File "/u/cohenjos/.local/lib/python2.7/site-packages/tensorflow/python/framework/constant_op.py", line 113
, in _constant_tensor_conversion_function
    return constant(v, dtype=dtype, name=name)
  File "/u/cohenjos/.local/lib/python2.7/site-packages/tensorflow/python/framework/constant_op.py", line 102
, in constant
    tensor_util.make_tensor_proto(value, dtype=dtype, shape=shape, verify_shape=verify_shape))
  File "/u/cohenjos/.local/lib/python2.7/site-packages/tensorflow/python/framework/tensor_util.py", line 374
, in make_tensor_proto
    _AssertCompatible(values, dtype)
  File "/u/cohenjos/.local/lib/python2.7/site-packages/tensorflow/python/framework/tensor_util.py", line 302
, in _AssertCompatible
    (dtype.name, repr(mismatch), type(mismatch).__name__))
TypeError: Expected int32, got list containing Tensors of type '_Message' instead.

Why we take the absolute of the predictions.

Not an Issue, but a request to explain.
Please explain the generation of negative numbers in the prediction. Ideally, should it not be all between 0-100. I understand during optimizing the negative numbers can come. I would appreciate if you can also explain the idea of summing up the absolute (#3 ) of the prediction and not only the positive numbers.
Excuse me if that was very trivial.
@WeidiXie

How to get cell numbers in a single image?

mean_diff = np.average(np.abs(np.sum(np.sum(A,1),1)-np.sum(np.sum(val_anno,1),1))) / (100.0)

Above line in your code take average of validation images and validation density map images.
How to get number of cells in a single image.

Also I tried single image test by replacing validation images with single image and a single density map of that image, but I got a difference of 154 cells.
Can you please tell me how to verify the code with single image, please.
Thanks

addition of a extra vector

Hi I would like to modify any one of the counting networks to have an additional vector input and therefore an additional output (MSE loss would be fine).

I think the network may learn several cell characteristics so I would like to try learning the diameter of the cells as well. Whats the implementation I should try? I was thinking adding a merge layer after u_net and then a dense layer(1).

buildModel_U_net and U_net_base gives error

U_net_base gives merge error, i tried change merge to concatenate

def U_net_base(input, nb_filter = 64):
block1 = _conv_bn_relu_x2(nb_filter,3,3)(input)
pool1 = MaxPooling2D(pool_size=(2,2))(block1)
block2 = _conv_bn_relu_x2(nb_filter,3,3)(pool1)
pool2 = MaxPooling2D(pool_size=(2, 2))(block2)
block3 = _conv_bn_relu_x2(nb_filter,3,3)(pool2)
pool3 = MaxPooling2D(pool_size=(2, 2))(block3)
block4 = _conv_bn_relu_x2(nb_filter,3,3)(pool3)
up4 = concatenate([UpSampling2D(size=(2, 2))(block4), block3])
block5 = _conv_bn_relu_x2(nb_filter,3,3)(up4)
up5 = concatenate([UpSampling2D(size=(2, 2))(block5), block2])
block6 = _conv_bn_relu_x2(nb_filter,3,3)(up5)
up6 = concatenate([UpSampling2D(size=(2, 2))(block6), block1])
block7 = conv_bn_relu(nb_filter,3,3)(up6)
return block7
now; model = Model(input = input
, output = density_pred) gives that error:

node = layer._inbound_nodes[node_index]
AttributeError: 'NoneType' object has no attribute '_inbound_nodes'

How can i fix that?

How many cells are on picture

Hi Weidi it's not really an issue. Your code works fine but you are meassure the difference. Is there way to get the number of cells are on picture ??

Upgrading to most recent libraries

Hi I am rather new to tensorflow and keras and I just got your code working after figuring out which versions you were using after a lot of trial and error. I was wondering if you were planning on upgrading your code to use the most recent packages and if not would you be able to help me through the process.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.