kaggle比赛--Dog Breed Identification狗狗品种识别大赛
对截止至2020.8.1的top5方案进行总结归纳
比赛链接:dog-breed-identification
1、数据形式
2、top1总结
3、top2总结
4、top3总结
……
1、数据形式
120个类别,训练集共10222张图片,测试集10357张
具体:train和test根目录下为图片,labels为每个图片对应label,sample_submission为测试集和最终给出的csv格式范例。具体如下
import pandas as pd
labelfile = os.path.join(dirname,'labels.csv')
dataf = pd.read_csv(labelfile)
print('csv文件长度:', len(dataf))
dataf
# 载入测试集
df2 = pd.read_csv(dirname + 'sample_submission.csv')
df2.head()
2、top1方案总结
top1传送门
方案:
1、使用4个提取特征器提取特征(fc层之前的特征)
2、将特征融合
3、使用简单的cnn网络,包括dense层和dropout层进行训练
没有使用数据增强
结果:验证集最高为0.9413,loss最低为0.1982。
# 提取特征网络
def get_features(model_name, data_preprocessor, input_size, data):'''1- Create a feature extractor to extract features from the data.2- Returns the extracted features and the feature extractor.'''#Prepare pipeline.input_layer = Input(input_size)preprocessor = Lambda(data_preprocessor)(input_layer)base_model = model_name(weights='imagenet', include_top=False,input_shape=input_size)(preprocessor)avg = GlobalAveragePooling2D()(base_model)feature_extractor = Model(inputs = input_layer, outputs = avg)#Extract feature.feature_maps = feature_extractor.predict(data, batch_size=64, verbose=1)print('Feature maps shape: ', feature_maps.shape)return feature_maps# 使用# Extract features using InceptionV3 as extractor.
from keras.applications.inception_v3 import InceptionV3, preprocess_input
inception_preprocessor = preprocess_input
inception_features = get_features(InceptionV3,inception_preprocessor,img_size, X)
...
# 依次提取了InceptionV3、xception、NASNetLarge 、InceptionResNetV2 四个网络特征
# 将特征concate在一起,大小为(10222、9664)
final_features = np.concatenate([inception_features,xception_features,nasnet_features,inc_resnet_features,], axis=-1)
print('Final feature maps shape', final_features.shape)
#Prepare DNN model
dnn = keras.models.Sequential([InputLayer(final_features.shape[1:]),Dropout(0.7),Dense(n_classes, activation='softmax')
])dnn.compile(optimizer='adam',loss='categorical_crossentropy',metrics=['accuracy'])
注意:测试时也同样需要提取并concate特征后再predict
3、top2方案总结
top2传送门
方案:和上面一样,只不过换了提取特征网络为InceptionV3、xception、NASNetLarge、InceptionResNetV2
4、top3方案总结
top3传送门
受到欺骗,方案和上面一样
5、top4方案总结
top4传送门
1、数据预处理及数据增强
2、构建模型:在InceptionResNetV2基础上,去除原fc层,pool后添加三层fc层
结果:train_acc=75.623%, train_loss=0.87319,val_acc=89.232%, val_loss=0.09762
norm_factor = 1 / 255#
# Augmentation Ranges
transform_params = {'featurewise_center': False,'featurewise_std_normalization': False,'samplewise_center': False,'samplewise_std_normalization': False,'rotation_range': 30, 'width_shift_range': 0.15,'height_shift_range': 0.15,'horizontal_flip': True,'rescale': norm_factor
}# the generator used for training - gives augmented images
img_gen = ImageDataGenerator(**transform_params)
值得借鉴的代码:将数据增强后的数据plot出来,及写一个plotter的class,将每个epoch的loss、acc等描绘出来
# a Fully connected layer with activation, batchnorm and dropout
def dense_block(x, neurons, layer_no):x = Dense(neurons, kernel_initializer=he_normal(layer_no), name=f'topDense{layer_no}')(x)x = Activation('relu', name=f'Relu{layer_no}')(x)x = BatchNormalization(name=f'BatchNorm{layer_no}')(x)x = Dropout(0.5, name=f'Dropout{layer_no}')(x)return xdef create_model(shape):input_layer = Input(shape, name='input_layer') # input layer with given shape# load InceptionResNetV2 with initialized weights and remove final dense layers - frozen layersincep_res = InceptionResNetV2(include_top=False, weights='imagenet', input_tensor=input_layer)for layer in incep_res.layers:layer.trainable = False# pooling to reduce dimensionality of each feature mappool = MaxPooling2D(pool_size=[3, 3], strides=[3, 3], padding='same')(incep_res.output)flat1 = Flatten(name='Flatten1')(pool)flat1_bn = BatchNormalization(name='BatchNormFlat')(flat1)# dense layers after the InceptionResNetV2 initialized layersdens1 = dense_block(flat1_bn, neurons=512, layer_no=1)dens2 = dense_block(dens1, neurons=512, layer_no=2)dens3 = dense_block(dens2, neurons=1024, layer_no=3)dens_final = Dense(classes_num, name='Dense4')(dens3)output_layer = Activation('softmax', name='Softmax')(dens_final)model = Model(inputs=[input_layer], outputs=[output_layer])return model
6、top5方案总结
top5传送门
使用fastai,resnet101网络及预训练
1、resnet101 baseline,acc为0.869
2、precompute+data augmentation, acc为0.889
3、扩大输入尺寸,acc为0.891
kaggle比赛--Dog Breed Identification狗狗品种识别大赛相关推荐
- 玩转Kaggle:Dog Breed Identification【识别狗的类别】
文章目录 1. Kaggle数据集介绍 2. 下载数据和数据整理(kaggle官网即可) 3. 图像增广 4. 加载数据 5.微调模型 6.可视化validation数据 7. 输出测试结果并提交ka ...
- 动手学深度学习Kaggle:图像分类 (CIFAR-10和Dog Breed Identification), StratifiedShuffleSplit,数据集划分
目录 CIFAR-10 获取并组织数据集 下载数据集 整理数据集 组织数据集更一般的方式 图像增广 读取数据集 torchvision.datasets.ImageFolder()的特点 定义模型 定 ...
- 【深度学习入门】基于 ResNet50 的狗狗品种识别
基于 ResNet50 的狗狗品种识别 1. 效果预览: 2. ResNet算法详解: 2.1 论文地址: 2.2 核心思想: 2.3 网络结构: 2.3.1 残差单元: 2.3.2 改进单元: 2. ...
- Kaggle: ImageNet Dog Breed Classification (Pytorch)
本文为自学碰壁的完成任务的一个记录总结,无任何参考价值 写在前面:本文章是跟着<动手深度学习>(李沐)学习过程中的动手实操,前因是对一个树叶数据集分类,但是由于自己太小白(太菜了)折腾了两 ...
- 比赛记录——记录一次失败的比赛,九坤量化验证码识别大赛
过日子不记录,就是对自己人生的极大不负责任! 逛吃逛吃小队完成的题目是type1,但是在初期拿到数据集时候,也尝试构建了其他几个任务的数据集.关于type1,因为所处理的是手写字符,所以采用的方案是使 ...
- Kaggle上的狗品种识别(ImageNet Dogs)
Kaggle上的狗品种识别(ImageNet Dogs) 在本节中,我们将解决Kaggle竞赛中的犬种识别挑战,比赛的网址是https://www.kaggle.com/c/dog-breed-ide ...
- 【Kaggle项目实战记录】狗的品种识别
文章目录 1 查看原数据 2 数据预处理,建立Dataset 设定图像增广的方法 创建数据集Dataset类 预览训练集和验证集 3 定义和初始化模型 4 设置训练集和测试集 5 训练 6 模型存储 ...
- python狗品种识别_狗品种识别
Kaggle竞赛中的犬种识别挑战,比赛的网址是https://www.kaggle.com/c/dog-breed-identification 在这项比赛中,尝试确定120种不同的狗.该比赛中使用的 ...
- python狗品种识别_kaggle之本地运行识别狗品种
在搭建了深度学习环境后,第一件事就是试试行不行,最简单的当然是使用已经训练好的模型拿来预测新样本了.这里我们使用kaggle上面训练好的狗狗品种预测模型进行使用说明.(后面有完整的数据和脚本,下载到本 ...
最新文章
- 常用的数据结构-散列表
- [转]SQL Server 2005链接字符串
- flex 单独一行_Flex网页布局一CSS弹性伸缩盒子语法教程
- 李开复:AI进入落地期,单凭科学家颠覆行业的机会几乎不存在,这个领域除外...
- win10下使用wget
- JAVA开发常用类(一)
- query string parameters什么意思_public static void main(String[] args) 是什么意思?(转)...
- 使用 Exceptionless 作为 Log Server 搭配 NLog 记录系统日志
- iphone固件降级_我在iPhone上装了个安卓
- SpringBoot学习笔记(8):事物处理
- python线程的学习
- MyBatis框架generatorSqlmapCustom自动生成及下载方法
- 初探Java8中的HashMap(转)
- 多元统计分析最短距离法_多元统计分析复习整理
- 赤兔AVI视频恢复软件找回永久删除的avi视频
- 基于EEMD和樽海鞘算法优化SVM的滚动轴承故障诊断python
- 现代ADC中采样率往往远低于输入信号带宽
- python笔记-爬取豆瓣Top250排行
- apache的IO包中的FileUtils方法的使用
- 好用的数据恢复软件,误删不再怕