简体   繁体   English

AttributeError: 模块'keras.utils' 没有使用classification_models.keras 的属性'get_file'

[英]AttributeError: module 'keras.utils' has no attribute 'get_file' using classification_models.keras

When I try to run the simple code snippet below on my computer or on Google Colab:当我尝试在我的计算机或 Google Colab 上运行下面的简单代码片段时:

from classification_models.keras import Classifiers

ResNet18, preprocess_input = Classifiers.get('resnet18')
resnet = ResNet18((170, 170, 3), weights='imagenet', include_top=False)

I get the following error:我收到以下错误:

AttributeError                            Traceback (most recent call last)
<ipython-input-4-b208d68b42cf> in <module>()
      2 
      3 ResNet18, preprocess_input = Classifiers.get('resnet18')
----> 4 resnet = ResNet18((170, 170, 3), weights='imagenet', include_top=False)

3 frames
/usr/local/lib/python3.7/dist-packages/classification_models/weights.py in load_model_weights(model, model_name, dataset, `classes`, include_top, **kwargs)
     23                              ' as true, classes should be {}'.format(weights['classes']))
     24 
---> 25         weights_path = keras_utils.get_file(
     26             weights['name'],
     27             weights['url'],

AttributeError: module 'keras.utils' has no attribute 'get_file'

Any idea why?知道为什么吗? Thank you in advance!先感谢您!

It seems to be the latest issue of the package.好像是最新一的包。 Nevertheless, in this documentation it says that weights defaults to imagenet if you do not give any path to a file.尽管如此,在本文档中,它表示如果您不提供任何文件路径,则weights默认为imagenet Therefore you could try removing that parameter and it should work.因此,您可以尝试删除该参数,它应该可以工作。 Please try:请尝试:

from classification_models.keras import Classifiers

ResNet18, preprocess_input = Classifiers.get('resnet18')
resnet = ResNet18((170, 170, 3), include_top=False)

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 AttributeError:模块'keras.utils'没有使用segmentation_models的属性'get_file' - AttributeError: module 'keras.utils' has no attribute 'get_file' using segmentation_models AttributeError:模块“keras.utils”没有属性“get_file” - AttributeError: module 'keras.utils' has no attribute 'get_file' AttributeError:模块“keras.utils”没有属性“to_categorical” - AttributeError: module 'keras.utils' has no attribute 'to_categorical' AttributeError: 模块 &#39;keras.utils&#39; 没有属性 &#39;Sequence&#39; - AttributeError: module 'keras.utils' has no attribute 'Sequence' importefficientnet.keras as efn - AttributeError: module 'keras.utils' has no attribute 'generic_utils' - import efficientnet.keras as efn - AttributeError: module 'keras.utils' has no attribute 'generic_utils' AttributeError: 模块 'keras.utils' 没有属性 'plot_model' 但安装了 Keras 和 tensorflow - AttributeError: module 'keras.utils' has no attribute 'plot_model' but installed Keras and tensorflow AttributeError:类型对象“ h5py.h5r.Reference”在使用“从keras.utils导入HDF5Matrix”时没有属性“ __reduce_cython__” - AttributeError: type object 'h5py.h5r.Reference' has no attribute '__reduce_cython__' on using “from keras.utils import HDF5Matrix” AttributeError:模块'tensorflow.python.keras.utils.generic_utils'没有属性'populate_dict_with_module_objects' - AttributeError: module 'tensorflow.python.keras.utils.generic_utils' has no attribute 'populate_dict_with_module_objects' AttributeError: 模块 'tensorflow.keras.models' 没有属性 'experimental' - AttributeError: module 'tensorflow.keras.models' has no attribute 'experimental' AttributeError:模块“keras.utils.generic_utils”没有属性“populate_dict_with_module_objects” - AttributeError: module 'keras.utils.generic_utils' has no attribute 'populate_dict_with_module_objects'
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM