如果看过我之前文章的话相信对于fruits360数据集就是比较熟悉的了,我之前就已经做过了相关的项目实践了,文章如下感兴趣的话可以自行移步阅读即可:
《Fruits 360 基于CNN实现果蔬识别系统》
首先看下效果:
数据集这里简单介绍下如下所示:
一共有131个类别的数据。
训练集-测试集详情如下:
Total Train Number: 67692
Total Test Number: 22688
各类别详情如下:
训练集
{
"Apple Braeburn": 492,
"Apple Crimson Snow": 444,
"Apple Golden 1": 480,
"Apple Golden 2": 492,
"Apple Golden 3": 481,
"Apple Granny Smith": 492,
"Apple Pink Lady": 456,
"Apple Red 1": 492,
"Apple Red 2": 492,
"Apple Red 3": 429,
"Apple Red Delicious": 490,
"Apple Red Yellow 1": 492,
"Apple Red Yellow 2": 672,
"Apricot": 492,
"Avocado": 427,
"Avocado ripe": 491,
"Banana": 490,
"Banana Lady Finger": 450,
"Banana Red": 490,
"Beetroot": 450,
"Blueberry": 462,
"Cactus fruit": 490,
"Cantaloupe 1": 492,
"Cantaloupe 2": 492,
"Carambula": 490,
"Cauliflower": 702,
"Cherry 1": 492,
"Cherry 2": 738,
"Cherry Rainier": 738,
"Cherry Wax Black": 492,
"Cherry Wax Red": 492,
"Cherry Wax Yellow": 492,
"Chestnut": 450,
"Clementine": 490,
"Cocos": 490,
"Corn": 450,
"Corn Husk": 462,
"Cucumber Ripe": 392,
"Cucumber Ripe 2": 468,
"Dates": 490,
"Eggplant": 468,
"Fig": 702,
"Ginger Root": 297,
"Granadilla": 490,
"Grape Blue": 984,
"Grape Pink": 492,
"Grape White": 490,
"Grape White 2": 490,
"Grape White 3": 492,
"Grape White 4": 471,
"Grapefruit Pink": 490,
"Grapefruit White": 492,
"Guava": 490,
"Hazelnut": 464,
"Huckleberry": 490,
"Kaki": 490,
"Kiwi": 466,
"Kohlrabi": 471,
"Kumquats": 490,
"Lemon": 492,
"Lemon Meyer": 490,
"Limes": 490,
"Lychee": 490,
"Mandarine": 490,
"Mango": 490,
"Mango Red": 426,
"Mangostan": 300,
"Maracuja": 490,
"Melon Piel de Sapo": 738,
"Mulberry": 492,
"Nectarine": 492,
"Nectarine Flat": 480,
"Nut Forest": 654,
"Nut Pecan": 534,
"Onion Red": 450,
"Onion Red Peeled": 445,
"Onion White": 438,
"Orange": 479,
"Papaya": 492,
"Passion Fruit": 490,
"Peach": 492,
"Peach 2": 738,
"Peach Flat": 492,
"Pear": 492,
"Pear 2": 696,
"Pear Abate": 490,
"Pear Forelle": 702,
"Pear Kaiser": 300,
"Pear Monster": 490,
"Pear Red": 666,
"Pear Stone": 711,
"Pear Williams": 490,
"Pepino": 490,
"Pepper Green": 444,
"Pepper Orange": 702,
"Pepper Red": 666,
"Pepper Yellow": 666,
"Physalis": 492,
"Physalis with Husk": 492,
"Pineapple": 490,
"Pineapple Mini": 493,
"Pitahaya Red": 490,
"Plum": 447,
"Plum 2": 420,
"Plum 3": 900,
"Pomegranate": 492,
"Pomelo Sweetie": 450,
"Potato Red": 450,
"Potato Red Washed": 453,
"Potato Sweet": 450,
"Potato White": 450,
"Quince": 490,
"Rambutan": 492,
"Raspberry": 490,
"Redcurrant": 492,
"Salak": 490,
"Strawberry": 492,
"Strawberry Wedge": 738,
"Tamarillo": 490,
"Tangelo": 490,
"Tomato 1": 738,
"Tomato 2": 672,
"Tomato 3": 738,
"Tomato 4": 479,
"Tomato Cherry Red": 492,
"Tomato Heart": 684,
"Tomato Maroon": 367,
"Tomato not Ripened": 474,
"Tomato Yellow": 459,
"Walnut": 735,
"Watermelon": 475
}
测试集
{
"Apple Braeburn": 164,
"Apple Crimson Snow": 148,
"Apple Golden 1": 160,
"Apple Golden 2": 164,
"Apple Golden 3": 161,
"Apple Granny Smith": 164,
"Apple Pink Lady": 152,
"Apple Red 1": 164,
"Apple Red 2": 164,
"Apple Red 3": 144,
"Apple Red Delicious": 166,
"Apple Red Yellow 1": 164,
"Apple Red Yellow 2": 219,
"Apricot": 164,
"Avocado": 143,
"Avocado ripe": 166,
"Banana": 166,
"Banana Lady Finger": 152,
"Banana Red": 166,
"Beetroot": 150,
"Blueberry": 154,
"Cactus fruit": 166,
"Cantaloupe 1": 164,
"Cantaloupe 2": 164,
"Carambula": 166,
"Cauliflower": 234,
"Cherry 1": 164,
"Cherry 2": 246,
"Cherry Rainier": 246,
"Cherry Wax Black": 164,
"Cherry Wax Red": 164,
"Cherry Wax Yellow": 164,
"Chestnut": 153,
"Clementine": 166,
"Cocos": 166,
"Corn": 150,
"Corn Husk": 154,
"Cucumber Ripe": 130,
"Cucumber Ripe 2": 156,
"Dates": 166,
"Eggplant": 156,
"Fig": 234,
"Ginger Root": 99,
"Granadilla": 166,
"Grape Blue": 328,
"Grape Pink": 164,
"Grape White": 166,
"Grape White 2": 166,
"Grape White 3": 164,
"Grape White 4": 158,
"Grapefruit Pink": 166,
"Grapefruit White": 164,
"Guava": 166,
"Hazelnut": 157,
"Huckleberry": 166,
"Kaki": 166,
"Kiwi": 156,
"Kohlrabi": 157,
"Kumquats": 166,
"Lemon": 164,
"Lemon Meyer": 166,
"Limes": 166,
"Lychee": 166,
"Mandarine": 166,
"Mango": 166,
"Mango Red": 142,
"Mangostan": 102,
"Maracuja": 166,
"Melon Piel de Sapo": 246,
"Mulberry": 164,
"Nectarine": 164,
"Nectarine Flat": 160,
"Nut Forest": 218,
"Nut Pecan": 178,
"Onion Red": 150,
"Onion Red Peeled": 155,
"Onion White": 146,
"Orange": 160,
"Papaya": 164,
"Passion Fruit": 166,
"Peach": 164,
"Peach 2": 246,
"Peach Flat": 164,
"Pear": 164,
"Pear 2": 232,
"Pear Abate": 166,
"Pear Forelle": 234,
"Pear Kaiser": 102,
"Pear Monster": 166,
"Pear Red": 222,
"Pear Stone": 237,
"Pear Williams": 166,
"Pepino": 166,
"Pepper Green": 148,
"Pepper Orange": 234,
"Pepper Red": 222,
"Pepper Yellow": 222,
"Physalis": 164,
"Physalis with Husk": 164,
"Pineapple": 166,
"Pineapple Mini": 163,
"Pitahaya Red": 166,
"Plum": 151,
"Plum 2": 142,
"Plum 3": 304,
"Pomegranate": 164,
"Pomelo Sweetie": 153,
"Potato Red": 150,
"Potato Red Washed": 151,
"Potato Sweet": 150,
"Potato White": 150,
"Quince": 166,
"Rambutan": 164,
"Raspberry": 166,
"Redcurrant": 164,
"Salak": 162,
"Strawberry": 164,
"Strawberry Wedge": 246,
"Tamarillo": 166,
"Tangelo": 166,
"Tomato 1": 246,
"Tomato 2": 225,
"Tomato 3": 246,
"Tomato 4": 160,
"Tomato Cherry Red": 164,
"Tomato Heart": 228,
"Tomato Maroon": 127,
"Tomato not Ripened": 158,
"Tomato Yellow": 153,
"Walnut": 249,
"Watermelon": 157
}
整体的建模流程可以参考前面的文章即可。
本文的主要目的是为了轻量化改造上文提及的五种模型,当然了lenet和mobilnet本身就是很轻量级的,这里基本不做改动,另外自己也搭建了相对简单的CNN模型,想依次对这六种模型分别进行实验分析,之后整体对比。
首先是自己搭建的网络模型,这里只有三层卷积,如下所示:
接下来是lenet,保持原始的结构:
之后是alexnet,alexnet本身网络的参数里还是较大的,这里主要是缩减参数量级,如下:
下面是mobilenet模型,这个本身就是轻量级的模型,这里就不再多赘述了,最后是VGG模型,本身VGG是非常成功的模型,主要有两款分别是vgg16和vgg19,但是每一款的参数里都是比较大的,这里主要是对网络结构进行精简,同时为了进一步简化计算,对每层的网络参数进行缩减,这里以vgg16为例,看下结构,vgg19也是同样的道理:
完成模型结构设计与改造后,接下来就是漫长的实验训练,这个阶段就直接不多讲了,我们直接来看结果,为了直观对六组模型进行对比分析,这里对其进行综合的对比可视化。
【训练loss曲线】
【验证loss曲线】
【训练accuracy曲线】
【验证accuracy曲线】
整体看其实并没有看出来很明显的差距,究其原因可能就是跟数据集比较“正”有关系吧,本身场景还是很简单。
最后我又绘制了loss和accuracy的整体对比曲线如下所示:
【损失曲线】
【准确率曲线】
这些实验足足用掉了一整天的时间,写到这里手都发软了,写作不易,记录一下!