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

Overview

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.

Comments
  • addition of a extra vector

    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).

    opened by GlastonburyC 10
  • How to deal with varying object scale?

    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?

    opened by mrgloom 6
  • How to escape all zeros prediction?

    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) https://github.com/ZFTurbo/ZF_UNET_224_Pretrained_Model/issues/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. https://github.com/WeidiXie/cell_counting_v2/blob/d37bf7048120faf958a51930bfe9e558206faaa0/train.py#L53

    opened by mrgloom 2
  • How many cells are on picture

    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 ??

    opened by AlexunderMicrocontrol 2
  • Why we take the absolute of the predictions.

    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

    opened by sagarkar10 1
  • Not working in Tensorflow 1.2.1?

    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.
    
    opened by ieee8023 1
  • Why activation of last layer is linear?

    Why activation of last layer is linear?

    Why activation of last layer is linear? i.e. is it normal that model can produce negative density map? https://github.com/WeidiXie/cell_counting_v2/blob/master/model.py#L169

    opened by mrgloom 1
  • buildModel_U_net and U_net_base gives error

    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?

    opened by nihattolga 0
  • Upgrading to most recent libraries

    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.

    opened by gatordevin 0
  • I want to visualise the data augmentation and what my model is actually getting feed

    I want to visualise the data augmentation and what my model is actually getting feed

    Please help me out how to dump the data from datagen.flow(). I have used the save to dir option and still, the images don't make sense visually, what normalization is still getting applied after I manually switch off all the init params to ImagedataGenerator

    opened by sagarkar10 0
  • How to get cell numbers in a single image?

    How to get cell numbers in a single image?

    https://github.com/WeidiXie/cell_counting_v2/blob/d37bf7048120faf958a51930bfe9e558206faaa0/train.py#L112

    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

    opened by AbidHussain70 0
Owner
Weidi
Machine Learning, Computer Vision, Biomedical Image Analysis.
Weidi
LWCC: A LightWeight Crowd Counting library for Python that includes several pretrained state-of-the-art models.

LWCC: A LightWeight Crowd Counting library for Python LWCC is a lightweight crowd counting framework for Python. It wraps four state-of-the-art models

Matija Teršek 39 Dec 28, 2022
This is the code for our KILT leaderboard submission to the T-REx and zsRE tasks. It includes code for training a DPR model then continuing training with RAG.

KGI (Knowledge Graph Induction) for slot filling This is the code for our KILT leaderboard submission to the T-REx and zsRE tasks. It includes code fo

International Business Machines 72 Jan 6, 2023
This is an implementation of Googles Yogi-Optimizer in Keras (tf.keras)

Yogi-Optimizer_Keras This is an implementation of Googles Yogi-Optimizer in Keras (tf.keras) The NeurIPS-Paper can be found here: http://papers.nips.c

null 14 Sep 13, 2022
Keras udrl - Keras implementation of Upside Down Reinforcement Learning

keras_udrl Keras implementation of Upside Down Reinforcement Learning This is me

Eder Santana 7 Jan 24, 2022
Example-custom-ml-block-keras - Custom Keras ML block example for Edge Impulse

Custom Keras ML block example for Edge Impulse This repository is an example on

Edge Impulse 8 Nov 2, 2022
Classification models 1D Zoo - Keras and TF.Keras

Classification models 1D Zoo - Keras and TF.Keras This repository contains 1D variants of popular CNN models for classification like ResNets, DenseNet

Roman Solovyev 12 Jan 6, 2023
Softlearning is a reinforcement learning framework for training maximum entropy policies in continuous domains. Includes the official implementation of the Soft Actor-Critic algorithm.

Softlearning Softlearning is a deep reinforcement learning toolbox for training maximum entropy policies in continuous domains. The implementation is

Robotic AI & Learning Lab Berkeley 997 Dec 30, 2022
Official Implement of CVPR 2021 paper “Cross-Modal Collaborative Representation Learning and a Large-Scale RGBT Benchmark for Crowd Counting”

RGBT Crowd Counting Lingbo Liu, Jiaqi Chen, Hefeng Wu, Guanbin Li, Chenglong Li, Liang Lin. "Cross-Modal Collaborative Representation Learning and a L

null 37 Dec 8, 2022
Weighing Counts: Sequential Crowd Counting by Reinforcement Learning

LibraNet This repository includes the official implementation of LibraNet for crowd counting, presented in our paper: Weighing Counts: Sequential Crow

Hao Lu 18 Nov 5, 2022
Official PyTorch implementation of the paper: Improving Graph Neural Network Expressivity via Subgraph Isomorphism Counting.

Improving Graph Neural Network Expressivity via Subgraph Isomorphism Counting Official PyTorch implementation of the paper: Improving Graph Neural Net

Giorgos Bouritsas 58 Dec 31, 2022
Variational Attention: Propagating Domain-Specific Knowledge for Multi-Domain Learning in Crowd Counting (ICCV, 2021)

DKPNet ICCV 2021 Variational Attention: Propagating Domain-Specific Knowledge for Multi-Domain Learning in Crowd Counting Baseline of DKPNet is availa

null 19 Oct 14, 2022
Vehicles Counting using YOLOv4 + DeepSORT + Flask + Ngrok

A project for counting vehicles using YOLOv4 + DeepSORT + Flask + Ngrok

Duong Tran Thanh 37 Dec 16, 2022
Real time Human Detection Counting

In this python project, we are going to build the Human Detection and Counting System through Webcam or you can give your own video or images. This is a deep learning project on computer vision, which will help you to master the concepts and make you an expert in the field of Data Science. Let’s build an exciting project.

Mir Nawaz Ahmad 2 Jun 17, 2022
A model that attempts to learn and benefit from data collected on card counting.

A model that attempts to learn and benefit from data collected on card counting. A decision tree like model is built to win more often than loose and increase the bet of the player appropriately to come out winning as much money as possible.

null 1 Dec 17, 2021
Various operations like path tracking, counting, etc by using yolov5

Object-tracing-with-YOLOv5 Various operations like path tracking, counting, etc by using yolov5

Pawan Valluri 5 Nov 28, 2022
DCSL - Generalizable Crowd Counting via Diverse Context Style Learning

DCSL Generalizable Crowd Counting via Diverse Context Style Learning Requirement

null 3 Jun 13, 2022
PyTorch implementations of the paper: "DR.VIC: Decomposition and Reasoning for Video Individual Counting, CVPR, 2022"

DRNet for Video Indvidual Counting (CVPR 2022) Introduction This is the official PyTorch implementation of paper: DR.VIC: Decomposition and Reasoning

tao han 35 Nov 22, 2022
Home repository for the Regularized Greedy Forest (RGF) library. It includes original implementation from the paper and multithreaded one written in C++, along with various language-specific wrappers.

Regularized Greedy Forest Regularized Greedy Forest (RGF) is a tree ensemble machine learning method described in this paper. RGF can deliver better r

RGF-team 364 Dec 28, 2022
Build tensorflow keras model pipelines in a single line of code. Created by Ram Seshadri. Collaborators welcome. Permission granted upon request.

deep_autoviml Build keras pipelines and models in a single line of code! Table of Contents Motivation How it works Technology Install Usage API Image

AutoViz and Auto_ViML 102 Dec 17, 2022