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

PipelineSwitchHook now compatible with MultiImageMixDataset #11716

Open
wants to merge 4 commits into
base: dev-3.x
Choose a base branch
from
Open
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
12 changes: 12 additions & 0 deletions mmdet/engine/hooks/pipeline_switch_hook.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,18 @@ def before_train_epoch(self, runner):
# The dataset pipeline cannot be updated when persistent_workers
# is True, so we need to force the dataloader's multi-process
# restart. This is a very hacky approach.
# Make it compatible with MultiImageMixDataset
if hasattr(train_loader.dataset, 'dataset'):
# Set the loading pipeline to the identity function
# Keep it compatible with "scale_factor" key, which
# is not available otherwise.
train_loader.dataset.pipeline = Compose([lambda x: x])
# Rewrite the inner pipeline with the one given
train_loader.dataset.dataset.pipeline = \
Compose(self.switch_pipeline)
else:
train_loader.dataset.pipeline = \
Compose(self.switch_pipeline)
train_loader.dataset.pipeline = Compose(self.switch_pipeline)
if hasattr(train_loader, 'persistent_workers'
) and train_loader.persistent_workers is True:
Expand Down