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

Expose data loader parameters in build_batch_data_loader and build_detection_train_loader. #5082

Closed
wants to merge 1 commit into from
Closed
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
15 changes: 15 additions & 0 deletions detectron2/data/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -289,6 +289,9 @@ def build_batch_data_loader(
num_workers=0,
collate_fn=None,
drop_last: bool = True,
prefetch_factor=None,
persistent_workers=False,
pin_memory=False,
):
"""
Build a batched dataloader. The main differences from `torch.utils.data.DataLoader` are:
Expand Down Expand Up @@ -327,6 +330,9 @@ def build_batch_data_loader(
num_workers=num_workers,
collate_fn=operator.itemgetter(0), # don't batch, but yield individual elements
worker_init_fn=worker_init_reset_seed,
prefetch_factor=prefetch_factor,
persistent_workers=persistent_workers,
pin_memory=pin_memory,
) # yield individual mapped dict
data_loader = AspectRatioGroupedDataset(data_loader, batch_size)
if collate_fn is None:
Expand All @@ -340,6 +346,9 @@ def build_batch_data_loader(
num_workers=num_workers,
collate_fn=trivial_batch_collator if collate_fn is None else collate_fn,
worker_init_fn=worker_init_reset_seed,
prefetch_factor=prefetch_factor,
persistent_workers=persistent_workers,
pin_memory=pin_memory,
)


Expand Down Expand Up @@ -479,6 +488,9 @@ def build_detection_train_loader(
aspect_ratio_grouping=True,
num_workers=0,
collate_fn=None,
prefetch_factor=None,
persistent_workers=False,
pin_memory=False,
):
"""
Build a dataloader for object detection with some default features.
Expand Down Expand Up @@ -530,6 +542,9 @@ def build_detection_train_loader(
aspect_ratio_grouping=aspect_ratio_grouping,
num_workers=num_workers,
collate_fn=collate_fn,
prefetch_factor=prefetch_factor,
persistent_workers=persistent_workers,
pin_memory=pin_memory,
)


Expand Down