由于植物分类所使用的数据集存在一定问题,修改起来比较麻烦,本次采用kaggle的ButterflyMothsImageClassification数据集,对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’
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