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] Fix bugs in RandomConcatDataset, SeqCropLikeStark and TridentSampling #438

Merged
merged 5 commits into from
Feb 23, 2022
Merged
Show file tree
Hide file tree
Changes from 4 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
13 changes: 7 additions & 6 deletions mmtrack/datasets/builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
from mmdet.datasets.samplers import (DistributedGroupSampler,
DistributedSampler, GroupSampler)
from torch.utils.data import DataLoader
from torch.utils.data.dataset import ConcatDataset
from torch.utils.data.sampler import RandomSampler

from mmtrack.datasets.samplers.quota_sampler import DistributedQuotaSampler
Expand Down Expand Up @@ -56,10 +57,13 @@ def build_dataloader(dataset,
DataLoader: A PyTorch dataloader.
"""
rank, world_size = get_dist_info()
is_sotdataset = isinstance(dataset, BaseSOTDataset) or (
isinstance(dataset, ConcatDataset)
and isinstance(dataset.datasets[0], BaseSOTDataset))
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add comments for isinstance(dataset, ConcatDataset) and isinstance(dataset.datasets[0], BaseSOTDataset)

if dist:
# ----- distributed train mode ------
if shuffle:
if isinstance(dataset, BaseSOTDataset):
if is_sotdataset:
if samples_per_epoch is None:
sampler = DistributedSampler(
dataset, world_size, rank, shuffle=True)
Expand Down Expand Up @@ -90,7 +94,7 @@ def build_dataloader(dataset,
else:
# ----- non-distributed train mode ------
if shuffle:
if isinstance(dataset, BaseSOTDataset):
if is_sotdataset:
if samples_per_epoch is None:
sampler = RandomSampler(dataset)
else:
Expand All @@ -104,10 +108,7 @@ def build_dataloader(dataset,
sampler = GroupSampler(dataset, samples_per_gpu)
# ----- non-distributed test mode ------
else:
if isinstance(dataset, BaseSOTDataset):
sampler = SOTVideoSampler(dataset)
else:
sampler = None
sampler = SOTVideoSampler(dataset) if is_sotdataset else None

batch_size = num_gpus * samples_per_gpu
num_workers = num_gpus * workers_per_gpu
Expand Down
2 changes: 2 additions & 0 deletions mmtrack/datasets/dataset_wrappers.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ def __init__(self, dataset_cfgs, dataset_sampling_weights=None):
]

datasets = [build_dataset(cfg) for cfg in dataset_cfgs]
self.CLASSES = datasets[0].CLASSES
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add comments that why we need CLASSES


super().__init__(datasets)

def __getitem__(self, ind):
Expand Down
5 changes: 1 addition & 4 deletions mmtrack/datasets/pipelines/processing.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,14 +117,11 @@ def sampling_trident(self, video_visibility):
else:
min_ind, max_ind = search_ind - max_frame_range, \
search_ind
# TODO: invisible objects are not used, because their
# bboxes must cause interruption in the subsequent
# pipeline.
extra_template_index = self.random_sample_inds(
video_visibility,
num_samples=1,
frame_range=[min_ind, max_ind],
allow_invisible=True)[0]
allow_invisible=False)[0]
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why change like this?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the bboxes of invisible object are invalid, and it will cause interruptions in the pipeline.


extra_template_inds.append(extra_template_index)

Expand Down
2 changes: 1 addition & 1 deletion mmtrack/datasets/pipelines/transforms.py
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,7 @@ def __call__(self, results):
_results['img_shape'] = crop_img.shape
_results['gt_bboxes'] = generated_bbox
_results['seg_fields'] = ['padding_mask']
_results['pdding_mask'] = padding_mask
_results['padding_mask'] = padding_mask
outs.append(_results)
return outs

Expand Down