AttributeError: module 'keras.utils' has no attribute 'get_file' using classification_models.keras
AttributeError: module 'keras.utils' has no attribute 'get_file' using classification_models.keras
当我尝试在我的计算机或 Google Colab 上 运行 下面的简单代码片段时:
from classification_models.keras import Classifiers
ResNet18, preprocess_input = Classifiers.get('resnet18')
resnet = ResNet18((170, 170, 3), weights='imagenet', include_top=False)
我收到以下错误:
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'
知道为什么吗?提前致谢!
好像是最新的issue包。
然而,在这个 documentation 中,它表示如果您不提供任何文件路径,weights
默认为 imagenet
。因此,您可以尝试删除该参数,它应该可以工作。请尝试:
from classification_models.keras import Classifiers
ResNet18, preprocess_input = Classifiers.get('resnet18')
resnet = ResNet18((170, 170, 3), include_top=False)
当我尝试在我的计算机或 Google Colab 上 运行 下面的简单代码片段时:
from classification_models.keras import Classifiers
ResNet18, preprocess_input = Classifiers.get('resnet18')
resnet = ResNet18((170, 170, 3), weights='imagenet', include_top=False)
我收到以下错误:
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'
知道为什么吗?提前致谢!
好像是最新的issue包。
然而,在这个 documentation 中,它表示如果您不提供任何文件路径,weights
默认为 imagenet
。因此,您可以尝试删除该参数,它应该可以工作。请尝试:
from classification_models.keras import Classifiers
ResNet18, preprocess_input = Classifiers.get('resnet18')
resnet = ResNet18((170, 170, 3), include_top=False)