Error in importing Cats-vs-Dogs dataset in Google Colab

Viewed 1771

While trying to download the "Cats_vs_Dogs" TensorFlow dataset using the tfds module, I get the following error

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.

The code I have used is

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

It worked yesterday but suddenly gave an error today.......

4 Answers

You can add this before loading to set the new 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")

Here is a temporary solution that worked for me, Add below line with 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,
)

It is indicated That 'DownloadError'. It is probably about your internet connection or you had reached the limit of download of a day on Google Colab.

Related