Skip to content

Commit 8ccf263

Browse files
committed
remove printing info in datasets
ghstack-source-id: baa1395 Pull Request resolved: pytorch/vision#8686
1 parent f68bac9 commit 8ccf263

File tree

6 files changed

+7
-25
lines changed

6 files changed

+7
-25
lines changed

torchvision/datasets/_stereo_matching.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -588,7 +588,6 @@ def _download_dataset(self, root: Union[str, Path]) -> None:
588588
for calibration in ["perfect", "imperfect"]:
589589
scene_name = f"{split_scene}-{calibration}"
590590
scene_url = f"{base_url}/{scene_name}.zip"
591-
print(f"Downloading {scene_url}")
592591
# download the scene only if it doesn't exist
593592
if not (split_root / scene_name).exists():
594593
download_and_extract_archive(

torchvision/datasets/inaturalist.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -239,4 +239,3 @@ def download(self) -> None:
239239
if not os.path.exists(orig_dir_name):
240240
raise RuntimeError(f"Unable to find downloaded files at {orig_dir_name}")
241241
os.rename(orig_dir_name, self.root)
242-
print(f"Dataset version '{self.version}' has been downloaded and prepared for use")

torchvision/datasets/kinetics.py

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import csv
22
import os
3-
import time
43
import urllib
54
from functools import partial
65
from multiprocessing import Pool
@@ -121,7 +120,6 @@ def __init__(
121120
self._legacy = _legacy
122121

123122
if _legacy:
124-
print("Using legacy structure")
125123
self.split_folder = root
126124
self.split = "unknown"
127125
output_format = "THWC"
@@ -157,14 +155,8 @@ def __init__(
157155

158156
def download_and_process_videos(self) -> None:
159157
"""Downloads all the videos to the _root_ folder in the expected format."""
160-
tic = time.time()
161158
self._download_videos()
162-
toc = time.time()
163-
print("Elapsed time for downloading in mins ", (toc - tic) / 60)
164159
self._make_ds_structure()
165-
toc2 = time.time()
166-
print("Elapsed time for processing in mins ", (toc2 - toc) / 60)
167-
print("Elapsed time overall in mins ", (toc2 - tic) / 60)
168160

169161
def _download_videos(self) -> None:
170162
"""download tarballs containing the video to "tars" folder and extract them into the _split_ folder where

torchvision/datasets/mnist.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -181,19 +181,20 @@ def download(self) -> None:
181181

182182
# download files
183183
for filename, md5 in self.resources:
184+
errors = []
184185
for mirror in self.mirrors:
185186
url = f"{mirror}{filename}"
186187
try:
187-
print(f"Downloading {url}")
188188
download_and_extract_archive(url, download_root=self.raw_folder, filename=filename, md5=md5)
189-
except URLError as error:
190-
print(f"Failed to download (trying next):\n{error}")
189+
except URLError as e:
190+
errors.append(e)
191191
continue
192-
finally:
193-
print()
194192
break
195193
else:
196-
raise RuntimeError(f"Error downloading {filename}")
194+
s = f"Error downloading {filename}:\n"
195+
for mirror, e in zip(self.mirrors, errors):
196+
s += f"Tried {mirror}, got:\n{str(e)}\n"
197+
raise RuntimeError(s)
197198

198199
def extra_repr(self) -> str:
199200
split = "Train" if self.train is True else "Test"

torchvision/datasets/phototour.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,6 @@ def _check_downloaded(self) -> bool:
145145

146146
def download(self) -> None:
147147
if self._check_datafile_exists():
148-
print(f"# Found cached data {self.data_file}")
149148
return
150149

151150
if not self._check_downloaded():
@@ -157,8 +156,6 @@ def download(self) -> None:
157156

158157
download_url(url, self.root, filename, md5)
159158

160-
print(f"# Extracting data {self.data_down}\n")
161-
162159
import zipfile
163160

164161
with zipfile.ZipFile(fpath, "r") as z:
@@ -168,7 +165,6 @@ def download(self) -> None:
168165

169166
def cache(self) -> None:
170167
# process and save as torch files
171-
print(f"# Caching data {self.data_file}")
172168

173169
dataset = (
174170
read_image_file(self.data_dir, self.image_ext, self.lens[self.name]),

torchvision/datasets/utils.py

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,6 @@ def download_url(
112112

113113
# check if file is already present locally
114114
if check_integrity(fpath, md5):
115-
print("Using downloaded and verified file: " + fpath)
116115
return
117116

118117
if _is_remote_location_available():
@@ -128,12 +127,10 @@ def download_url(
128127

129128
# download the file
130129
try:
131-
print("Downloading " + url + " to " + fpath)
132130
_urlretrieve(url, fpath)
133131
except (urllib.error.URLError, OSError) as e: # type: ignore[attr-defined]
134132
if url[:5] == "https":
135133
url = url.replace("https:", "http:")
136-
print("Failed download. Trying https -> http instead. Downloading " + url + " to " + fpath)
137134
_urlretrieve(url, fpath)
138135
else:
139136
raise e
@@ -204,7 +201,6 @@ def download_file_from_google_drive(
204201
os.makedirs(root, exist_ok=True)
205202

206203
if check_integrity(fpath, md5):
207-
print(f"Using downloaded {'and verified ' if md5 else ''}file: {fpath}")
208204
return
209205

210206
gdown.download(id=file_id, output=fpath, quiet=False, user_agent=USER_AGENT)
@@ -395,7 +391,6 @@ def download_and_extract_archive(
395391
download_url(url, download_root, filename, md5)
396392

397393
archive = os.path.join(download_root, filename)
398-
print(f"Extracting {archive} to {extract_root}")
399394
extract_archive(archive, extract_root, remove_finished)
400395

401396

0 commit comments

Comments
 (0)