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

四、结果展示





相关推荐
刀客1231 小时前
python3+TensorFlow 2.x(四)反向传播
人工智能·python·tensorflow
SpikeKing1 小时前
LLM - 大模型 ScallingLaws 的设计 100B 预训练方案(PLM) 教程(5)
人工智能·llm·预训练·scalinglaws·100b·deepnorm·egs
小枫@码1 小时前
免费GPU算力,不花钱部署DeepSeek-R1
人工智能·语言模型
liruiqiang051 小时前
机器学习 - 初学者需要弄懂的一些线性代数的概念
人工智能·线性代数·机器学习·线性回归
Icomi_1 小时前
【外文原版书阅读】《机器学习前置知识》1.线性代数的重要性,初识向量以及向量加法
c语言·c++·人工智能·深度学习·神经网络·机器学习·计算机视觉
微学AI1 小时前
GPU算力平台|在GPU算力平台部署可图大模型Kolors的应用实战教程
人工智能·大模型·llm·gpu算力
西猫雷婶1 小时前
python学opencv|读取图像(四十六)使用cv2.bitwise_or()函数实现图像按位或运算
人工智能·opencv·计算机视觉
IT古董1 小时前
【深度学习】常见模型-生成对抗网络(Generative Adversarial Network, GAN)
人工智能·深度学习·生成对抗网络
Jackilina_Stone1 小时前
【论文阅读笔记】“万字”关于深度学习的图像和视频阴影检测、去除和生成的综述笔记 | 2024.9.3
论文阅读·人工智能·笔记·深度学习·ai
梦云澜1 小时前
论文阅读(三):微阵列数据的图形模型和多变量分析
论文阅读·深度学习