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

四、结果展示





相关推荐
阿坡RPA11 小时前
手搓MCP客户端&服务端:从零到实战极速了解MCP是什么?
人工智能·aigc
用户277844910499311 小时前
借助DeepSeek智能生成测试用例:从提示词到Excel表格的全流程实践
人工智能·python
机器之心12 小时前
刚刚,DeepSeek公布推理时Scaling新论文,R2要来了?
人工智能
算AI14 小时前
人工智能+牙科:临床应用中的几个问题
人工智能·算法
凯子坚持 c14 小时前
基于飞桨框架3.0本地DeepSeek-R1蒸馏版部署实战
人工智能·paddlepaddle
你觉得20515 小时前
哈尔滨工业大学DeepSeek公开课:探索大模型原理、技术与应用从GPT到DeepSeek|附视频与讲义下载方法
大数据·人工智能·python·gpt·学习·机器学习·aigc
8K超高清15 小时前
中国8K摄像机:科技赋能文化传承新图景
大数据·人工智能·科技·物联网·智能硬件
hyshhhh15 小时前
【算法岗面试题】深度学习中如何防止过拟合?
网络·人工智能·深度学习·神经网络·算法·计算机视觉
薛定谔的猫-菜鸟程序员15 小时前
零基础玩转深度神经网络大模型:从Hello World到AI炼金术-详解版(含:Conda 全面使用指南)
人工智能·神经网络·dnn
币之互联万物16 小时前
2025 AI智能数字农业研讨会在苏州启幕,科技助农与数据兴业成焦点
人工智能·科技