This is an implemention of our paper "Automated pig counting using deep learning" (https://www.sciencedirect.com/science/article/pii/S0168169918313176). Our code is based on gramuah's code CCNN. Many thanks to Daniel Oñoro-Rubio and Roberto J. López-Sastre for their codes.
Based on this code, it is improved to make it more suitable for pig counts. We have provided the test code, you can test it directly, and all the code will be published after the article is accepted.
@inproceedings{onoro2016,
Author = {O\~noro-Rubio, D. and L\'opez-Sastre, R.~J.},
Title = {Towards perspective-free object counting with deep learning},
Booktitle = {ECCV},
Year = {2016}
}
@article{TIAN2019104840,
author = "Mengxiao Tian and Hao Guo and Hong Chen and Qing Wang and Chengjiang Long and Yuhao Ma",
title = "Automated pig counting using deep learning",
journal = "Computers and Electronics in Agriculture",
year = "2019",
The license information of this project is described in the file "LICENSE.txt".
- Requirements: software
- Requirements: hardware
- Basic installation
- Demo
- How to reproduce the results of the paper
- Remarks
- Acknowledgements
-
Use a Linux distribution. We have developed and tested the code on Ubuntu.
-
Requirements for
Caffe
andpycaffe
. Follow the Caffe installation instructions.
Note: Caffe must be built with support for Python layers!
# In your Makefile.config, make sure to have this line uncommented
WITH_PYTHON_LAYER := 1
- Python packages you need:
cython
,python-opencv
,python-h5py
,easydict
,pillow (version >= 3.4.2)
.
This code allows the usage of CPU and GPU, but we strongly recommend the usage of GPU.
-
For training, we recommend using a GPU with at least 3GB of memory.
-
For testing, a GPU with 2GB of memory is enough.
-
Be sure you have added to your
PATH
thetools
directory of yourCaffe
installation:export PATH=<your_caffe_root_path>/build/tools:$PATH
-
Be sure you have added your
pycaffe
compilation into yourPYTHONPATH
:export PYTHONPATH=<your_caffe_root_path>/python:$PYTHONPATH
We here provide a demo about predicting the number of pigs in the test images of the Pigs dataset.
To run the demo, these are the steps to follow:
-
Download the our pretrained model.
./our_scale/ccnn_trancos_iter.caffemodel
-
Finally, to run the demo, simply execute the following command:
./tools/demo.sh
We provide here the scripts needed to train and test the models with the pigs dataset. These are the steps to follow.
- [Pigs dataset] (https://pan.baidu.com/s/1-iCOU19XewCAKW2TOSiDVw): Extraction code:udei
When the paper is accepted, we can open source data. Put the downloaded train data in counting-pigs/genfiles/features/train, and put the validation data in counting-pigs/genfiles/features/validation.
All our pre-trained models can be downloaded using the corresponding script:
./tools/get_trancos_model.sh
run the script ./experiments/scripts/trancos_train_test.sh
run the script ./experiments/scripts/trancos_test_pretrained.sh
In order to provide a better distribution, this repository unifies and reimplements in Python some of the original modules. Due to these changes in the libraries used, the results produced by this software might be slightly different from the ones reported in the paper.