open-mmlab / mmtracking

OpenMMLab Video Perception Toolbox. It supports Video Object Detection (VID), Multiple Object Tracking (MOT), Single Object Tracking (SOT), Video Instance Segmentation (VIS) with a unified framework.
https://mmtracking.readthedocs.io/en/latest/
Apache License 2.0
3.59k stars 598 forks source link

IndexError: boolean index did not match indexed array along dimension 0; dimension is 10 but corresponding boolean dimension is 9 #808

Open ouyanglinke opened 1 year ago

ouyanglinke commented 1 year 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. The bug has not been fixed in the latest version.

Describe the bug I was trying to run qdtrack model for MOT17 in dev-1.x, but it always got this error.

Reproduction

  1. What command or script did you run?
srun -p bigdata_s2 --quotatype=auto --gres=gpu:1 python tools/train.py configs/mot/qdtrack/qdtrack_faster-rcnn_r50_fpn_8xb2-4e_mot17halftrain_test-mot17halfval.py
  1. Did you make any modifications on the code or config? Did you understand what you have modified? No
  2. What dataset did you use and what task did you run? MOT17

Environment

  1. Please run python mmtrack/utils/collect_env.py to collect necessary environment information and paste it here. Got error:

    Traceback (most recent call last):
    File "mmtrack/utils/collect_env.py", line 2, in <module>
    from mmcv.utils import collect_env as collect_base_env
    File "/mnt/lustre/ouyanglinke/anaconda3/envs/openmmlab/lib/python3.8/site-packages/mmcv/__init__.py", line 3, in <module>
    from .arraymisc import *
    File "/mnt/lustre/ouyanglinke/anaconda3/envs/openmmlab/lib/python3.8/site-packages/mmcv/arraymisc/__init__.py", line 2, in <module>
    from .quantization import dequantize, quantize
    File "/mnt/lustre/ouyanglinke/anaconda3/envs/openmmlab/lib/python3.8/site-packages/mmcv/arraymisc/quantization.py", line 2, in <module>
    from typing import Union
    File "/mnt/petrelfs/ouyanglinke/mmtracking/mmtrack/utils/typing.py", line 3, in <module>
    from typing import Dict, List, Optional, Tuple, Union
    ImportError: cannot import name 'Dict' from partially initialized module 'typing' (most likely due to a circular import) (/mnt/petrelfs/ouyanglinke/mmtracking/mmtrack/utils/typing.py)

    But I do successfully run SOT model. Python version is 3.8. Pytorch is 1.7.1.

  2. You may add addition that may be helpful for locating the problem, such as

    • How you installed PyTorch [e.g., pip, conda, source]
    • Other environment variables that may be related (such as $PATH, $LD_LIBRARY_PATH, $PYTHONPATH, etc.)

Error traceback If applicable, paste the error trackback here.

Traceback (most recent call last):
  File "tools/train.py", line 119, in <module>
    main()
  File "tools/train.py", line 115, in main
    runner.train()
  File "/mnt/lustre/ouyanglinke/anaconda3/envs/openmmlab/lib/python3.8/site-packages/mmengine/runner/runner.py", line 1684, in train
    model = self.train_loop.run()  # type: ignore
  File "/mnt/lustre/ouyanglinke/anaconda3/envs/openmmlab/lib/python3.8/site-packages/mmengine/runner/loops.py", line 90, in run
    self.run_epoch()
  File "/mnt/lustre/ouyanglinke/anaconda3/envs/openmmlab/lib/python3.8/site-packages/mmengine/runner/loops.py", line 105, in run_epoch
    for idx, data_batch in enumerate(self.dataloader):
  File "/mnt/lustre/ouyanglinke/anaconda3/envs/openmmlab/lib/python3.8/site-packages/torch/utils/data/dataloader.py", line 435, in __next__
    data = self._next_data()
  File "/mnt/lustre/ouyanglinke/anaconda3/envs/openmmlab/lib/python3.8/site-packages/torch/utils/data/dataloader.py", line 1085, in _next_data
    return self._process_data(data)
  File "/mnt/lustre/ouyanglinke/anaconda3/envs/openmmlab/lib/python3.8/site-packages/torch/utils/data/dataloader.py", line 1111, in _process_data
    data.reraise()
  File "/mnt/lustre/ouyanglinke/anaconda3/envs/openmmlab/lib/python3.8/site-packages/torch/_utils.py", line 428, in reraise
    raise self.exc_type(msg)
