预测:无法在系统权重中加载模型“ VGG16 model.h5”

问题描述 投票:0回答:1

负载模型

model.load_weights(VGG16(include_top = False,weights ='imagenet'))


    VGG16=load_model('E:/TBirds/TBirdDOCS/PythonCode/DOCMODEL/vgg16_weights_tf_dim_ordering_tf_kernels_notop.h5')

    # build the VGG16 network
    #model = application.VGG16(include_top=False, weights='imagenet')
    model.load_weights(VGG16(include_top=False, weights='imagenet'))
    # get the bottleneck prediction from the pre-trained VGG16 model
    bottleneck_prediction = model.predict(image)
    #print(bottleneck_prediction)

ValueError:无法以只读模式创建组。

Traceback (most recent call last):
  File "C:/Users/Administrator.SQL6/AppData/Roaming/Python/Python36/site-packages/keras/engine/Auto-AI.py", line 254, in <module>
    main()
  File "C:/Users/Administrator.SQL6/AppData/Roaming/Python/Python36/site-packages/keras/engine/Auto-AI.py", line 244, in main
    prediction_And_Bookmark(writer, Total_Number_of_Pages, pdf_source,File_Name)
  File "C:/Users/Administrator.SQL6/AppData/Roaming/Python/Python36/site-packages/keras/engine/Auto-AI.py", line 189, in prediction_And_Bookmark
    layb, count, pos = predict(test_imag)
  File "C:/Users/Administrator.SQL6/AppData/Roaming/Python/Python36/site-packages/keras/engine/Auto-AI.py", line 97, in predict
    VGG16=load_model('E:/TBirds/TBirdDOCS/PythonCode/DOCMODEL/vgg16_weights_tf_dim_ordering_tf_kernels_notop.h5')
  File "C:\Users\Administrator.SQL6\AppData\Roaming\Python\Python36\site-packages\keras\engine\saving.py", line 492, in load_wrapper
    return load_function(*args, **kwargs)
  File "C:\Users\Administrator.SQL6\AppData\Roaming\Python\Python36\site-packages\keras\engine\saving.py", line 584, in load_model
    model = _deserialize_model(h5dict, custom_objects, compile)
  File "C:\Users\Administrator.SQL6\AppData\Roaming\Python\Python36\site-packages\keras\engine\saving.py", line 270, in _deserialize_model
    model_config = h5dict['model_config']
  File "C:\Users\Administrator.SQL6\AppData\Roaming\Python\Python36\site-packages\keras\utils\io_utils.py", line 318, in __getitem__
    raise ValueError('Cannot create group in read-only mode.')
ValueError: Cannot create group in read-only mode.

Process finished with exit code 1

ValueError:无法以只读模式创建组。

python tensorflow keras pycharm h5py
1个回答
0
投票

[如果您分别保存了权重和体系结构,并且尝试使用model.load_weights('model_weights.h5')单独加载权重,您会收到此错误。

© www.soinside.com 2019 - 2024. All rights reserved.