mmtracking icon indicating copy to clipboard operation
mmtracking copied to clipboard

Use pretrained RTMDet as detector

Open tctco opened this issue 1 year ago • 1 comments

I'm trying to use RTMDet as the detector and use SORT to track a video with demo_vid.py, but I get the following errors:

03/07 23:32:17 - mmengine - WARNING - The "model" registry in mmtrack did not set import location. Fallback to call `mmtrack.utils.register_all_modules` instead.
03/07 23:32:17 - mmengine - WARNING - The "task util" registry in mmtrack did not set import location. Fallback to call `mmtrack.utils.register_all_modules` instead.
Traceback (most recent call last):
  File "/home/tc/anaconda3/envs/open-mmlab/lib/python3.8/site-packages/mmengine/registry/build_functions.py", line 121, in build_from_cfg
    obj = obj_cls(**args)  # type: ignore
  File "/home/tc/open-mmlab/mmdetection/mmdet/models/task_modules/assigners/dynamic_soft_label_assigner.py", line 64, in __init__
    self.iou_calculator = TASK_UTILS.build(iou_calculator)
  File "/home/tc/anaconda3/envs/open-mmlab/lib/python3.8/site-packages/mmengine/registry/registry.py", line 548, in build
    return self.build_func(cfg, *args, **kwargs, registry=self)
  File "/home/tc/anaconda3/envs/open-mmlab/lib/python3.8/site-packages/mmengine/registry/build_functions.py", line 100, in build_from_cfg
    raise KeyError(
KeyError: 'BboxOverlaps2D is not in the task util registry. Please check whether the value of `BboxOverlaps2D` is correct or it was registered as expected. More details can be found at https://mmengine.readthedocs.io/en/latest/advanced_tutorials/config.html#import-the-custom-module'

What could cause the problem?

Here are my configs

_base_ = [
    './rtmdet_tiny.py',
    '../_base_/datasets/mot_challenge.py', '../_base_/default_runtime.py'
]
model = dict(
    type='DeepSORT',
    detector=dict(
        init_cfg=dict(
            type='Pretrained',
            checkpoint=  # noqa: E251
            '/home/tc/open-mmlab/mmdetection/work_dirs/rtmdet-ins_tiny_8xb32-300e_mouse/best_coco/segm_mAP_epoch_291.pth'  # noqa: E501
        )),
    motion=dict(type='KalmanFilter', center_only=False),
    tracker=dict(
        type='SORTTracker', obj_score_thr=0.5, match_iou_thr=0.5, reid=None))

train_dataloader = None

train_cfg = None
val_cfg = dict(type='ValLoop')
test_cfg = dict(type='TestLoop')
model = dict(
  data_preprocessor=dict(
    type='TrackDataPreprocessor',
    mean=[103.53, 116.28, 123.675],
    std=[57.375, 57.12, 58.395],
    bgr_to_rgb=False,
    batch_augments=None),
  detector=dict(
    type='mmdet.RTMDet',
    backbone=dict(
      type='mmdet.CSPNeXt',
      arch='P5',
      expand_ratio=0.5,
      deepen_factor=0.167,
      widen_factor=0.375,
      channel_attention=True,
      norm_cfg=dict(type='SyncBN'),
      act_cfg=dict(type='SiLU', inplace=True),
      init_cfg=dict(
        type='Pretrained',
        prefix='backbone.',
        checkpoint=
        'https://download.openmmlab.com/mmdetection/v3.0/rtmdet/cspnext_rsb_pretrain/cspnext-tiny_imagenet_600e.pth'
      )),
    neck=dict(
      type='mmdet.CSPNeXtPAFPN',
      in_channels=[96, 192, 384],
      out_channels=96,
      num_csp_blocks=1,
      expand_ratio=0.5,
      norm_cfg=dict(type='SyncBN'),
      act_cfg=dict(type='SiLU', inplace=True)),
    bbox_head=dict(
      type='mmdet.RTMDetInsSepBNHead',
      num_classes=1,
      in_channels=96,
      stacked_convs=2,
      share_conv=True,
      pred_kernel_size=1,
      feat_channels=96,
      act_cfg=dict(type='SiLU', inplace=True),
      norm_cfg=dict(type='SyncBN', requires_grad=True),
      anchor_generator=dict(
        type='mmdet.MlvlPointGenerator', offset=0, strides=[8, 16, 32]),
      bbox_coder=dict(type='mmdet.DistancePointBBoxCoder'),
      loss_cls=dict(
        type='mmdet.QualityFocalLoss',
        use_sigmoid=True,
        beta=2.0,
        loss_weight=1.0),
      loss_bbox=dict(type='mmdet.GIoULoss', loss_weight=2.0),
      loss_mask=dict(
        type='mmdet.DiceLoss', loss_weight=2.0, eps=5e-06, reduction='mean')),
    train_cfg=dict(
      assigner=dict(type='mmdet.DynamicSoftLabelAssigner', topk=13),
      allowed_border=-1,
      pos_weight=-1,
      debug=False),
    test_cfg=dict(
      nms_pre=1000,
      min_bbox_size=0,
      score_thr=0.05,
      nms=dict(type='nms', iou_threshold=0.6),
      max_per_img=100,
      mask_thr_binary=0.5)
      )
  )

tctco avatar Mar 07 '23 15:03 tctco

did you figure this out? Trying to do something similar

robertsutherland avatar Nov 29 '23 22:11 robertsutherland