在 Google Colab 中导入猫狗数据集时出错

问题描述 投票:0回答:5

尝试使用

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,
)

昨天还可以,今天突然出错了......

python tensorflow dataset google-colaboratory kaggle
5个回答
12
投票

您可以在加载之前添加此内容以设置新 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")

1
投票

这是一个对我有用的临时解决方案,在下面添加带有 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,
)

0
投票

从昨天开始就失败了

https://github.com/tensorflow/datasets/issues/3918

他们似乎更改了网址并忘记了张量流数据集:-(


0
投票

只需更新已安装的

tensorflow_datasets
软件包即可。


-2
投票

提示“DownloadError”。这可能与您的互联网连接有关,或者您已达到 Google Colab 一天的下载限制。

© www.soinside.com 2019 - 2024. All rights reserved.