Keras 模型权重(repo地址:https://github.com/fchollet/deep-learning-models/releases):
ResNet
DenseNet
- densenet169_weights_tf_dim_ordering_tf_kernels.h5
- densenet201_weights_tf_dim_ordering_tf_kernels.h5
- densenet121_weights_tf_dim_ordering_tf_kernels.h5
InceptionResNetV2
MobileNet
- List item
Xception model
- List item
VGG16, VGG19
- List item
下载Flyai提供的预训练模型
- 安装flyai框架
建议使用conda环境安装,方便管理,安装时好像除了flyai还会装其他的库包括numpy,tensorflow之类。
pip install flyai
2.调用flyai的库下载模型,模型可以在这个网址上找
找到要使用的模型,点击复制使用,运行代码会自动下载,keras是下载到用户目录下的.Keras文件夹下
这里直接引用flyai网站上keras使用flyai预训练模型说明。
from keras.applications import densenet
from flyai.utils import remote_helper
path=remote_helper.get_remote_date("https://www.flyai.com/m/v0.8|densenet169_weights_tf_dim_ordering_tf_kernels_notop.h5") #参数替换为想要下载的模型地址
densenet_notop = densenet.DenseNet169(include_top=False, weights=None)
densenet_notop.load_weights(path)
# densenet_notop = densenet.DenseNet169(include_top=False, weights='imagenet')
# 这行代码与上面等同,只不过一个是调用FlyAI提供的预训练模型地址,一个是外网的地址
x = densenet_notop.output
x = GlobalAveragePooling2D()(x)
x = Dense(2048, activation='relu')(x)
predictions = Dense(200, activation='softmax')(x)
model = Model(inputs=densenet_notop.input, outputs=predictions)
model.compile(...)
model.fit_generator(...)
下载模型,只需运行remote_helper.get_remote_date()这行代码就可以了。