Skip to content
Objects counting from density map
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.

Objects counting by estimating a density map with convolutional neural networks

The PyTorch implementation of

More details about the method can be found in our blog post.

Data preparation

Three datasets are considered:

One can get them using script:

Usage: [OPTIONS]

  Get chosen dataset and generate HDF5 files with training and validation samples.

  --dataset [cell|mall|ucsd]  [required]
  --help                      Show this message and exit.

The script download original data and preprocess it to create HDF5 files with images and labels (corresponding density maps).


Two network architectures are available so far:

  • U-Net

    Ronneberger, Olaf, Philipp Fischer, and Thomas Brox. "U-net: Convolutional networks for biomedical image segmentation." In International Conference on Medical image computing and computer-assisted intervention, pp. 234-241. Springer, Cham, 2015.

  • FCRN-A

    Weidi, Xie, J. Alison Noble, and Andrew Zisserman. "Microscopy cell counting with fully convolutional regression networks." In 1st Deep Learning Workshop, Medical Image Computing and Computer-Assisted Intervention (MICCAI). 2015.

One can use script to train chosen network on selected dataset:

Usage: [OPTIONS]

  Train chosen model on selected dataset.

  -d, --dataset_name [cell|mall|ucsd]
                                  Dataset to train model on (expect proper
                                  HDF5 files).  [required]
  -n, --network_architecture [UNet|FCRN_A]
                                  Model to train.  [required]
  -lr, --learning_rate FLOAT      Initial learning rate (lr_scheduler is
  -e, --epochs INTEGER            Number of training epochs.
  --batch_size INTEGER            Batch size for both training and validation
  -hf, --horizontal_flip FLOAT    The probability of horizontal flip for
                                  training dataset.
  -vf, --vertical_flip FLOAT      The probability of horizontal flip for
                                  validation dataset.
  --unet_filters INTEGER          Number of filters for U-Net convolutional
  --convolutions INTEGER          Number of layers in a convolutional block.
  --plot                          Generate a live plot.
  --help                          Show this message and exit.


To install required python packages run: pip3 install -r requirements.txt.

You can’t perform that action at this time.