keras
keras copied to clipboard
keras.utils.get_file function: unzip directory can't be specified
- when execute the following code, the file is download successful, but it will not unzip the
stack_overflow_16k.tar.gzfile intostack_overflow_16kdirectory, it just unzip in current directory (is./). - it's right to assignment cache_subdir to
stack_overflow_16k, but by doing this the ''stack_overflow_16k.tar.gz'' file is download into the directory of ''stack_overflow_16k'', i just want the unzip files in the directory ofstack_overflow_16k. and the return file_directory will be not correct withstack_overflow_16k/stack_overflow_16k
how to solve this problem? thanks.
url = 'https://storage.googleapis.com/download.tensorflow.org/data/stack_overflow_16k.tar.gz'
dataset_dir = tf.keras.utils.get_file('stack_overflow_16k', origin=url, extract=True, cache_dir='.', cache_subdir='')
Hi @DaHui-BT ,
I am not fully understood your question. If you want to save the url content to fname such as /stack_overflow_16k/filename , you need to create stack_overflow_16k directory and provide absolute path to argumentfname.
Or try dataset_dir = tf.keras.utils.get_file('stack_overflow_16k', origin=url, extract=True, cache_dir='.', cache_subdir='stack_overflow_16k') also seems works for your requirement.
Thanks for your help, by using your code is work, it should take two steps, and you shoule specific the path which you want to load the unzip dataset.
My mean is that, when run the following code, the variable dataset_dir value is ./stack_overflow_16k, but the stack_overflow_16k.tar.gz file is download in current directory (./) and then unzip in current directory. By using extract=True parameter it will unzip automaticly.
I guess the zip file may have different zip choice. I can finish the work, but it will have a little bit steps, Thanks😊
url = 'https://storage.googleapis.com/download.tensorflow.org/data/stack_overflow_16k.tar.gz'
dataset_dir = tf.keras.utils.get_file('stack_overflow_16k', origin=url, extract=True, cache_dir='.', cache_subdir='')
The file directory after run the code, you can see the dataset_dir variable is not match:
---work
|----train
|----test
after run then code, what i want is the follows:
---work
|----stack_overflow_16k
|----train
|----test
Hi @DaHui-BT ,
I guess the zip file may have different zip choice. I can finish the work, but it will have a little bit steps, Thanks😊
Please feel free to raise a PR if you want ? Thanks!
This issue is stale because it has been open for 14 days with no activity. It will be closed if no further activity occurs. Thank you.
This issue was closed because it has been inactive for 28 days. Please reopen if you'd like to work on this further.