Skip to content

Commit

Permalink
fix a bug where detector is not initialized when training a detector …
Browse files Browse the repository at this point in the history
…in MOT task (#221)
  • Loading branch information
GT9505 authored Jul 26, 2021
1 parent b28898b commit fdeefd3
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions tools/train.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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:
Expand Down

0 comments on commit fdeefd3

Please sign in to comment.