Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
163 views
in Technique[技术] by (71.8m points)

python - Errno 13 Permission Denied Keras VGG16

I'm trying to load the VGG16 model from Keras to perform transfer learning,

input_shape = (224, 224, 3)
model = VGG16(weights='imagenet', include_top=False, input_shape=input_shape)

but I'm getting the following error:

Traceback (most recent call last):

  File "<ipython-input-27-898653ab5324>", line 1, in <module>
    model = VGG16(weights='imagenet', include_top=False)

  File "C:UsersjywljAppDataRoamingPythonPython37site-packagesensorflow_corepythonkerasapplications\__init__.py", line 49, in wrapper
    return base_fun(*args, **kwargs)

  File "C:UsersjywljAppDataRoamingPythonPython37site-packagesensorflow_corepythonkerasapplicationsvgg16.py", line 32, in VGG16
    return vgg16.VGG16(*args, **kwargs)

  File "C:UsersjywljAppDataRoamingPythonPython37site-packageskeras_applicationsvgg16.py", line 209, in VGG16
    file_hash='6d6bbae143d832006294945121d1f1fc')

  File "C:UsersjywljAppDataRoamingPythonPython37site-packagesensorflow_corepythonkerasutilsdata_utils.py", line 223, in get_file
    if not validate_file(fpath, file_hash, algorithm=hash_algorithm):

  File "C:UsersjywljAppDataRoamingPythonPython37site-packagesensorflow_corepythonkerasutilsdata_utils.py", line 324, in validate_file
    if str(_hash_file(fpath, hasher, chunk_size)) == str(file_hash):

  File "C:UsersjywljAppDataRoamingPythonPython37site-packagesensorflow_corepythonkerasutilsdata_utils.py", line 299, in _hash_file
    for chunk in iter(lambda: fpath_file.read(chunk_size), b''):

  File "C:UsersjywljAppDataRoamingPythonPython37site-packagesensorflow_corepythonkerasutilsdata_utils.py", line 299, in <lambda>
    for chunk in iter(lambda: fpath_file.read(chunk_size), b''):

PermissionError: [Errno 13] Permission denied

This is really strange, as loading the VGG19 network gives me no problem. Also, if I remove the "include_top" argument, the model loads successfully without throwing the error.

# This works fine
model = VGG16(weights='imagenet')

Can anyone help with this? Thanks.

question from:https://stackoverflow.com/questions/65942067/errno-13-permission-denied-keras-vgg16

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Instead of importing from keras, you can import from tensorflow.

from tensorflow.keras.applications import VGG16

This will solve your problem


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...