butterfly蝴蝶分类

一、分类原因

由于植物分类所使用的数据集存在一定问题,修改起来比较麻烦,本次采用kaggle的ButterflyMothsImageClassification数据集,对100这种蝴蝶进行分类。

二、100中蝴蝶类别

'ADONIS','AFRICAN GIANT SWALLOWTAIL','AMERICAN SNOOT','AN 88','APPOLLO','ARCIGERA FLOWER MOTH','ATALA','ATLAS MOTH','BANDED ORANGE HELICONIAN','BANDED PEACOCK','BANDED TIGER MOTH','BECKERS WHITE','BIRD CHERRY ERMINE MOTH','BLACK HAIRSTREAK','BLUE MORPHO','BLUE SPOTTED CROW','BROOKES BIRDWING','BROWN ARGUS','BROWN SIPROETA','CABBAGE WHITE','CAIRNS BIRDWING','CHALK HILL BLUE','CHECQUERED SKIPPER','CHESTNUT','CINNABAR MOTH','CLEARWING MOTH','CLEOPATRA','CLODIUS PARNASSIAN','CLOUDED SULPHUR','COMET MOTH','COMMON BANDED AWL','COMMON WOOD-NYMPH','COPPER TAIL','CRECENT','CRIMSON PATCH','DANAID EGGFLY','EASTERN COMA','EASTERN DAPPLE WHITE','EASTERN PINE ELFIN','ELBOWED PIERROT','EMPEROR GUM MOTH','GARDEN TIGER MOTH','GIANT LEOPARD MOTH','GLITTERING SAPPHIRE','GOLD BANDED','GREAT EGGFLY','GREAT JAY','GREEN CELLED CATTLEHEART','GREEN HAIRSTREAK','GREY HAIRSTREAK','HERCULES MOTH','HUMMING BIRD HAWK MOTH','INDRA SWALLOW','IO MOTH','Iphiclus sister','JULIA','LARGE MARBLE','LUNA MOTH','MADAGASCAN SUNSET MOTH','MALACHITE','MANGROVE SKIPPER','MESTRA','METALMARK','MILBERTS TORTOISESHELL','MONARCH','MOURNING CLOAK','OLEANDER HAWK MOTH','ORANGE OAKLEAF','ORANGE TIP','ORCHARD SWALLOW','PAINTED LADY','PAPER KITE','PEACOCK','PINE WHITE','PIPEVINE SWALLOW','POLYPHEMUS MOTH','POPINJAY','PURPLE HAIRSTREAK','PURPLISH COPPER','QUESTION MARK','RED ADMIRAL','RED CRACKER','RED POSTMAN','RED SPOTTED PURPLE','ROSY MAPLE MOTH','SCARCE SWALLOW','SILVER SPOT SKIPPER','SIXSPOT BURNET MOTH','SLEEPY ORANGE','SOOTYWING','SOUTHERN DOGFACE','STRAITED QUEEN','TROPICAL LEAFWING','TWO BARRED FLASHER','ULYSES','VICEROY','WHITE LINED SPHINX MOTH','WOOD SATYR','YELLOW SWALLOW TAIL','ZEBRA LONG WING'

三、配置文件

python 复制代码
auto_scale_lr = dict(base_batch_size=256)
data_preprocessor = dict(
    mean=[
        123.675,
        116.28,
        103.53,
    ],
    num_classes=100,
    std=[
        58.395,
        57.12,
        57.375,
    ],
    to_rgb=True)
dataset_type = 'ImageNet'
data_root = 'data/ButterflyMothsImageClassification'
default_hooks = dict(
    checkpoint=dict(interval=1, type='CheckpointHook', max_keep_ckpts=2, save_best="auto"),
    logger=dict(interval=100, type='LoggerHook'),
    param_scheduler=dict(type='ParamSchedulerHook'),
    sampler_seed=dict(type='DistSamplerSeedHook'),
    timer=dict(type='IterTimerHook'),
    visualization=dict(enable=False, type='VisualizationHook'))
default_scope = 'mmpretrain'
env_cfg = dict(
    cudnn_benchmark=False,
    dist_cfg=dict(backend='nccl'),
    mp_cfg=dict(mp_start_method='fork', opencv_num_threads=0))
