Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix a bug where detector is not initialized when training a detector in MOT task #221

Merged
merged 1 commit into from
Jul 26, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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