From cc276ac3e03480b4e20ec5f21370225eed6e01cc Mon Sep 17 00:00:00 2001 From: Tao Gong Date: Mon, 26 Jul 2021 17:10:26 +0800 Subject: [PATCH] fix a bug where detector is not initialized when training a detector in MOT task --- tools/train.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/tools/train.py b/tools/train.py index bbc57f3c8..607091fd4 100644 --- a/tools/train.py +++ b/tools/train.py @@ -66,11 +66,13 @@ def main(): cfg = Config.fromfile(args.config) + need_init_detector = False if cfg.get('USE_MMDET', False): from mmdet.apis import train_detector as train_model from mmdet.models import build_detector as build_model if 'detector' in cfg.model: cfg.model = cfg.model.detector + need_init_detector = True elif cfg.get('USE_MMCLS', False): from mmtrack.apis import train_model from mmtrack.models import build_reid as build_model @@ -146,6 +148,10 @@ def main(): model = build_model(cfg.model) if 'detector' in cfg.model: model.detector.init_weights() + # if True, the model denotes a detector based on Line #75. Therefore, we + # need model.init_weights() rather than model.detector.init_weights() + if need_init_detector: + model.init_weights() datasets = [build_dataset(cfg.data.train)] if len(cfg.workflow) == 2: