Giter Club home page Giter Club logo

crowdcount-cascaded-mtl's Introduction

CNN-based Cascaded Multi-task Learning of High-level Prior and Density Estimation for Crowd Counting (Single Image Crowd Counting)

This is implementation of the paper CNN-based Cascaded Multi-task Learning of High-level Prior and Density Estimation for Crowd Counting for single image crowd counting which is accepted at AVSS 2017

Installation

  1. Install pytorch

  2. Clone this repository

git clone https://github.com/svishwa/crowdcount-cascaded-mtl.git

We'll call the directory that you cloned crowdcount-cascaded-mtl ROOT

Data Setup

  1. Download ShanghaiTech Dataset

    Dropbox: https://www.dropbox.com/s/fipgjqxl7uj8hd5/ShanghaiTech.zip?dl=0

    Baidu Disk: http://pan.baidu.com/s/1nuAYslz

  2. Create Directory

mkdir ROOT/data/original/shanghaitech/  
  1. Save "part_A_final" under ROOT/data/original/shanghaitech/

  2. Save "part_B_final" under ROOT/data/original/shanghaitech/

  3. cd ROOT/data_preparation/

    run create_gt_test_set_shtech.m in matlab to create ground truth files for test data

  4. cd ROOT/data_preparation/

    run create_training_set_shtech.m in matlab to create training and validataion set along with ground truth files

Test

  1. Follow steps 1,2,3,4 and 5 from Data Setup

  2. Download pre-trained model files:

    [Shanghai Tech A]

    [Shanghai Tech B]

    Save the model files under ROOT/final_models

  3. Run test.py

    a. Set save_output = True to save output density maps

    b. Errors are saved in output directory

Training

  1. Follow steps 1,2,3,4 and 6 from Data Setup
  2. Run train.py

Training with TensorBoard

With the aid of Crayon, we can access the visualisation power of TensorBoard for any deep learning framework.

