Giter VIP home page Giter VIP logo

crowddetection's Introduction

Detection in Crowded Scenes: One Proposal, Multiple Predictions

This is the pytorch re-implementation of the paper "Detection in Crowded Scenes: One Proposal, Multiple Predictions" that published in CVPR 2020.

Object detection in crowded scenes is challenging. When objects gather, they tend to overlap largely with each other, leading to occlusions. Occlusion caused by objects of the same class is called intra-class occlusion, also referred to as crowd occlusion. Object detectors need to determine the locations of different objects in the crowd and accurately delineate their boundaries. Many cases are quite challenging even for human annotators.

To address the aforementioned problem, this paper proposed a schema that one anchor/proposal can predict multiple predictions simultaneously. With this scheme, the predictions of nearby proposals are expected to infer the same set of instances, rather than distinguishing individuals, which is much easy for the model to learn. Besides, A new NMS method called set NMS is designed to remove the duplicates during the inference time. The EMD loss is devised to obtain the minimal loss during optimization based on the truth that a set of combinations can be obtained between the predictions and groundtruth boxes. Therefore, the combination that produces the minimal loss can be chosen to better optimize the model during training. Additionally, the proposed schema can be deployed on the mainstream detectors such as Cascade RCNN, FPN and also one-stage detector RetinaNet. The implementation details can be viewed in the repository.

The model structure and results are shown here:

Citation

If you use the code in your research, please cite:

@InProceedings{Chu_2020_CVPR,
author = {Chu, Xuangeng and Zheng, Anlin and Zhang, Xiangyu and Sun, Jian},
title = {Detection in Crowded Scenes: One Proposal, Multiple Predictions},
booktitle = {Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition (CVPR)},
month = {June},
year = {2020}
}

Run

  1. Requirements:

    • python 3.6.8, pytorch 1.5.0, torchvision 0.6.0, cuda 10.1
  2. CrowdHuman data:

    • CrowdHuman is a benchmark dataset containing highly overlapped objects to better evaluate whether a detector can better handle crowd scenarios. The dataset can be downloaded from http://www.crowdhuman.org/. The path of the dataset is set in config.py.
  3. Steps to run:

    • Step1: training. More training and testing settings can be set in config.py.
    cd ROOT_DIR/model/DETECTOR_NAME/OWNER_NAME/project
    
    • Step2: testing. If you have four GPUs, you can use -d 0-NUM_GPUS to use all of your GPUs. NUM_GPUS is the number of GPUs you would lik to use during inference, The result json file will be saved in the corresponding directory automatically.
    cd ROOT_DIR/model/DETECTOR_NAME/OWNER_NAME/project
    python3 test_net.py -d 0-NUM_GPUS -r 40 -e 50
    
    • Step3: evaluating json, inference one picture and visulization json file. All of the value correpsponding the different evalutation metric will be calculated and be saved in a log file
    cd ROOT_DIR/model/DETECTOR_NAME/OWNER_NAME/project
    python3 demo.py
    

Models

This proiect is a re-implementation based on Pytorch. We use pre-trained model from MegEngine Model Hub and convert this model to pytorch. You can get this model from GoogleDrive or Baidu Netdisk(code:yx46).

Model Top1 acc Top5 acc
ResNet50 76.254 93.056

All models are re-trained based on ResNet-50.

mAP mMR mJI Model
RCNN FPN Baseline 0.8708 0.4262 0.7973 rcnn_fpn_baseline.pth
RCNN EMD Simple 0.9027 0.4208 0.8246 rcnn_emd_simple.pth
RCNN EMD with RM 0.9041 0.4145 0.8251 rcnn_emd_refine.pth
Cascade FPN RCNN Baseline 0.8677 0.4065 0.8038 cascade_rcnn_fpn_baseline.pth
Cascade FPN RCNN EMD Simple 0.9048 0.4022 0.8314 cascade_rcnn_emd_simple.pth
Cascade FPN RCNN EMD with RM 0.9047 0.3987 0.8272 cascade_rcnn_emd_refine.pth
RetinaNet FPN Baseline 0.8793 0.4753 0.7729 retinanet_baseline.pth
RetinaNet Simple 0.8988 0.4779 0.7931 retinanet_simple.pth

crowddetection's People

Contributors

megvii-model avatar xg-chu avatar yexiguafuqihao avatar zhouyizhuang-megvii 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  avatar  avatar  avatar  avatar  avatar  avatar  avatar

crowddetection's Issues

Errors when runing on myself dataset

Environment

  • CUDA 10.2
  • megengine 3.1
  • python 3.6

Hi, I run this code based on the crowd person dataset, It seem everything is ok.

11 23:56:11 e0, 112/3750, lr:0.002123, total_loss:0.870193, rpn_cls:0.212023, rpn_loc:0.182936, rcnn_emd:0.475234
11 23:56:18 e0, 113/3750, lr:0.002127, total_loss:0.817391, rpn_cls:0.129117, rpn_loc:0.066281, rcnn_emd:0.621992
11 23:56:19 e0, 114/3750, lr:0.002132, total_loss:1.136824, rpn_cls:0.205079, rpn_loc:0.195120, rcnn_emd:0.736625

But, when I try to run this code based on myself dataset, it always occur the error as follows:

 File "/root/ld/PycharmProjects/CrowdDetection/model/emd_simple/train.py", line 60, in train_one_epoch
    losses = propagate()
