Skip to content

Commit

Permalink
fix: do not download VOCSegmentation by default (#144)
Browse files Browse the repository at this point in the history
* fix: do not download VOCSegmentation by default

* fix: add local rank barrier

* chore: remove extra try except
  • Loading branch information
ydcjeff committed Jun 1, 2021
1 parent 4dfbf33 commit cff1946
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 4 deletions.
24 changes: 21 additions & 3 deletions src/templates/template-vision-segmentation/data.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,18 @@ def __getitem__(self, index):


def setup_data(config: Namespace):
dataset_train = VOCSegmentationPIL(
root=config.data_path, year="2012", image_set="train", download=False
)
try:
dataset_train = VOCSegmentationPIL(
root=config.data_path,
year="2012",
image_set="train",
download=False,
)
except RuntimeError as e:
raise e(
"Dataset not found. You can use `download_datasets` from data.py function to download it."
)

dataset_eval = VOCSegmentationPIL(
root=config.data_path, year="2012", image_set="val", download=False
)
Expand Down Expand Up @@ -168,5 +177,14 @@ def prepare_image_mask(batch, device, non_blocking):


def download_datasets(data_path):
local_rank = idist.get_local_rank()
if local_rank > 0:
# Ensure that only rank 0 download the dataset
idist.barrier()

VOCSegmentation(data_path, image_set="train", download=True)
VOCSegmentation(data_path, image_set="val", download=True)

if local_rank == 0:
# Ensure that only rank 0 download the dataset
idist.barrier()
1 change: 0 additions & 1 deletion src/templates/template-vision-segmentation/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,6 @@ def _():
# main entrypoint
def main():
config = setup_parser().parse_args()
download_datasets(config.data_path)
#::: if (it.dist === 'spawn') { :::#
#::: if (it.nproc_per_node && it.nnodes > 1 && it.master_addr && it.master_port) { :::#
kwargs = {
Expand Down

0 comments on commit cff1946

Please sign in to comment.