Skip to content

separate caching logic from download for PhotoTour dataset #3448

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

Merged
merged 2 commits into from
Mar 1, 2021
Merged
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
7 changes: 5 additions & 2 deletions torchvision/datasets/phototour.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,10 @@ def __init__(
self.download()

if not self._check_datafile_exists():
raise RuntimeError('Dataset not found.' +
' You can use download=True to download it')
try:
self.cache()
except Exception as error:
raise RuntimeError("Dataset not found. You can use download=True to download it") from error

# load the serialized data
self.data, self.labels, self.matches = torch.load(self.data_file)
Expand Down Expand Up @@ -151,6 +153,7 @@ def download(self) -> None:

os.unlink(fpath)

def cache(self) -> None:
# process and save as torch files
print('# Caching data {}'.format(self.data_file))

Expand Down