launcher = 'none'
load_from = './work_dirs/resnet50_8xb32-coslr_in1k/resnet50_8xb32_in1k_20210831-ea4938fc.pth'
log_level = 'INFO'
model = dict(
    backbone=dict(
        depth=50,
        num_stages=4,
        out_indices=(3,),
        style='pytorch',
        type='ResNet'),
    head=dict(
        in_channels=2048,
        # loss=dict(loss_weight=1.0, type='CrossEntropyLoss'),
        loss=dict(
                    type='LabelSmoothLoss',
                    label_smooth_val=0.1,
                    num_classes=100,
                    reduction='mean',
                    loss_weight=1.0),
        num_classes=100,
        topk=(
            1,
            5,
        ),
        type='LinearClsHead'),
    data_preprocessor=data_preprocessor,
    neck=dict(type='GlobalAveragePooling'),
    type='ImageClassifier')
train_cfg = dict(by_epoch=True, max_epochs=300, val_interval=1)
optim_wrapper = dict(
    optimizer=dict(lr=0.1, momentum=0.9, type='SGD', weight_decay=0.0001))
param_scheduler = dict(
    T_max=260, begin=20, by_epoch=True, end=300, type='CosineAnnealingLR')
randomness = dict(deterministic=False, seed=None)
resume = False
test_cfg = dict()
test_pipeline = [
    dict(type='LoadImageFromFile'),
    dict(edge='short', scale=256, type='ResizeEdge'),
    dict(crop_size=224, type='CenterCrop'),
    dict(type='PackInputs'),
]
test_dataloader = dict(
    batch_size=32,
    collate_fn=dict(type='default_collate'),
    dataset=dict(
        data_root=data_root,
        pipeline=test_pipeline,
        split='test',
        ann_file='test.txt',
        type=dataset_type),
    num_workers=1,
    persistent_workers=True,
    pin_memory=True,
    sampler=dict(shuffle=False, type='DefaultSampler'))
test_evaluator = dict(
    topk=(
        1,
        5,
    ), type='Accuracy')

train_pipeline = [
    dict(type='LoadImageFromFile'),
    dict(scale=224, type='RandomResizedCrop'),
    dict(direction='horizontal', prob=0.5, type='RandomFlip'),
    dict(type='PackInputs'),
]
train_dataloader = dict(
    batch_size=45,
    collate_fn=dict(type='default_collate'),
    dataset=dict(
        data_root=data_root,
        pipeline=train_pipeline,
        split='train',
        ann_file='train.txt',
        type=dataset_type),
    num_workers=1,
    persistent_workers=True,
    pin_memory=True,
    sampler=dict(shuffle=True, type='DefaultSampler'))

val_cfg = dict()
val_dataloader = dict(
    batch_size=45,
    collate_fn=dict(type='default_collate'),
    dataset=dict(
        data_root=data_root,
        pipeline=test_pipeline,
        split='val',
        ann_file='valid.txt',
        type=dataset_type),
    num_workers=1,
    persistent_workers=True,
    pin_memory=True,
    sampler=dict(shuffle=False, type='DefaultSampler'))
val_evaluator = test_evaluator
vis_backends = [
    dict(type='LocalVisBackend'),
]
visualizer = dict(
    type='UniversalVisualizer', vis_backends=[
        dict(type='LocalVisBackend'),
    ])
work_dir = './work_dirs\\resnet50_8xb32-coslr_in1k'

三、训练结果

accuracy/top1: 97.0000 accuracy/top5: 99.0000

四、结果展示





相关推荐
Elastic 中国社区官方博客41 分钟前
使用 Elastic AI Assistant for Search 和 Azure OpenAI 实现从 0 到 60 的转变
大数据·人工智能·elasticsearch·microsoft·搜索引擎·ai·azure
江_小_白2 小时前
自动驾驶之激光雷达
人工智能·机器学习·自动驾驶
yusaisai大鱼3 小时前
TensorFlow如何调用GPU?
人工智能·tensorflow
weixin_466202783 小时前
第31周:天气识别(Tensorflow实战第三周)
分类·数据挖掘·tensorflow
珠海新立电子科技有限公司5 小时前
FPC柔性线路板与智能生活的融合
人工智能·生活·制造
IT古董6 小时前
【机器学习】机器学习中用到的高等数学知识-8. 图论 (Graph Theory)
人工智能·机器学习·图论
曼城周杰伦6 小时前
自然语言处理:第六十三章 阿里Qwen2 & 2.5系列
人工智能·阿里云·语言模型·自然语言处理·chatgpt·nlp·gpt-3
余炜yw7 小时前
【LSTM实战】跨越千年,赋诗成文:用LSTM重现唐诗的韵律与情感
人工智能·rnn·深度学习
莫叫石榴姐7 小时前
数据科学与SQL:组距分组分析 | 区间分布问题
大数据·人工智能·sql·深度学习·算法·机器学习·数据挖掘
96777 小时前
对抗样本存在的原因
深度学习