第一步:准备数据
2种数据,即本地物种和外来入侵物种,总共有12031张图片,每个文件夹单独放一种
第二步:搭建模型
本文选择MobileNetV2,其网络结构如下:
由于是2分类问题,直接套用网络肯定是不行,因此会在改动神经网络输出类别数,参考代码如下:
x = base_model.output
x = GlobalAveragePooling2D()(x)
x = Dense(256)(x)
x = BatchNormalization()(x)
x = Activation('relu')(x)
x = Dense(64)(x)
x = BatchNormalization()(x)
x = Activation('relu')(x)
x = Dense(2)(x)
predictions = Activation('softmax')(x)
# for layer in base_model.layers:
# layer.trainable = True
model = Model(inputs=base_model.input, outputs=predictions)
return model
第三步:训练代码
1)损失函数为:交叉熵损失函数
2)MobileNetV2从进行迁移学习训练:
w = 1
if w:
base_model = MODEL(weights='imagenet', include_top=False, input_shape=(width, height, 3))
else:
base_model = MODEL(weights=None, include_top=False, input_shape=(width, height, 3))
for layer in base_model.layers:
layer.trainable = False
第四步:统计正确率
|
正确率高达94.2%
第五步:搭建GUI界面
第六步:整个工程的内容
有训练代码和训练好的模型以及训练过程,提供数据,提供GUI界面代码,主要使用方法可以参考里面的“文档说明_必看.docx”
代码的下载路径(新窗口打开链接):基于深度学习神经网络cnn的外来物种入侵识别系统源码
有问题可以私信或者留言,有问必答