迁移学习之DenseNet121(121层),DenseNet169(169层),DenseNet201(201层)(图像识别)
文章目录
- 1.实现效果:
- 2.结果分析:
- 3.主文件TransorDenseNet.py:
1.实现效果:
实际图片:
(1)DenseNet121预测第一个结果为:Sealyham_terrier(㹴犬)——0.21411328
(2)DenseNet169预测的第一个结果为:Sealyham_terrier(㹴犬)——0.43225577
(3)DenseNet201预测第一个结果为:Sealyham_terrier(㹴犬)——0.15977885
2.结果分析:
相比于之前的ResNet50,ResNet101,MobileNet,MobileNetV2,InceptionV3,Xception,Inception_ResNet_V2其中DenseNet169预测结果是最好的,也是正确的,虽然DenseNet121预测准确率不是很高,但是结果是正确的;但是呢!这个DenseNet121,169相比之前的ResNet50要多了很多的层,所以计算量更大,如果是自己也加了数据集进行训练的话,计算量将更大,所以折中的选择是ResNet50.
关于ResNet50和ResNet101:
https://mydreamambitious.blog.csdn.net/article/details/123906833
关于VGG16和VGG19:
https://mydreamambitious.blog.csdn.net/article/details/123906643
关于InceptionV3(159层),Xception(126层),Inception_ResNet_V2(572层):
https://mydreamambitious.blog.csdn.net/article/details/123907490
关于MobileNet(88层)和MobileNetV2(88层):
https://mydreamambitious.blog.csdn.net/article/details/123907955
EfficientNetBX
https://mydreamambitious.blog.csdn.net/article/details/123929264
3.主文件TransorDenseNet.py:
import os
import cv2
import tensorflow
import numpy as np
from PIL import Image
from tensorflow import keras
from tensorflow.keras.preprocessing import image
from tensorflow.keras.preprocessing.image import img_to_array
from tensorflow.keras.applications.inception_v3 import preprocess_input,decode_predictionsdef load_DenseNet121():model_DenseNet=tensorflow.keras.applications.densenet.DenseNet121(weights='imagenet')#图形路径curr_path=os.getcwd()img_path=curr_path+'\\images\\train\\dog\\1.jpg'#将图像转换为网络需要的大小,因为我们这里加载的模型都是固定输入大小224*224img=image.load_img(img_path,target_size=(224,224))#首先需要转换为向量的形式img_out=image.img_to_array(img)#扩充维度img_out=np.expand_dims(img_out,axis=0)#对输入的图像进行处理img_out=preprocess_input(img_out)# decode the results into a list of tuples (class, description, probability)# (one such list for each sample in the batch)#上面这段话的意思是输出包括(类别,图像描述,输出概率)preds=model_DenseNet.predict(img_out)#输出前三个结果的可能性print('Predicted: ',decode_predictions(preds,top=3)[0])print('Predicted: ',decode_predictions(preds,top=3))def load_DenseNet169():model_DenseNet169 =tensorflow.keras.applications.densenet.DenseNet169(weights='imagenet')# 图形路径img_path = 'images/train/dog/1.jpg'# 将图像转换为网络需要的大小,因为我们这里加载的模型都是固定输入大小224*224img = image.load_img(img_path, target_size=(224, 224))# 首先需要转换为向量的形式img_out = image.img_to_array(img)# 扩充维度img_out = np.expand_dims(img_out, axis=0)# 对输入的图像进行处理img_out = preprocess_input(img_out)# decode the results into a list of tuples (class, description, probability)# (one such list for each sample in the batch)# 上面这段话的意思是输出包括(类别,图像描述,输出概率)preds = model_DenseNet169.predict(img_out)# 输出前三个结果的可能性print('Predicted: ', decode_predictions(preds, top=3)[0])print('Predicted: ', decode_predictions(preds, top=3))
def load_DenseNet201():model_DenseNet201 =tensorflow.keras.applications.densenet.DenseNet201(weights='imagenet')# 图形路径img_path = 'images/train/dog/1.jpg'# 将图像转换为网络需要的大小,因为我们这里加载的模型都是固定输入大小224*224img = image.load_img(img_path, target_size=(224, 224))# 首先需要转换为向量的形式img_out = image.img_to_array(img)# 扩充维度img_out = np.expand_dims(img_out, axis=0)# 对输入的图像进行处理img_out = preprocess_input(img_out)# decode the results into a list of tuples (class, description, probability)# (one such list for each sample in the batch)# 上面这段话的意思是输出包括(类别,图像描述,输出概率)preds = model_DenseNet201.predict(img_out)# 输出前三个结果的可能性print('Predicted: ', decode_predictions(preds, top=3)[0])print('Predicted: ', decode_predictions(preds, top=3))if __name__ == '__main__':print('Pycharm')print('DenseNet121: \\n')load_DenseNet121()print('DenseNet169: \\n')load_DenseNet169()print('DenseNet201: \\n')load_DenseNet201()
迁移学习之DenseNet121(121层),DenseNet169(169层),DenseNet201(201层)(图像识别)相关推荐
- 迁移学习之MobileNet(88层)和MobileNetV2(88层)
文章目录 1.实现的效果: 2.结果分析: 3.主文件TransorMobileNet.py: 1.实现的效果: 实际图片: (1)MobileNet预测的第一个结果为:pug(哈巴狗) (2)Mob ...
- 迁移学习之InceptionV3(159层),Xception(126层),Inception_ResNet_V2(572层)(图像识别)
文章目录 1.实现的效果: 2.结果分析: 3.主文件TransorInception.py: 1.实现的效果: 实际图片: (1)从上面的输出效果来看,InceptionV3预测的第一个结果为:ch ...
- 迁移学习之EfficientNetBX(图像识别)
文章目录 1.实现效果: 2.结果分析: 3.主文件:TransorEfficientNetBx.py: 1.实现效果: 实际图像: (1)EfficientNetB0预测的前三个中第一个结果:whi ...
- 迁移学习之ResNet50和ResNet101(图像识别)
文章目录 1.实现的效果: 2.主文件TransorResNet.py: 1.实现的效果: 实际的图片: (1)可以看到ResNet50预测的前三个结果中第一个结果为:whippet(小灵狗) (2) ...
- 迁移学习之VGG16和VGG19
文章目录 1.输出效果: 2.主文件TransorVGG16AndVGG19.py: 1.输出效果: 实际的图片--Dog: 预测的结果有误.但是没关系,自己可以找一些数据集,在此模型的基础上进行微调 ...
- 【神经网络】(7) 迁移学习(CNN-MobileNetV2),案例:乳腺癌二分类
各位同学好,今天和大家分享一下Tensorflow2.0中如何使用迁移学习的方法构造神经网络.需要数据集的在评论区留个言. 1. 迁移学习 官方文档:Module: tf.keras.applicat ...
- 基于迁移学习的反欺诈方法研究
迁移学习(Transfer learning),顾名思义,就是把已知学到的知识应用于理解未知事物上,这很符合我们的认知过程.举个最简单的例子,假设我们给朋友介绍一种新产品,就叫"奇里古刹币& ...
- 《基于卷积神经网络的深度迁移学习,用于燃气轮机燃烧室的故障检测》论文阅读
目录 突出 抽象 引言 1.1动机 1.2文献综述获得的结论 1.3贡献 1.4组织 2方法 2.1燃汽轮机组故障知识共享 2.2迁移学习 2.3 基于卷积神经网络的深度迁移学习 2.4用于燃气轮机燃 ...
- 基于MATLAB的Alexnet迁移学习进行猫狗分类(数据集:Kaggle)
基本介绍 软件:Matlab R2018b 数据集:Kaggle猫狗数据集 网络:AlexNet 前期准备 数据集 Kaggle猫狗数据集猫与狗用于训练的图片(train)分别12500张,每张图片的 ...
最新文章
- Android中View如何刷新
- 系统制成docker镜像_docker 制作自己的镜像
- 前端学习(3192):react第一个案例
- C#测量程序运行时间及cpu使用时间(转)
- leetcode python3 简单题70. Climbing Stairs
- Java中HttpURLConnection使用代理服务器
- Notepad2添加到右键菜单栏
- c语言入门编程题库100题,C语言入门100题
- AVI视频怎么转换成MOV视频
- vue实现点击图片放大显示功能
- 如果域名被劫持该怎么办?有什么应对方法?
- TestBird成为全球最大手游测试平台
- 计算机断电重启后蓝屏,电脑断电后重启屏幕出现蓝屏代码0x000000f4解决方法
- Spark的容错机制
- Google Maps Download Tool 谷歌地图下载工具
- 【软件定义汽车】【操作系统篇】特斯拉–Version
- 数组10— sort() : 对数组中的元素进行排序
- 学习Pycharm使用方法(一):Pycharm中Make available to all projects的含义是什么
- Spring项目整合WebService服务遇到问题记录
- python:根据输入的身高、体重,判断体型是否标准。(计算公式:身高-105=体重)
热门文章
- Dubbo基础专题——第一章(带你认识Dubbo)
- MySQL数据库右连接查询right join ... on
- 从numpy开启Python数据科学之旅
- 2018 百越杯 pwn(Boring Game Write up)
- [c#基础]ICloneable接口
- Electron的代码调试
- python 对象拷贝
- Gartner评出2017年最值得关注的11个顶级信息安全技术
- iOS:CALayer核心动画层
- hdu1027 Ignatius and the Princess II (全排列 amp; STL中的神器)