IndexError: Caught IndexError in DataLoader worker process 0.
Original Traceback (most recent call last):
  File "/mnt/lustre/ouyanglinke/anaconda3/envs/openmmlab/lib/python3.8/site-packages/torch/utils/data/_utils/worker.py", line 198, in _worker_loop
    data = fetcher.fetch(index)
  File "/mnt/lustre/ouyanglinke/anaconda3/envs/openmmlab/lib/python3.8/site-packages/torch/utils/data/_utils/fetch.py", line 44, in fetch
    data = [self.dataset[idx] for idx in possibly_batched_index]
  File "/mnt/lustre/ouyanglinke/anaconda3/envs/openmmlab/lib/python3.8/site-packages/torch/utils/data/_utils/fetch.py", line 44, in <listcomp>
    data = [self.dataset[idx] for idx in possibly_batched_index]
  File "/mnt/lustre/ouyanglinke/anaconda3/envs/openmmlab/lib/python3.8/site-packages/mmengine/dataset/base_dataset.py", line 378, in __getitem__
    data = self.prepare_data(idx)
  File "/mnt/petrelfs/ouyanglinke/mmtracking/mmtrack/datasets/base_video_dataset.py", line 387, in prepare_data
    return self.pipeline(final_data_info)
  File "/mnt/lustre/ouyanglinke/anaconda3/envs/openmmlab/lib/python3.8/site-packages/mmengine/dataset/base_dataset.py", line 55, in __call__
    data = t(data)
  File "/mnt/lustre/ouyanglinke/anaconda3/envs/openmmlab/lib/python3.8/site-packages/mmcv/transforms/base.py", line 12, in __call__
    return self.transform(results)
  File "/mnt/petrelfs/ouyanglinke/mmtracking/mmtrack/datasets/transforms/formatting.py", line 237, in transform
    key_anns[key_valid_idx])
IndexError: boolean index did not match indexed array along dimension 0; dimension is 10 but corresponding boolean dimension is 9

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! This message might help: In mmtracking/configs/base/datasets/mot_challenge.py, just block "TransformBroadcaster" would work.

# data pipeline
train_pipeline = [
    dict(
        type='TransformBroadcaster',
        share_random_params=True,
        transforms=[
            dict(type='LoadImageFromFile'),
            dict(type='LoadTrackAnnotations', with_instance_id=True),
            dict(
                type='mmdet.RandomResize',
                scale=(1088, 1088),
                ratio_range=(0.8, 1.2),
                keep_ratio=True,
                clip_object_border=False),
            dict(type='mmdet.PhotoMetricDistortion')
        ]),
    # dict(
    #     type='TransformBroadcaster',
    #     share_random_params=False,
    #     transforms=[
    #         dict(
    #             type='mmdet.RandomCrop',
    #             crop_size=(1088, 1088),
    #             bbox_clip_border=False)
    #     ]),
    dict(
        type='TransformBroadcaster',
        share_random_params=True,
        transforms=[
            dict(type='mmdet.RandomFlip', prob=0.5),
        ]),
    dict(type='PackTrackInputs', ref_prefix='ref', num_key_frames=1)
]
dyhBUPT commented 1 year ago

Thanks for your error report ! The bug has been fixed in PR https://github.com/open-mmlab/mmtracking/pull/811 by @pixeli99 .

Best wishes.