open-mmlab / mmdetection

OpenMMLab Detection Toolbox and Benchmark
https://mmdetection.readthedocs.io
Apache License 2.0
29.31k stars 9.42k forks source link

a bug in test_mixins.py #5037

Closed ToumaKazusa3 closed 3 years ago

ToumaKazusa3 commented 3 years ago

Thanks for your error report and we appreciate it a lot.

Checklist

  1. I have searched related issues but cannot get the expected help.
  2. I have read the FAQ documentation but cannot get the expected help.
  3. The bug has not been fixed in the latest version.

Describe the bug When I run the simple_test_bboxes function in the D:\anaconda3\envs\open-mmlab\Lib\site-packages\mmdet\models\roi_heads\test_mixins.py file, If there is no proposal in this image (like [tensor([], device='cuda :0', size=(0, 4))]), the function will have the following error: RuntimeError: cannot reshape tensor of 0 elements into shape [1, 0, -1] because the unspecified dimension size -1 can be any value and is ambiguous

Reproduction

  1. What command or script did you run? I run a script in mmtracking project, which is built upon MMDetection.
    ./tools/slurm_test.sh mediaf test-1 configs/mot/tracktor/tracktor_faster-rcnn_r50_fpn_4e_mot17-public-half.py 8 --eval track

    Environment sys.platform: linux Python: 3.7.6 (default, Jan 8 2020, 19:59:22) [GCC 7.3.0] CUDA available: True GPU 0,1,2,3,4,5,6,7: GeForce GTX 1080 CUDA_HOME: /mnt/lustre/share/polaris/dep/cuda-9.0-cudnn7.6.5 NVCC: Cuda compilation tools, release 9.0, V9.0.176 GCC: gcc (GCC) 5.4.0 PyTorch: 1.5.0 PyTorch compiling details: PyTorch built with:

    • GCC 5.4
    • C++ Version: 201402
    • Intel(R) Math Kernel Library Version 2020.0.1 Product Build 20200208 for Intel(R) 64 architecture applications
    • Intel(R) MKL-DNN v0.21.1 (Git Hash 912ce228837d1ce28e1a61806118835de03f5751)
    • OpenMP 201307 (a.k.a. OpenMP 4.0)
    • NNPACK is enabled
    • CPU capability usage: AVX2
    • CUDA Runtime 9.0
    • NVCC architecture flags: -gencode;arch=compute_52,code=sm_52;-gencode;arch=compute_60,code=sm_60;-gencode;arch=compute_61,code=sm_61;-gencode;arch=compute_70,code=sm_70;-gencode;arch=compute_70,code=compute_70
    • CuDNN 7.6.5
    • Magma 2.5.0
    • Build settings: BLAS=MKL, BUILD_TYPE=Release, CXX_FLAGS= -Wno-deprecated -fvisibility-inlines-hidden -fopenmp -DNDEBUG -DUSE_FBGEMM -DUSE_QNNPACK -DUSE_PYTORCH_QNNPACK -DUSE_XNNPACK -DUSE_INTERNAL_THREADPOOL_IMPL -O2 -fPIC -Wno-narrowing -Wall -Wextra -Werror=return-type -Wno-missing-field-initializers -Wno-type-limits -Wno-array-bounds -Wno-unknown-pragmas -Wno-sign-compare -Wno-unused-parameter -Wno-unused-variable -Wno-unused-function -Wno-unused-result -Wno-strict-overflow -Wno-strict-aliasing -Wno-error=deprecated-declarations -Wno-error=pedantic -Wno-error=redundant-decls -Wno-error=old-style-cast -fdiagnostics-color=always -Wno-unused-but-set-variable -Wno-maybe-uninitialized -fno-math-errno -fno-trapping-math -Werror=format, PERF_WITH_AVX=1, PERF_WITH_AVX2=1, PERF_WITH_AVX512=1, USE_CUDA=ON, USE_EXCEPTION_PTR=1, USE_GFLAGS=OFF, USE_GLOG=OFF, USE_MKL=ON, USE_MKLDNN=ON, USE_MPI=ON, USE_NCCL=ON, USE_NNPACK=ON, USE_OPENMP=ON, USE_STATIC_DISPATCH=OFF,

TorchVision: 0.6.0 OpenCV: 4.2.0 MMCV: 1.3.1 MMCV Compiler: GCC 5.4 MMCV CUDA Compiler: 9.0 MMDetection: 2.11.0+2313bd7 Error traceback If applicable, paste the error trackback here.

File"/mnt/lustre/shensanjing/anaconda3/envs/pt1.5/lib/python3.7/sitepackages/mmdet/models/roi_heads/test_mixins.py", line 113, in simple_test_bboxes
rois = rois.reshape(batch_size, num_proposals_per_img, -1)
RuntimeError: cannot reshape tensor of 0 elements into shape [1, 0, -1] because the unspecified dimension size -1 can be any value and is ambiguous

Bug fix If you have already identified the reason, you can provide the information here. If you are willing to create a PR to fix it, please also leave a comment here and that would be much appreciated!

hhaAndroid commented 3 years ago

Hi @ToumaKazusa3 I would like to ask in what scenario will no proposal appear?Can you describe in detail?

ToumaKazusa3 commented 3 years ago

@hhaAndroid In MOT tracker, we will feed the public detections as proposels into roi head. like

 if hasattr(self.detector, 'roi_head'):
    # TODO: check whether this is the case
    if public_bboxes is not None:
        public_bboxes = [_[0] for _ in public_bboxes]
        proposals = public_bboxes
    else:
        proposals = self.detector.rpn_head.simple_test_rpn(
            x, img_metas)
    det_bboxes, det_labels = self.detector.roi_head.simple_test_bboxes(
        x,
        img_metas,
        proposals,
        self.detector.roi_head.test_cfg,
        rescale=rescale)
    # TODO: support batch inference
    det_bboxes = det_bboxes[0]
    det_labels = det_labels[0]
    num_classes = self.detector.roi_head.bbox_head.num_classes

If there is no pedestrian in the current frame or the public detector does not detect pedestrians, then there will be no proposal

hhaAndroid commented 3 years ago

@hhaAndroid In MOT tracker, we will feed the public detections as proposels into roi head. like

 if hasattr(self.detector, 'roi_head'):
    # TODO: check whether this is the case
    if public_bboxes is not None:
        public_bboxes = [_[0] for _ in public_bboxes]
        proposals = public_bboxes
    else:
        proposals = self.detector.rpn_head.simple_test_rpn(
            x, img_metas)
    det_bboxes, det_labels = self.detector.roi_head.simple_test_bboxes(
        x,
        img_metas,
        proposals,
        self.detector.roi_head.test_cfg,
        rescale=rescale)
    # TODO: support batch inference
    det_bboxes = det_bboxes[0]
    det_labels = det_labels[0]
    num_classes = self.detector.roi_head.bbox_head.num_classes

If there is no pedestrian in the current frame or the public detector does not detect pedestrians, then there will be no proposal

Ok, Thank you. I will check it.