Quantcast
Viewing all articles
Browse latest Browse all 14243

Getting error when trying to load data using keras.utils.get_file()

I am getting an error when trying to load a dataset using TensorFlow Keras. Here is the code:

dataset_url = "https://storage.googleapis.com/sample_org/sample_file.zip"data_dir = tf.keras.utils.get_file(origin=dataset_url,                                    fname='sample_file',                                    extract=True)data_dir = pathlib.Path(data_dir)

I have changed the URL to 'sample_file.zip' for security reasons.

This is the error that I am getting:

---------------------------------------------------------------------------FileExistsError                           Traceback (most recent call last)<ipython-input-12-1cdc186b0389> in <module>()      2 data_dir = tf.keras.utils.get_file(origin=dataset_url,       3                                    fname='sample_file',----> 4                                    extract=True)      5 data_dir = pathlib.Path(data_dir)3 frames/usr/lib/python3.6/zipfile.py in _extract_member(self, member, targetpath, pwd)   1572         if member.is_dir():   1573             if not os.path.isdir(targetpath):-> 1574                 os.mkdir(targetpath)   1575             return targetpath   1576 FileExistsError: [Errno 17] File exists: '/root/.keras/datasets/sample_file'

What is causing this error? How can I fix it?

This is the first block of code run after imports so I don't know why 'FileExistsError' happens.

I have tried changing the name of the file.

I have checked TensorFlow documentation and it uses code like this:

dataset_url = "https://storage.googleapis.com/download.tensorflow.org/example_images/flower_photos.tgz"data_dir = tf.keras.utils.get_file(origin=dataset_url,                                    fname='flower_photos',                                    untar=True)data_dir = pathlib.Path(data_dir)

I have run this above code and it is working. But I cannot figure out why the same code is showing error for my data. Please advice.


Viewing all articles
Browse latest Browse all 14243

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>