Updating get_file() to respect the KERAS_HOME environment variable if set by a user for download caching directory location
@@ -86,6 +86,7 @@ if True: # This gets transformed to `if sys.version_info[0] == 2:` in OSS.
for chunk in chunk_read(response, reporthook=reporthook):
fd.write(chunk)
+
else:
from urllib.request import urlretrieve
@@ -220,6 +221,9 @@ def get_file(
)
if cache_dir is None:
+ if "KERAS_HOME" in os.environ:
+ cache_dir = os.environ.get("KERAS_HOME")
+ else:
cache_dir = os.path.join(os.path.expanduser("~"), ".keras")
if md5_hash is not None and file_hash is None:
file_hash = md5_hash
