mmpretrain icon indicating copy to clipboard operation
mmpretrain copied to clipboard

help me.

Open vothaianh1997 opened this issue 3 years ago • 4 comments

2022-04-06 19:17:39,308 - mmcls - INFO - Set random seed to 0, deterministic: True
2022-04-06 19:17:39,590 - mmcls - INFO - initialize ImageClassifier with init_cfg [{'type': 'TruncNormal', 'layer': 'Linear', 'std': 0.02, 'bias': 0.0}, {'type': 'Constant', 'layer': 'LayerNorm', 'val': 1.0, 'bias': 0.0}]
Traceback (most recent call last):
  File "/usr/local/lib/python3.7/dist-packages/mmcv/utils/registry.py", line 52, in build_from_cfg
    return obj_cls(**args)
  File "/content/mmclassification/mmcls/datasets/imagenet.py", line 1034, in __init__
    file_client_args=file_client_args)
  File "/content/mmclassification/mmcls/datasets/custom.py", line 170, in __init__
    test_mode=test_mode)
  File "/content/mmclassification/mmcls/datasets/base_dataset.py", line 51, in __init__
    self.data_infos = self.load_annotations()
  File "/content/mmclassification/mmcls/datasets/custom.py", line 211, in load_annotations
    samples = self._find_samples()
  File "/content/mmclassification/mmcls/datasets/custom.py", line 176, in _find_samples
    classes, folder_to_idx = find_folders(self.data_prefix, file_client)
  File "/content/mmclassification/mmcls/datasets/custom.py", line 31, in find_folders
    recursive=False,
  File "/usr/local/lib/python3.7/dist-packages/mmcv/fileio/file_client.py", line 1149, in list_dir_or_file
    suffix, recursive)
  File "/usr/local/lib/python3.7/dist-packages/mmcv/fileio/file_client.py", line 673, in _list_dir_or_file
    for entry in os.scandir(dir_path):
FileNotFoundError: [Errno 2] No such file or directory: 'data/imagenet/train'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "tools/train.py", line 194, in <module>
    main()
  File "tools/train.py", line 167, in main
    datasets = [build_dataset(cfg.data.train)]
  File "/content/mmclassification/mmcls/datasets/builder.py", line 50, in build_dataset
    dataset = build_from_cfg(cfg, DATASETS, default_args)
  File "/usr/local/lib/python3.7/dist-packages/mmcv/utils/registry.py", line 55, in build_from_cfg
    raise type(e)(f'{obj_cls.__name__}: {e}')
FileNotFoundError: ImageNet: [Errno 2] No such file or directory: 'data/imagenet/train'

vothaianh1997 avatar Apr 06 '22 19:04 vothaianh1997

Looks like you don't have dataset folder

mzr1996 avatar Apr 07 '22 01:04 mzr1996

https://programmer.help/blogs/start-a-classification-task-using-swing-transformer-in-mmclassification.html#1.%20MMClassification%E5%AE%89%E8%A3%85 .Start a classification task using swing transformer in MMClassification

i don't know where imagenet dataset in code of this link. Can U give me link code of Swin Transformer fine tuning.

vothaianh1997 avatar Apr 07 '22 02:04 vothaianh1997

Here is the colab tutorial Please notice the Prepare data section and the Create a new config file section

mzr1996 avatar Apr 07 '22 02:04 mzr1996

help me

!python tools/test.py ./configs/swin_transformer/swin-tiny_cats-dogs.py work_dirs/swin-tiny_cats-dogs/latest.pth --metrics=accuracy --metric-options=topk=1

/usr/local/lib/python3.7/dist-packages/mmcv/cnn/bricks/transformer.py:33: UserWarning: Fail to import MultiScaleDeformableAttention from mmcv.ops.multi_scale_deform_attn, You should install mmcv-full if you need this module. warnings.warn('Fail to import MultiScaleDeformableAttention from ' /content/mmclassification/mmcls/utils/setup_env.py:33: UserWarning: Setting OMP_NUM_THREADS environment variable for each process to be 1 in default, to avoid your system being overloaded, please further tune the variable for optimal performance in your application as needed. f'Setting OMP_NUM_THREADS environment variable for each process ' /content/mmclassification/mmcls/utils/setup_env.py:43: UserWarning: Setting MKL_NUM_THREADS environment variable for each process to be 1 in default, to avoid your system being overloaded, please further tune the variable for optimal performance in your application as needed. f'Setting MKL_NUM_THREADS environment variable for each process ' load checkpoint from local path: work_dirs/swin-tiny_cats-dogs/latest.pth Traceback (most recent call last): File "tools/test.py", line 243, in main() File "tools/test.py", line 170, in main checkpoint = load_checkpoint(model, args.checkpoint, map_location='cpu') File "/usr/local/lib/python3.7/dist-packages/mmcv/runner/checkpoint.py", line 563, in load_checkpoint load_state_dict(model, state_dict, strict, logger) File "/usr/local/lib/python3.7/dist-packages/mmcv/runner/checkpoint.py", line 80, in load_state_dict load(module) File "/usr/local/lib/python3.7/dist-packages/mmcv/runner/checkpoint.py", line 78, in load load(child, prefix + name + '.') File "/usr/local/lib/python3.7/dist-packages/mmcv/runner/checkpoint.py", line 75, in load err_msg) File "/content/mmclassification/mmcls/models/backbones/swin_transformer.py", line 457, in _load_from_state_dict *args, **kwargs) File "/usr/local/lib/python3.7/dist-packages/torch/nn/modules/module.py", line 1372, in _load_from_state_dict hook(state_dict, prefix, local_metadata, strict, missing_keys, unexpected_keys, error_msgs) File "/content/mmclassification/mmcls/models/backbones/swin_transformer.py", line 514, in _prepare_relative_position_bias_table relative_position_bias_table_current = state_dict_model[key] KeyError: 'backbone.stages.0.blocks.0.attn.w_msa.relative_position_bias_table'

vothaianh1997 avatar Apr 18 '22 13:04 vothaianh1997

This issue will be closed as it is inactive, feel free to re-open it if necessary.

tonysy avatar Dec 12 '22 15:12 tonysy