Skip to content

Commit 4eb5ab9

Browse files
YosuaMichaelpmeier
authored andcommitted
[fbsync] Deactivate CelebA download (#6052)
Summary: * Deactivate CelebA download * flake8 * Do proto version * Update torchvision/prototype/datasets/utils/_resource.py * address review Reviewed By: NicolasHug Differential Revision: D36760933 fbshipit-source-id: 8efe44df2ab94c66b239199e89bbe2ecc171ed84 Co-authored-by: Philip Meier <[email protected]> Co-authored-by: Philip Meier <[email protected]>
1 parent b0e78aa commit 4eb5ab9

File tree

3 files changed

+35
-24
lines changed

3 files changed

+35
-24
lines changed

torchvision/datasets/celeba.py

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
import PIL
77
import torch
88

9-
from .utils import download_file_from_google_drive, check_integrity, verify_str_arg, extract_archive
9+
from .utils import check_integrity, verify_str_arg
1010
from .vision import VisionDataset
1111

1212
CSV = namedtuple("CSV", ["header", "index", "data"])
@@ -35,9 +35,16 @@ class CelebA(VisionDataset):
3535
and returns a transformed version. E.g, ``transforms.PILToTensor``
3636
target_transform (callable, optional): A function/transform that takes in the
3737
target and transforms it.
38-
download (bool, optional): If true, downloads the dataset from the internet and
39-
puts it in root directory. If dataset is already downloaded, it is not
40-
downloaded again.
38+
download (bool, optional): Unsupported.
39+
40+
.. warning::
41+
42+
Downloading CelebA is not supported anymore as of 0.13. See
43+
`this issue <https://github.com/pytorch/vision/issues/5705>`__
44+
for more details.
45+
Please download the files from
46+
https://mmlab.ie.cuhk.edu.hk/projects/CelebA.html and extract
47+
them in ``root/celeba``.
4148
"""
4249

4350
base_folder = "celeba"
@@ -146,10 +153,13 @@ def download(self) -> None:
146153
print("Files already downloaded and verified")
147154
return
148155

149-
for (file_id, md5, filename) in self.file_list:
150-
download_file_from_google_drive(file_id, os.path.join(self.root, self.base_folder), filename, md5)
151-
152-
extract_archive(os.path.join(self.root, self.base_folder, "img_align_celeba.zip"))
156+
raise ValueError(
157+
"Downloading CelebA is not supported anymore as of 0.13. See "
158+
"https://github.com/pytorch/vision/issues/5705 for more details. "
159+
"Please download the files from "
160+
"https://mmlab.ie.cuhk.edu.hk/projects/CelebA.html and extract them "
161+
"in ``root/celeba``."
162+
)
153163

154164
def __getitem__(self, index: int) -> Tuple[Any, Any]:
155165
X = PIL.Image.open(os.path.join(self.root, self.base_folder, "img_align_celeba", self.filename[index]))

torchvision/prototype/datasets/_builtin/celeba.py

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
)
1212
from torchvision.prototype.datasets.utils import (
1313
Dataset,
14-
GDriveResource,
14+
ManualDownloadResource,
1515
OnlineResource,
1616
)
1717
from torchvision.prototype.datasets.utils._internal import (
@@ -85,33 +85,34 @@ def __init__(
8585
super().__init__(root, skip_integrity_check=skip_integrity_check)
8686

8787
def _resources(self) -> List[OnlineResource]:
88-
splits = GDriveResource(
89-
"0B7EVK8r0v71pY0NSMzRuSXJEVkk",
88+
instructions = "Please download the file from https://mmlab.ie.cuhk.edu.hk/projects/CelebA.html."
89+
splits = ManualDownloadResource(
90+
instructions=instructions,
9091
sha256="fc955bcb3ef8fbdf7d5640d9a8693a8431b5f2ee291a5c1449a1549e7e073fe7",
9192
file_name="list_eval_partition.txt",
9293
)
93-
images = GDriveResource(
94-
"0B7EVK8r0v71pZjFTYXZWM3FlRnM",
94+
images = ManualDownloadResource(
95+
instructions=instructions,
9596
sha256="46fb89443c578308acf364d7d379fe1b9efb793042c0af734b6112e4fd3a8c74",
9697
file_name="img_align_celeba.zip",
9798
)
98-
identities = GDriveResource(
99-
"1_ee_0u7vcNLOfNLegJRHmolfH5ICW-XS",
99+
identities = ManualDownloadResource(
100+
instructions=instructions,
100101
sha256="c6143857c3e2630ac2da9f782e9c1232e5e59be993a9d44e8a7916c78a6158c0",
101102
file_name="identity_CelebA.txt",
102103
)
103-
attributes = GDriveResource(
104-
"0B7EVK8r0v71pblRyaVFSWGxPY0U",
104+
attributes = ManualDownloadResource(
105+
instructions=instructions,
105106
sha256="f0e5da289d5ccf75ffe8811132694922b60f2af59256ed362afa03fefba324d0",
106107
file_name="list_attr_celeba.txt",
107108
)
108-
bounding_boxes = GDriveResource(
109-
"0B7EVK8r0v71pbThiMVRxWXZ4dU0",
109+
bounding_boxes = ManualDownloadResource(
110+
instructions=instructions,
110111
sha256="7487a82e57c4bb956c5445ae2df4a91ffa717e903c5fa22874ede0820c8ec41b",
111112
file_name="list_bbox_celeba.txt",
112113
)
113-
landmarks = GDriveResource(
114-
"0B7EVK8r0v71pd0FJY3Blby1HUTQ",
114+
landmarks = ManualDownloadResource(
115+
instructions=instructions,
115116
sha256="6c02a87569907f6db2ba99019085697596730e8129f67a3d61659f198c48d43b",
116117
file_name="list_landmarks_align_celeba.txt",
117118
)

torchvision/prototype/datasets/utils/_resource.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -216,9 +216,9 @@ def __init__(self, instructions: str, **kwargs: Any) -> None:
216216

217217
def _download(self, root: pathlib.Path) -> NoReturn:
218218
raise RuntimeError(
219-
f"The file {self.file_name} cannot be downloaded automatically. "
220-
f"Please follow the instructions below and place it in {root}\n\n"
221-
f"{self.instructions}"
219+
f"The file {self.file_name} was not found, and cannot be downloaded automatically.\n\n"
220+
f"{self.instructions.strip()}\n\n"
221+
f"Once it is downloaded, please place the file in {root}."
222222
)
223223

224224

0 commit comments

Comments
 (0)