megengine._internal.exc.MegBrainError: MegBrain core throws exception: mgb::MegDNNError
bad input shape for polyadic operator: {2034,12}, {2034,4}
| Associated operator: id=130407 name=SUB(reshape[130071],reshape[130401])[130407] type=mgb::opr::Elemwise
|   input variables: 
|     0: {id:130072, shape:{2034,12}, Float32, owner:reshape(concat[130063])[130071]{Reshape}, name:reshape(concat[130063])[130071], slot:0, gpu0:0, d, 8, 8}
|     1: {id:130402, shape:{2034,4}, Float32, owner:reshape(indexing_multi_axis_vec[130398])[130401]{Reshape}, name:reshape(indexing_multi_axis_vec[130398])[130401], slot:0, gpu0:0, d, 8, 8}
|   output variables: 
|     0: {id:130408, shape:{}, Float32, owner:SUB(reshape[130071],reshape[130401])[130407]{Elemwise}, name:SUB(reshape[130071],reshape[130401])[130407], slot:0, gpu0:0, d, 8, 8}

Do you have any suggestion about that?
Thanks

Erro when compiling

Hi, when i make sh ./setup.sh i get this error

nms.cu:1:10: fatal error: megbrain_pubapi.h: No such file or directory
#include "megbrain_pubapi.h"
^~~~~~~~~~~~~~~~~~~
compilation terminated.

How can i fix it?

Failed to request for multiple GPUs during inference

test.py provides API for multi-GPUs testing. However, when I set -d 4, the program seems to request memory on only GPU 0 which leads to OOM.

11 16:42:50[mgb] ERR cudaMalloc failed while requesting 57933824 bytes (55.250MiB) of memory; error: out of memory(last_err=2(out of memory) device=0 mem_free=29.312MiB mem_tot=24220.312MiB)
11 16:42:50[mgb] could not allocate memory on device 0; try to gather free blocks from child streams, got 0.00MiB(0 bytes).

Have you met this problem before?

Problem with @jit.trace(symbolic=True) in the train.py of the cascade_emd model

When I run the cascade_emd model, I met the error as the following. I appreciate it if you could help me out. Thank you in advance.

Traceback (most recent call last):
File "train.py", line 167, in
run_train()
File "train.py", line 164, in run_train
train(args)
File "train.py", line 156, in train
worker(0, 1, args)
File "train.py", line 119, in worker
train_one_epoch(model, train_loader, opt, max_steps, rank, epoch_id, gpu_num)
File "train.py", line 58, in train_one_epoch
losses = propagate()
File "/home/xinmiao/anaconda3/envs/CRDET/lib/python3.6/site-packages/megengine/jit/init.py", line 424, in call
self._compiled_func()
File "/home/xinmiao/anaconda3/envs/CRDET/lib/python3.6/site-packages/megengine/_internal/mgb.py", line 1208, in call
self._execute()
File "/home/xinmiao/anaconda3/envs/CRDET/lib/python3.6/site-packages/megengine/_internal/mgb.py", line 1092, in _execute
return _mgb.AsyncExec__execute(self)
megengine._internal.exc.MegBrainError: MegBrain core throws exception: mgb::AssertionError
assertion `begin >= 0 && end >= begin && end <= size_ax' failed at /home/code/src/core/impl/tensor.cpp:151: mgb::SubTensorSpec mgb::Slice::apply(megdnn::TensorLayout, int) const
extra message: index out of bound: layout={511(1),1(1)}; request begin=None end=2 step=None axis=1

  • bt:/home/xinmiao/anaconda3/envs/CRDET/lib/python3.6/site-packages/megengine/_internal/_mgb.cpython-36m-x86_64-linux-gnu.so{1e36052,1edec06,1fc6782,1fc6fd0}
    | Associated operator: id=160315 name=subtensor(argsort[160305]:o0)[160315] type=mgb::opr::Subtensor
    | input variables:
    | 0: {id:160306, shape:{511,1}, Float32, owner:argsort(MUL[160303])[160305]{ArgsortForward}, name:argsort(MUL[160303])[160305]:o0, slot:0, gpu0:0, d, 8, 1}
    | 1: {id:21, shape:{1}, Int32, owner:2[20]{ImmutableTensor}, name:2[20], slot:0, gpu0:0, s, 2, 2}
    | output variables:
    | 0: {id:160316, shape:{553,2}, Float32, owner:subtensor(argsort[160305]:o0)[160315]{Subtensor}, name:subtensor(argsort[160305]:o0)[160315], slot:0, gpu0:0, d, 8, 8}
    |
    | Unoptimized equivalent of associated operator: id=10623 name=subtensor(argsort[10615]:o0)[10623] type=mgb::opr::Subtensor
    | input variables:
    | 0: {id:10616, shape:{}, Float32, owner:argsort(MUL[10611])[10615]{ArgsortForward}, name:argsort(MUL[10611])[10615]:o0, slot:0, gpu0:0, d, 8, 1}
    | 1: {id:21, shape:{1}, Int32, owner:2[20]{ImmutableTensor}, name:2[20], slot:0, gpu0:0, s, 2, 2}
    | output variables:
    | 0: {id:10624, shape:{}, Float32, owner:subtensor(argsort[10615]:o0)[10623]{Subtensor}, name:subtensor(argsort[10615]:o0)[10623], slot:0, gpu0:0, d, 8, 8}

set_cpu_nms

To understand the set NMS operation, I run the sub main func in utils/set_nms_utils , changing keep = py_cpu_nms(boxes,nms_thresh) as keep = set_cpu_nms(boxes,nms_thresh) , the ERROR encounters as follow:
"set_nms_utils.py", line 29, in set_cpu_nms
numbers = dets[:, 5]
IndexError: index 5 is out of bounds for axis 1 with size 5
Please Help solve this \ ( * ^ * ) /

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.