AssertionError: The number of subfolders (102) doesn't match the number of specified classes (1000). Please check the data folder. #1797
Unanswered
yangzhenyu6
asked this question in
Q&A
Replies: 4 comments
-
解决了吗,怎么改? |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I hope to use my own dataset to train resnet18_ 8xb32_ However, my dataset only has 102 classes. How can I adjust my parameters so that the model can be trained
Here are my parameter configurations:
auto_scale_lr = dict(base_batch_size=256)
data_preprocessor = dict(
mean=[
123.675,
116.28,
103.53,
],
num_classes=102,
std=[
58.395,
57.12,
57.375,
],
to_rgb=True)
dataset_type = 'ImageNet'
default_hooks = dict(
checkpoint=dict(interval=50, type='CheckpointHook'),
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 = None
log_level = 'INFO'
model = dict(
backbone=dict(
depth=18,
num_stages=4,
out_indices=(3, ),
style='pytorch',
type='ResNet'),
head=dict(
in_channels=512,
loss=dict(loss_weight=1.0, type='CrossEntropyLoss'),
num_classes=102,
topk=(
1,
5,
),
type='LinearClsHead'),
neck=dict(type='GlobalAveragePooling'),
type='ImageClassifier')
optim_wrapper = dict(
optimizer=dict(lr=0.1, momentum=0.9, type='SGD', weight_decay=0.0001))
param_scheduler = dict(
by_epoch=True, gamma=0.1, milestones=[
30,
60,
90,
], type='MultiStepLR')
randomness = dict(deterministic=False, seed=None)
resume = False
test_cfg = dict()
test_dataloader = dict(
batch_size=32,
collate_fn=dict(type='default_collate'),
dataset=dict(
data_root=r'D:\PycharmProjects\pythonProject_test\mmpretrain-main\mmpretrain\data\flower_data\valid',
pipeline=[
dict(type='LoadImageFromFile'),
dict(edge='short', scale=256, type='ResizeEdge'),
dict(crop_size=224, type='CenterCrop'),
dict(type='PackInputs'),
],
split='val',
type='ImageNet'),
num_workers=5,
persistent_workers=True,
pin_memory=True,
sampler=dict(shuffle=False, type='DefaultSampler'))
test_evaluator = dict(
topk=(
1,
5,
), type='Accuracy')
test_pipeline = [
dict(type='LoadImageFromFile'),
dict(edge='short', scale=256, type='ResizeEdge'),
dict(crop_size=224, type='CenterCrop'),
dict(type='PackInputs'),
]
train_cfg = dict(by_epoch=True, max_epochs=100, val_interval=1)
train_dataloader = dict(
batch_size=32,
collate_fn=dict(type='default_collate'),
dataset=dict(
data_root=r'D:\PycharmProjects\pythonProject_test\mmpretrain-main\mmpretrain\data\flower_data',
pipeline=[
dict(type='LoadImageFromFile'),
dict(scale=224, type='RandomResizedCrop'),
dict(direction='horizontal', prob=0.5, type='RandomFlip'),
dict(type='PackInputs'),
],
split='train',
type='ImageNet'),
num_workers=5,
persistent_workers=True,
pin_memory=True,
sampler=dict(shuffle=True, type='DefaultSampler'))
train_pipeline = [
dict(type='LoadImageFromFile'),
dict(scale=224, type='RandomResizedCrop'),
dict(direction='horizontal', prob=0.5, type='RandomFlip'),
dict(type='PackInputs'),
]
val_cfg = dict()
val_dataloader = dict(
batch_size=32,
collate_fn=dict(type='default_collate'),
dataset=dict(
data_root=r'D:\PycharmProjects\pythonProject_test\mmpretrain-main\mmpretrain\data\flower_data\valid',
pipeline=[
dict(type='LoadImageFromFile'),
dict(edge='short', scale=256, type='ResizeEdge'),
dict(crop_size=224, type='CenterCrop'),
dict(type='PackInputs'),
],
split='val',
type='ImageNet'),
num_workers=5,
persistent_workers=True,
pin_memory=True,
sampler=dict(shuffle=False, type='DefaultSampler'))
val_evaluator = dict(
topk=(
1,
5,
), type='Accuracy')
vis_backends = [
dict(type='LocalVisBackend'),
]
visualizer = dict(
type='UniversalVisualizer', vis_backends=[
dict(type='LocalVisBackend'),
])
work_dir = './work_dirs\resnet18_8xb32_in1k'
Beta Was this translation helpful? Give feedback.
All reactions