Skip to content
Merged
Show file tree
Hide file tree
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
5 changes: 0 additions & 5 deletions test/test_datasets.py
Original file line number Diff line number Diff line change
Expand Up @@ -1869,11 +1869,6 @@ def test_class_to_idx(self):
with self.create_dataset() as (dataset, _):
assert dataset.class_to_idx == class_to_idx

def test_images_download_preexisting(self):
with pytest.raises(RuntimeError):
with self.create_dataset({"download": True}):
pass


class INaturalistTestCase(datasets_utils.ImageDatasetTestCase):
DATASET_CLASS = datasets.INaturalist
Expand Down
11 changes: 4 additions & 7 deletions torchvision/datasets/inaturalist.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ def __init__(
if download:
self.download()

if not self._check_integrity():
if not self._check_exists():
raise RuntimeError("Dataset not found or corrupted. You can use download=True to download it")

self.all_categories: List[str] = []
Expand Down Expand Up @@ -219,15 +219,12 @@ def category_name(self, category_type: str, category_id: int) -> str:
return name
raise ValueError(f"Invalid category id {category_id} for {category_type}")

def _check_integrity(self) -> bool:
def _check_exists(self) -> bool:
return os.path.exists(self.root) and len(os.listdir(self.root)) > 0

def download(self) -> None:
if self._check_integrity():
raise RuntimeError(
f"The directory {self.root} already exists. "
f"If you want to re-download or re-extract the images, delete the directory."
)
if self._check_exists():
return

base_root = os.path.dirname(self.root)

Expand Down
5 changes: 1 addition & 4 deletions torchvision/datasets/kinetics.py
Original file line number Diff line number Diff line change
Expand Up @@ -166,10 +166,7 @@ def _download_videos(self) -> None:
RuntimeError: if download folder exists, break to prevent downloading entire dataset again.
"""
if path.exists(self.split_folder):
raise RuntimeError(
f"The directory {self.split_folder} already exists. "
f"If you want to re-download or re-extract the images, delete the directory."
)
return
tar_path = path.join(self.root, "tars")
file_list_path = path.join(self.root, "files")

Expand Down
5 changes: 1 addition & 4 deletions torchvision/datasets/places365.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,10 +145,7 @@ def download_devkit(self) -> None:

def download_images(self) -> None:
if path.exists(self.images_dir):
raise RuntimeError(
f"The directory {self.images_dir} already exists. If you want to re-download or re-extract the images, "
f"delete the directory."
)
return

file, md5 = self._IMAGES_META[(self.split, self.small)]
download_and_extract_archive(urljoin(self._BASE_URL, file), self.root, md5=md5)
Expand Down
Loading