From 624eb6368d48cbda9a270758b4ec5106a69140a2 Mon Sep 17 00:00:00 2001 From: vfdev Date: Tue, 17 Oct 2023 00:27:12 +0200 Subject: [PATCH] Added graceful exit if data download errored (#3096) --- examples/super_resolution/main.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/examples/super_resolution/main.py b/examples/super_resolution/main.py index 816d1caea7f..08199a22e74 100644 --- a/examples/super_resolution/main.py +++ b/examples/super_resolution/main.py @@ -73,8 +73,12 @@ def __len__(self): return len(self.dataset) -trainset = torchvision.datasets.Caltech101(root="./data", download=True) -testset = torchvision.datasets.Caltech101(root="./data", download=False) +try: + trainset = torchvision.datasets.Caltech101(root="./data", download=True) + testset = torchvision.datasets.Caltech101(root="./data", download=False) +except RuntimeError: + print("Dataset download problem, exiting without error code") + exit(0) trainset_sr = SRDataset(trainset, scale_factor=opt.upscale_factor, crop_size=opt.crop_size) testset_sr = SRDataset(testset, scale_factor=opt.upscale_factor, crop_size=opt.crop_size)