To use the TensorBoard, install Crayon (https://github.com/torrvision/crayon) and set use_tensorboard = True in ROOT/train.py.

Other notes

  1. During training, the best model is chosen using error on the validation set.

  2. 10% of the training set is set aside for validation. The validation set is chosen randomly.

  3. Following are the results on Shanghai Tech A and B dataset:

             |     |  MAE  |   MSE  |
             ------------------------
             | A   |  101  |   148  |
             ------------------------
             | B   |   17  |    29  |
    

    It may be noted that the results are slightly different from the paper. This is due to a few implementation differences as the earlier implementation was in torch-lua. Contact me if torch models (that were used for the paper) are required.

crowdcount-cascaded-mtl's People

Contributors

svishwa 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

crowdcount-cascaded-mtl's Issues

the output image is grayscale

when I run test.py, I found the output image is grayscale while it should be colorful in your paper, what should I do to solve this question.

A question for training

Hello,I ran the code you provided, but I was unable to reproduce the effect of the paper,I can only lower my MAE to 30. I have a question if there are any training technique?

Dataset

Hi,
Could you please share the link to ShanghaiTech dataset?
Thank you in advance.

run test.py error

cuda runtime error!
When trying to run test.py I get the following message:
(pytorch) zhouyao@wb-i36g:~/crowdcount-cascaded-mtl$ python test.py --gpu 0
Pre-loading the data. This may take a while...
Loaded 100 / 182
Completed laoding 182 files
/home/zhouyao/anaconda3/envs/pytorch/lib/python2.7/site-packages/h5py/init.py:36: FutureWarning: Conversion of the second argumen t of issubdtype from float to np.floating is deprecated. In future, it will be treated as np.float64 == np.dtype(float).type.
from ._conv import register_converters as _register_converters
/home/zhouyao/crowdcount-cascaded-mtl/src/crowd_count.py:25: UserWarning: Implicit dimension choice for softmax has been deprecated. Change the call to include dim=X as an argument.
density_cls_prob = F.softmax(density_cls_score)
THCudaCheck FAIL file=/opt/conda/conda-bld/pytorch_1513363039688/work/torch/lib/THC/generic/THCTensorCopy.c line=70 error=77 : an ill egal memory access was encountered
Traceback (most recent call last):
File "test.py", line 45, in
density_map = density_map.data.cpu().numpy()
File "/home/zhouyao/anaconda3/envs/pytorch/lib/python2.7/site-packages/torch/tensor.py", line 35, in cpu
return self.type(getattr(torch, self.class.name))
File "/home/zhouyao/anaconda3/envs/pytorch/lib/python2.7/site-packages/torch/cuda/init.py", line 370, in type
return super(_CudaBase, self).type(*args, **kwargs)
File "/home/zhouyao/anaconda3/envs/pytorch/lib/python2.7/site-packages/torch/_utils.py", line 38, in type
return new_type(self.size()).copy(self, async)
RuntimeError: cuda runtime error (77) : an illegal memory access was encountered at /opt/conda/conda-bld/pytorch_1513363039688/work/t orch/lib/THC/generic/THCTensorCopy.c:70

Any suggestions for what might be wrong.

how to fix the invalid value problem

when i change my own dataset , it comes out with:
D:\project\mtl\src\utils.py:8: RuntimeWarning: invalid value encountered in true_divide
density_map = 255*density_map/np.max(density_map)

UC_FF_50 processing code

Dear svishwa, I am not getting shanghatitech images publicly. I also emailed to the authors but yet I dint get any kind of links of the dataset. I have UCF dataset. Can you please provide me the UC_FF_50 data processing marlab codes, if available?

usage Models

How to use trained model for other crowd dataset images.

How to output the crowd count ?

Hello, when I run test.py I get the grayscale density maps, however I don't find the crowd count like it is outputted in your paper. How do we get it ?

为什么要灰度化

您好!请问为什么得到的结果都是灰度图像,而paper中的是彩色图像,是训练需要吗?

Model download issue

I met a issue when i tried to access to the DropBox. So i would be appreciated that if you can provide the final train model in Baidu disk.

Thank you.

Issues

Hi, I didn't download the Pre-trained model files [Shanghai Tech A], [Shanghai Tech A],Can you seed me the files to the email, My email is [email protected]. Thank you very much

Softmax runtime warning

UserWarning: Implicit dimension choice for softmax has been deprecated. Change the call to include dim=X as an argument.
this is the original code line: density_cls_prob = F.softmax(density_cls_score)
So how do I know whether dim should be taken '0' or '1'

evaluate count do not effective in this network.

epoch: 0, step 525, Time: 0.0011s, gt_cnt: 0.0, et_cnt: 7.1
epoch: 0, step 530, Time: 0.0011s, gt_cnt: 59.5, et_cnt: 6.9
epoch: 0, step 535, Time: 0.0010s, gt_cnt: 0.0, et_cnt: 7.4
epoch: 0, step 540, Time: 0.0010s, gt_cnt: 1.0, et_cnt: 7.2
epoch: 0, step 545, Time: 0.0010s, gt_cnt: 0.0, et_cnt: 6.7
epoch: 0, step 550, Time: 0.0010s, gt_cnt: 2.0, et_cnt: 6.4
epoch: 0, step 555, Time: 0.0010s, gt_cnt: 3.0, et_cnt: 6.0
epoch: 0, step 560, Time: 0.0010s, gt_cnt: 0.0, et_cnt: 6.2
epoch: 0, step 565, Time: 0.0010s, gt_cnt: 3.1, et_cnt: 6.3
epoch: 0, step 570, Time: 0.0010s, gt_cnt: 1.0, et_cnt: 6.0
epoch: 0, step 575, Time: 0.0010s, gt_cnt: 7.6, et_cnt: 5.6
epoch: 0, step 580, Time: 0.0010s, gt_cnt: 0.0, et_cnt: 5.8

It seems like that the evaluate count is continuous,but not appeared in 'mcnn' network. What's more, the density maps draw a blank.

how to test on new images

I have crowd images gathered by a security camera. I have all jpg files. How do I run your code on only jpg files. From what I have seen your code requires '.mat'+'.jpg' files in order to produce output. But in my case I donot have .mat file

Any pointers will really help

Error running test.py

When trying to run test.py I get the following message:
File "test.py", line 4, in
from src.crowd_count import CrowdCounter
File "ROOT/crowdcount-cascaded-mtl/src/crowd_count.py", line 5, in
import network
ModuleNotFoundError: No module named 'network'

Thanks in advance for your help

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.