尝试使用
tfds
模块下载“Cats_vs_Dogs”TensorFlow 数据集时,出现以下错误 👇
DownloadError Traceback (most recent call last)
<ipython-input-2-244305a07c33> in <module>()
7 split=['train[:80%]', 'train[80%:90%]', 'train[90%:]'],
8 with_info=True,
----> 9 as_supervised=True,
10 )
21 frames
/usr/local/lib/python3.7/dist-packages/tensorflow_datasets/core/download/downloader.py in _assert_status(response)
257 if response.status_code != 200:
258 raise DownloadError('Failed to get url {}. HTTP code: {}.'.format(
--> 259 response.url, response.status_code))
DownloadError: Failed to get url https://download.microsoft.com/download/3/E/1/3E1C3F21-ECDB-4869-8368-6DEBA77B919F/kagglecatsanddogs_3367a.zip. HTTP code: 404.
我使用的代码是
import tensorflow_datasets as tfds
tfds.disable_progress_bar()
# split the data manually into 80% training, 10% testing, 10% validation
(raw_train, raw_validation, raw_test), metadata = tfds.load(
'cats_vs_dogs',
split=['train[:80%]', 'train[80%:90%]', 'train[90%:]'],
with_info=True,
as_supervised=True,
)
昨天还可以,今天突然出错了......
您可以在加载之前添加此内容以设置新 URL :
setattr(tfds.image_classification.cats_vs_dogs, '_URL',"https://download.microsoft.com/download/3/E/1/3E1C3F21-ECDB-4869-8368-6DEBA77B919F/kagglecatsanddogs_5340.zip")
这是一个对我有用的临时解决方案,在下面添加带有 url 的行
#Added code
setattr(tfds.image_classification.cats_vs_dogs, '_URL',"https://download.microsoft.com/download/3/E/1/3E1C3F21-ECDB-4869-8368-6DEBA77B919F/kagglecatsanddogs_5340.zip")
#Initial code that failed with the error
(train_examples, validation_examples), info = tfds.load(
'cats_vs_dogs',
split=['train[:80%]', 'train[80%:]'],
with_info=True,
as_supervised=True,
)
#Complete code together
setattr(tfds.image_classification.cats_vs_dogs, '_URL',"https://download.microsoft.com/download/3/E/1/3E1C3F21-ECDB-4869-8368-6DEBA77B919F/kagglecatsanddogs_5340.zip")
(train_examples, validation_examples), info = tfds.load(
'cats_vs_dogs',
split=['train[:80%]', 'train[80%:]'],
with_info=True,
as_supervised=True,
)
只需更新已安装的
tensorflow_datasets
软件包即可。
提示“DownloadError”。这可能与您的互联网连接有关,或者您已达到 Google Colab 一天的下载限制。