mmyolo
mmyolo copied to clipboard
Razor subnets are broken, probably due to updates in dependencies.
Prerequisite
- [X] I have searched the existing and past issues but cannot get the expected help.
- [X] I have read the FAQ documentation but cannot get the expected help.
- [X] The bug has not been fixed in the latest version.
🐞 Describe the bug
I run both configs, without modifications:
configs/razor/subnets/yolov5_s_spos_shufflenetv2_syncbn_8xb16-300e_coco.py
configs/razor/subnets/yolov6_l_attentivenas_a6_d12_syncbn_fast_8xb32-300e_coco.py
Both are broken and it's rather difficult to debug. Here is example for "configs/razor/subnets/yolov5_s_spos_shufflenetv2_syncbn_8xb16-300e_coco.py"
Traceback (most recent call last):
File "./tools/train.py", line 115, in <module>
main()
File "./tools/train.py", line 104, in main
runner = Runner.from_cfg(cfg)
File "/home/azureuser/miniconda3/envs/mmyolo/lib/python3.8/site-packages/mmengine/runner/runner.py", line 439, in from_cfg
runner = cls(
File "/home/azureuser/miniconda3/envs/mmyolo/lib/python3.8/site-packages/mmengine/runner/runner.py", line 406, in __init__
self.model = self.build_model(model)
File "/home/azureuser/miniconda3/envs/mmyolo/lib/python3.8/site-packages/mmengine/runner/runner.py", line 808, in build_model
model = MODELS.build(model)
File "/home/azureuser/miniconda3/envs/mmyolo/lib/python3.8/site-packages/mmengine/registry/registry.py", line 548, in build
return self.build_func(cfg, *args, **kwargs, registry=self)
File "/home/azureuser/miniconda3/envs/mmyolo/lib/python3.8/site-packages/mmengine/registry/build_functions.py", line 241, in build_model_from_cfg
return build_from_cfg(cfg, registry, default_args)
File "/home/azureuser/miniconda3/envs/mmyolo/lib/python3.8/site-packages/mmengine/registry/build_functions.py", line 135, in build_from_cfg
raise type(e)(
TypeError: class `YOLODetector` in mmyolo/models/detectors/yolo_detector.py: class `sub_model` in mmrazor/registry/registry.py: class `SearchableShuffleNetV2` in mmrazor/models/architectures/backbones/searchable_shufflenet_v2.py: __init__() takes 1 positional argument but 2 were given
If you want to see the entire error, you can see how everything is broken recursively.
03/27 20:53:52 - mmengine - WARNING - The "model" registry in mmrazor did not set import location. Fallback to call `mmrazor.utils.register_all_modules` instead.
Traceback (most recent call last):
File "/home/azureuser/miniconda3/envs/mmyolo/lib/python3.8/site-packages/mmengine/registry/build_functions.py", line 121, in build_from_cfg
obj = obj_cls(**args) # type: ignore
File "/home/azureuser/miniconda3/envs/mmyolo/lib/python3.8/site-packages/mmrazor/models/architectures/backbones/searchable_shufflenet_v2.py", line 97, in __init__
super().__init__(init_cfg)
TypeError: __init__() takes 1 positional argument but 2 were given
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/azureuser/miniconda3/envs/mmyolo/lib/python3.8/site-packages/mmengine/registry/build_functions.py", line 121, in build_from_cfg
obj = obj_cls(**args) # type: ignore
File "/home/azureuser/miniconda3/envs/mmyolo/lib/python3.8/site-packages/mmrazor/registry/registry.py", line 117, in sub_model
model = MODELS.build(cfg)
File "/home/azureuser/miniconda3/envs/mmyolo/lib/python3.8/site-packages/mmengine/registry/registry.py", line 548, in build
return self.build_func(cfg, *args, **kwargs, registry=self)
File "/home/azureuser/miniconda3/envs/mmyolo/lib/python3.8/site-packages/mmrazor/registry/registry.py", line 49, in build_razor_model_from_cfg
razor_model = build_from_cfg(cfg, registry, default_args)
File "/home/azureuser/miniconda3/envs/mmyolo/lib/python3.8/site-packages/mmengine/registry/build_functions.py", line 135, in build_from_cfg
raise type(e)(
TypeError: class `SearchableShuffleNetV2` in mmrazor/models/architectures/backbones/searchable_shufflenet_v2.py: __init__() takes 1 positional argument but 2 were given
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/azureuser/miniconda3/envs/mmyolo/lib/python3.8/site-packages/mmengine/registry/build_functions.py", line 121, in build_from_cfg
obj = obj_cls(**args) # type: ignore
File "/home/azureuser/mmyolo/mmyolo/models/detectors/yolo_detector.py", line 41, in __init__
super().__init__(
File "/home/azureuser/miniconda3/envs/mmyolo/lib/python3.8/site-packages/mmdet/models/detectors/single_stage.py", line 30, in __init__
self.backbone = MODELS.build(backbone)
File "/home/azureuser/miniconda3/envs/mmyolo/lib/python3.8/site-packages/mmengine/registry/registry.py", line 548, in build
return self.build_func(cfg, *args, **kwargs, registry=self)
File "/home/azureuser/miniconda3/envs/mmyolo/lib/python3.8/site-packages/mmengine/registry/build_functions.py", line 241, in build_model_from_cfg
return build_from_cfg(cfg, registry, default_args)
File "/home/azureuser/miniconda3/envs/mmyolo/lib/python3.8/site-packages/mmengine/registry/build_functions.py", line 135, in build_from_cfg
raise type(e)(
TypeError: class `sub_model` in mmrazor/registry/registry.py: class `SearchableShuffleNetV2` in mmrazor/models/architectures/backbones/searchable_shufflenet_v2.py: __init__() takes 1 positional argument but 2 were given
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "./tools/train.py", line 115, in <module>
main()
File "./tools/train.py", line 104, in main
runner = Runner.from_cfg(cfg)
File "/home/azureuser/miniconda3/envs/mmyolo/lib/python3.8/site-packages/mmengine/runner/runner.py", line 439, in from_cfg
runner = cls(
File "/home/azureuser/miniconda3/envs/mmyolo/lib/python3.8/site-packages/mmengine/runner/runner.py", line 406, in __init__
self.model = self.build_model(model)
File "/home/azureuser/miniconda3/envs/mmyolo/lib/python3.8/site-packages/mmengine/runner/runner.py", line 808, in build_model
model = MODELS.build(model)
File "/home/azureuser/miniconda3/envs/mmyolo/lib/python3.8/site-packages/mmengine/registry/registry.py", line 548, in build
return self.build_func(cfg, *args, **kwargs, registry=self)
File "/home/azureuser/miniconda3/envs/mmyolo/lib/python3.8/site-packages/mmengine/registry/build_functions.py", line 241, in build_model_from_cfg
return build_from_cfg(cfg, registry, default_args)
File "/home/azureuser/miniconda3/envs/mmyolo/lib/python3.8/site-packages/mmengine/registry/build_functions.py", line 135, in build_from_cfg
raise type(e)(
TypeError: class `YOLODetector` in mmyolo/models/detectors/yolo_detector.py: class `sub_model` in mmrazor/registry/registry.py: class `SearchableShuffleNetV2` in mmrazor/models/architectures/backbones/searchable_shufflenet_v2.py: __init__() takes 1 positional argument but 2 were given
Environment
''' Python: 3.8.16 (default, Mar 2 2023, 03:21:46) [GCC 11.2.0] CUDA available: True numpy_random_seed: 2147483648 GPU 0: NVIDIA A100 80GB PCIe CUDA_HOME: /opt/nvidia/hpc_sdk/Linux_x86_64/22.7/compilers NVCC: Cuda compilation tools, release 11.7, V11.7.64 GCC: gcc (Ubuntu 9.4.0-1ubuntu1~20.04.1) 9.4.0 PyTorch: 1.10.1 PyTorch compiling details: PyTorch built with:
- GCC 7.3
- C++ Version: 201402
- Intel(R) oneAPI Math Kernel Library Version 2021.4-Product Build 20210904 for Intel(R) 64 architecture applications
- Intel(R) MKL-DNN v2.2.3 (Git Hash 7336ca9f055cf1bfa13efb658fe15dc9b41f0740)
- OpenMP 201511 (a.k.a. OpenMP 4.5)
- LAPACK is enabled (usually provided by MKL)
- NNPACK is enabled
- CPU capability usage: AVX2
- CUDA Runtime 11.3
- NVCC architecture flags: -gencode;arch=compute_37,code=sm_37;-gencode;arch=compute_50,code=sm_50;-gencode;arch=compute_60,code=sm_60;-gencode;arch=compute_61,code=sm_61;-gencode;arch=compute_70,code=sm_70;-gencode;arch=compute_75,code=sm_75;-gencode;arch=compute_80,code=sm_80;-gencode;arch=compute_86,code=sm_86;-gencode;arch=compute_37,code=compute_37
- CuDNN 8.2
- Magma 2.5.2
- Build settings: BLAS_INFO=mkl, BUILD_TYPE=Release, CUDA_VERSION=11.3, CUDNN_VERSION=8.2.0, CXX_COMPILER=/opt/rh/devtoolset-7/root/usr/bin/c++, CXX_FLAGS= -Wno-deprecated -fvisibility-inlines-hidden -DUSE_PTHREADPOOL -fopenmp -DNDEBUG -DUSE_KINETO -DUSE_FBGEMM -DUSE_QNNPACK -DUSE_PYTORCH_QNNPACK -DUSE_XNNPACK -DSYMBOLICATE_MOBILE_DEBUG_HANDLE -DEDGE_PROFILER_USE_KINETO -O2 -fPIC -Wno-narrowing -Wall -Wextra -Werror=return-type -Wno-missing-field-initializers -Wno-type-limits -Wno-array-bounds -Wno-unknown-pragmas -Wno-sign-compare -Wno-unused-parameter -Wno-unused-variable -Wno-unused-function -Wno-unused-result -Wno-unused-local-typedefs -Wno-strict-overflow -Wno-strict-aliasing -Wno-error=deprecated-declarations -Wno-stringop-overflow -Wno-psabi -Wno-error=pedantic -Wno-error=redundant-decls -Wno-error=old-style-cast -fdiagnostics-color=always -faligned-new -Wno-unused-but-set-variable -Wno-maybe-uninitialized -fno-math-errno -fno-trapping-math -Werror=format -Wno-stringop-overflow, LAPACK_INFO=mkl, PERF_WITH_AVX=1, PERF_WITH_AVX2=1, PERF_WITH_AVX512=1, TORCH_VERSION=1.10.1, USE_CUDA=ON, USE_CUDNN=ON, USE_EXCEPTION_PTR=1, USE_GFLAGS=OFF, USE_GLOG=OFF, USE_MKL=ON, USE_MKLDNN=ON, USE_MPI=OFF, USE_NCCL=ON, USE_NNPACK=ON, USE_OPENMP=ON,
TorchVision: 0.11.2 OpenCV: 4.7.0 MMEngine: 0.7.0 MMCV: 2.0.0rc4 MMDetection: 3.0.0rc6 MMYOLO: 0.5.0+dc85144 '''
Additional information
No response
Any updates? @hhaAndroid
I am trying to bug fix the issue, but would like some help here.
Environment
04/12 10:51:35 - mmengine - WARNING - Failed to search registry with scope "mmyolo" in the "log_processor" registry tree. As a workaround, the current "log_processor" registry in "mmengine" is used to build instance. This may cause unexpected failure when running the built modules. Please check whether "mmyolo" is a correct scope, or whether the registry is initialized.
04/12 10:51:35 - mmengine - INFO -
------------------------------------------------------------
System environment:
sys.platform: linux
Python: 3.8.16 (default, Mar 2 2023, 03:21:46) [GCC 11.2.0]
CUDA available: False
numpy_random_seed: 1709640938
GCC: gcc (Ubuntu 9.4.0-1ubuntu1~20.04.1) 9.4.0
PyTorch: 1.10.1
PyTorch compiling details: PyTorch built with:
- GCC 7.3
- C++ Version: 201402
- Intel(R) oneAPI Math Kernel Library Version 2021.4-Product Build 20210904 for Intel(R) 64 architecture applications
- Intel(R) MKL-DNN v2.2.3 (Git Hash 7336ca9f055cf1bfa13efb658fe15dc9b41f0740)
- OpenMP 201511 (a.k.a. OpenMP 4.5)
- LAPACK is enabled (usually provided by MKL)
- NNPACK is enabled
- CPU capability usage: AVX512
- Build settings: BLAS_INFO=mkl, BUILD_TYPE=Release, CUDA_VERSION=11.3, CUDNN_VERSION=8.2.0, CXX_COMPILER=/opt/rh/devtoolset-7/root/usr/bin/c++, CXX_FLAGS= -Wno-deprecated -fvisibility-inlines-hidden -DUSE_PTHREADPOOL -fopenmp -DNDEBUG -DUSE_KINETO -DUSE_FBGEMM -DUSE_QNNPACK -DUSE_PYTORCH_QNNPACK -DUSE_XNNPACK -DSYMBOLICATE_MOBILE_DEBUG_HANDLE -DEDGE_PROFILER_USE_KINETO -O2 -fPIC -Wno-narrowing -Wall -Wextra -Werror=return-type -Wno-missing-field-initializers -Wno-type-limits -Wno-array-bounds -Wno-unknown-pragmas -Wno-sign-compare -Wno-unused-parameter -Wno-unused-variable -Wno-unused-function -Wno-unused-result -Wno-unused-local-typedefs -Wno-strict-overflow -Wno-strict-aliasing -Wno-error=deprecated-declarations -Wno-stringop-overflow -Wno-psabi -Wno-error=pedantic -Wno-error=redundant-decls -Wno-error=old-style-cast -fdiagnostics-color=always -faligned-new -Wno-unused-but-set-variable -Wno-maybe-uninitialized -fno-math-errno -fno-trapping-math -Werror=format -Wno-stringop-overflow, LAPACK_INFO=mkl, PERF_WITH_AVX=1, PERF_WITH_AVX2=1, PERF_WITH_AVX512=1, TORCH_VERSION=1.10.1, USE_CUDA=ON, USE_CUDNN=ON, USE_EXCEPTION_PTR=1, USE_GFLAGS=OFF, USE_GLOG=OFF, USE_MKL=ON, USE_MKLDNN=ON, USE_MPI=OFF, USE_NCCL=ON, USE_NNPACK=ON, USE_OPENMP=ON,
TorchVision: 0.11.2
OpenCV: 4.7.0
MMEngine: 0.7.2
Config:
04/12 10:51:42 - mmengine - INFO - Config:
arch_setting = dict(
kernel_size=[[3, 3, 1], [3, 7, 2], [3, 7, 2], [3, 7, 2], [3, 7, 2],
[3, 7, 2]],
num_blocks=[[1, 1, 1], [2, 4, 1], [2, 4, 1], [2, 4, 1], [2, 4, 1],
[2, 4, 1]],
expand_ratio=[[1, 1, 1], [3, 6, 1], [3, 6, 1], [3, 6, 1], [3, 6, 1],
[3, 6, 1], [6, 6, 1]],
num_out_channels=[[16, 16, 8], [16, 16, 8], [16, 24, 8], [24, 40, 8],
[40, 80, 8], [80, 112, 8], [112, 160, 8],
[1024, 1280, 256]])
input_resizer_cfg = dict(
input_sizes=[[128, 128], [140, 140], [144, 144], [152, 152], [192, 192],
[204, 204], [224, 224], [256, 256]])
nas_backbone = dict(
type='mmrazor.sub_model',
arch_setting=dict(
kernel_size=[[3, 3, 1], [3, 7, 2], [3, 7, 2], [3, 7, 2], [3, 7, 2],
[3, 7, 2]],
num_blocks=[[1, 1, 1], [2, 4, 1], [2, 4, 1], [2, 4, 1], [2, 4, 1],
[2, 4, 1]],
expand_ratio=[[1, 1, 1], [3, 6, 1], [3, 6, 1], [3, 6, 1], [3, 6, 1],
[3, 6, 1], [6, 6, 1]],
num_out_channels=[[16, 16, 8], [16, 16, 8], [16, 24, 8], [24, 40, 8],
[40, 80, 8], [80, 112, 8], [112, 160, 8],
[1024, 1280, 256]]),
out_indices=(2, 4, 5),
stride_list=[1, 2, 2, 2, 1, 2],
with_se_list=[False, False, True, False, True, True],
act_cfg_list=[
'HSwish', 'ReLU', 'ReLU', 'ReLU', 'HSwish', 'HSwish', 'HSwish',
'HSwish', 'HSwish'
],
conv_cfg=dict(type='mmrazor.OFAConv2d'),
norm_cfg=dict(type='mmrazor.DynamicBatchNorm2d', momentum=0.1),
fine_grained_mode=True,
with_attentive_shortcut=False,
_scope_='mmrazor',
init_cfg=dict(
type='Pretrained',
checkpoint=
'https://download.openmmlab.com/mmrazor/v1/ofa/ofa_mobilenet_subnet_8xb256_in1k_note8_lat%4031ms_top1%4072.8_finetune%4025.py_20221214_0939-981a8b2a.pth',
prefix='architecture.backbone.'),
fix_subnet=
'https://download.openmmlab.com/mmrazor/v1/yolo_nas_backbone/OFA_SUBNET_NOTE8_LAT31.yaml',
cfg=dict(
type='mmrazor.AttentiveMobileNetV3',
arch_setting=dict(
kernel_size=[[3, 3, 1], [3, 7, 2], [3, 7, 2], [3, 7, 2], [3, 7, 2],
[3, 7, 2]],
num_blocks=[[1, 1, 1], [2, 4, 1], [2, 4, 1], [2, 4, 1], [2, 4, 1],
[2, 4, 1]],
expand_ratio=[[1, 1, 1], [3, 6, 1], [3, 6, 1], [3, 6, 1],
[3, 6, 1], [3, 6, 1], [6, 6, 1]],
num_out_channels=[[16, 16, 8], [16, 16, 8], [16, 24, 8],
[24, 40, 8], [40, 80, 8], [80, 112, 8],
[112, 160, 8], [1024, 1280, 256]]),
out_indices=(2, 4, 5),
stride_list=[1, 2, 2, 2, 1, 2],
with_se_list=[False, False, True, False, True, True],
act_cfg_list=[
'HSwish', 'ReLU', 'ReLU', 'ReLU', 'HSwish', 'HSwish', 'HSwish',
'HSwish', 'HSwish'
],
conv_cfg=dict(type='mmrazor.OFAConv2d'),
norm_cfg=dict(type='mmrazor.DynamicBatchNorm2d', momentum=0.1),
fine_grained_mode=True,
with_attentive_shortcut=False,
_scope_='mmrazor',
init_cfg=dict(
type='Pretrained',
checkpoint=
'https://download.openmmlab.com/mmrazor/v1/ofa/ofa_mobilenet_subnet_8xb256_in1k_note8_lat%4031ms_top1%4072.8_finetune%4025.py_20221214_0939-981a8b2a.pth',
prefix='architecture.backbone.')),
extra_prefix='backbone.')
default_scope = 'mmyolo'
default_hooks = dict(
timer=dict(type='IterTimerHook'),
logger=dict(type='LoggerHook', interval=50),
param_scheduler=dict(type='ParamSchedulerHook'),
checkpoint=dict(type='CheckpointHook', interval=10, max_keep_ckpts=3),
sampler_seed=dict(type='DistSamplerSeedHook'),
visualization=dict(type='mmdet.DetVisualizationHook'))
env_cfg = dict(
cudnn_benchmark=True,
mp_cfg=dict(mp_start_method='fork', opencv_num_threads=0),
dist_cfg=dict(backend='nccl'))
vis_backends = [dict(type='LocalVisBackend')]
visualizer = dict(
type='mmdet.DetLocalVisualizer',
vis_backends=[dict(type='LocalVisBackend')],
name='visualizer')
log_processor = dict(type='LogProcessor', window_size=50, by_epoch=True)
log_level = 'INFO'
load_from = None
resume = False
file_client_args = dict(backend='disk')
_file_client_args = dict(backend='disk')
tta_model = dict(
type='mmdet.DetTTAModel',
tta_cfg=dict(nms=dict(type='nms', iou_threshold=0.65), max_per_img=300))
img_scales = [(640, 640), (320, 320), (960, 960)]
_multiscale_resize_transforms = [
dict(
type='Compose',
transforms=[
dict(type='YOLOv5KeepRatioResize', scale=(640, 640)),
dict(
type='LetterResize',
scale=(640, 640),
allow_scale_up=False,
pad_val=dict(img=114))
]),
dict(
type='Compose',
transforms=[
dict(type='YOLOv5KeepRatioResize', scale=(320, 320)),
dict(
type='LetterResize',
scale=(320, 320),
allow_scale_up=False,
pad_val=dict(img=114))
]),
dict(
type='Compose',
transforms=[
dict(type='YOLOv5KeepRatioResize', scale=(960, 960)),
dict(
type='LetterResize',
scale=(960, 960),
allow_scale_up=False,
pad_val=dict(img=114))
])
]
tta_pipeline = [
dict(type='LoadImageFromFile', file_client_args=dict(backend='disk')),
dict(
type='TestTimeAug',
transforms=[[{
'type':
'Compose',
'transforms': [{
'type': 'YOLOv5KeepRatioResize',
'scale': (640, 640)
}, {
'type': 'LetterResize',
'scale': (640, 640),
'allow_scale_up': False,
'pad_val': {
'img': 114
}
}]
}, {
'type':
'Compose',
'transforms': [{
'type': 'YOLOv5KeepRatioResize',
'scale': (320, 320)
}, {
'type': 'LetterResize',
'scale': (320, 320),
'allow_scale_up': False,
'pad_val': {
'img': 114
}
}]
}, {
'type':
'Compose',
'transforms': [{
'type': 'YOLOv5KeepRatioResize',
'scale': (960, 960)
}, {
'type': 'LetterResize',
'scale': (960, 960),
'allow_scale_up': False,
'pad_val': {
'img': 114
}
}]
}],
[{
'type': 'mmdet.RandomFlip',
'prob': 1.0
}, {
'type': 'mmdet.RandomFlip',
'prob': 0.0
}], [{
'type': 'mmdet.LoadAnnotations',
'with_bbox': True
}],
[{
'type':
'mmdet.PackDetInputs',
'meta_keys':
('img_id', 'img_path', 'ori_shape', 'img_shape',
'scale_factor', 'pad_param', 'flip', 'flip_direction')
}]])
]
data_root = 'data/coco/'
train_ann_file = 'annotations/instances_train2017.json'
train_data_prefix = 'train2017/'
val_ann_file = 'annotations/instances_val2017.json'
val_data_prefix = 'val2017/'
num_classes = 80
train_batch_size_per_gpu = 16
train_num_workers = 10
persistent_workers = True
base_lr = 0.004
max_epochs = 300
num_epochs_stage2 = 20
model_test_cfg = dict(
multi_label=True,
nms_pre=30000,
score_thr=0.001,
nms=dict(type='nms', iou_threshold=0.65),
max_per_img=300)
img_scale = (960, 960)
random_resize_ratio_range = (0.5, 2.0)
mosaic_max_cached_images = 40
mixup_max_cached_images = 20
dataset_type = 'YOLOv5CocoDataset'
val_batch_size_per_gpu = 32
val_num_workers = 10
batch_shapes_cfg = dict(
type='BatchShapePolicy',
batch_size=32,
img_size=640,
size_divisor=32,
extra_pad_ratio=0.5)
deepen_factor = 0.167
widen_factor = 1.0
strides = [8, 16, 32]
norm_cfg = dict(type='BN')
lr_start_factor = 1e-05
dsl_topk = 13
loss_cls_weight = 1.0
loss_bbox_weight = 2.0
qfl_beta = 2.0
weight_decay = 0.05
save_checkpoint_intervals = 10
val_interval_stage2 = 1
max_keep_ckpts = 3
model = dict(
type='YOLODetector',
data_preprocessor=dict(
type='YOLOv5DetDataPreprocessor',
mean=[103.53, 116.28, 123.675],
std=[57.375, 57.12, 58.395],
bgr_to_rgb=False),
backbone=dict(
type='mmrazor.sub_model',
fix_subnet=
'https://download.openmmlab.com/mmrazor/v1/yolo_nas_backbone/OFA_SUBNET_NOTE8_LAT31.yaml',
cfg=dict(
type='mmrazor.AttentiveMobileNetV3',
arch_setting=dict(
kernel_size=[[3, 3, 1], [3, 7, 2], [3, 7, 2], [3, 7, 2],
[3, 7, 2], [3, 7, 2]],
num_blocks=[[1, 1, 1], [2, 4, 1], [2, 4, 1], [2, 4, 1],
[2, 4, 1], [2, 4, 1]],
expand_ratio=[[1, 1, 1], [3, 6, 1], [3, 6, 1], [3, 6, 1],
[3, 6, 1], [3, 6, 1], [6, 6, 1]],
num_out_channels=[[16, 16, 8], [16, 16, 8], [16, 24, 8],
[24, 40, 8], [40, 80, 8], [80, 112, 8],
[112, 160, 8], [1024, 1280, 256]]),
out_indices=(2, 4, 5),
stride_list=[1, 2, 2, 2, 1, 2],
with_se_list=[False, False, True, False, True, True],
act_cfg_list=[
'HSwish', 'ReLU', 'ReLU', 'ReLU', 'HSwish', 'HSwish', 'HSwish',
'HSwish', 'HSwish'
],
conv_cfg=dict(type='mmrazor.OFAConv2d'),
norm_cfg=dict(type='mmrazor.DynamicBatchNorm2d', momentum=0.1),
fine_grained_mode=True,
with_attentive_shortcut=False,
_scope_='mmrazor',
init_cfg=dict(
type='Pretrained',
checkpoint=
'https://download.openmmlab.com/mmrazor/v1/ofa/ofa_mobilenet_subnet_8xb256_in1k_note8_lat%4031ms_top1%4072.8_finetune%4025.py_20221214_0939-981a8b2a.pth',
prefix='architecture.backbone.')),
extra_prefix='backbone.'),
neck=dict(
type='CSPNeXtPAFPN',
deepen_factor=0.167,
widen_factor=1.0,
in_channels=[40, 112, 160],
out_channels=40,
num_csp_blocks=3,
expand_ratio=0.5,
norm_cfg=dict(type='BN'),
act_cfg=dict(type='SiLU', inplace=True)),
bbox_head=dict(
type='RTMDetHead',
head_module=dict(
type='RTMDetSepBNHeadModule',
num_classes=80,
in_channels=40,
stacked_convs=2,
feat_channels=40,
norm_cfg=dict(type='BN'),
act_cfg=dict(type='SiLU', inplace=True),
share_conv=True,
pred_kernel_size=1,
featmap_strides=[8, 16, 32],
widen_factor=1.0),
prior_generator=dict(
type='mmdet.MlvlPointGenerator', offset=0, strides=[8, 16, 32]),
bbox_coder=dict(type='DistancePointBBoxCoder'),
loss_cls=dict(
type='mmdet.QualityFocalLoss',
use_sigmoid=True,
beta=2.0,
loss_weight=1.0),
loss_bbox=dict(type='mmdet.GIoULoss', loss_weight=2.0)),
train_cfg=dict(
assigner=dict(
type='BatchDynamicSoftLabelAssigner',
num_classes=80,
topk=13,
iou_calculator=dict(type='mmdet.BboxOverlaps2D')),
allowed_border=-1,
pos_weight=-1,
debug=False),
test_cfg=dict(
multi_label=True,
nms_pre=1000,
min_bbox_size=0,
score_thr=0.05,
nms=dict(type='nms', iou_threshold=0.6),
max_per_img=100))
train_pipeline = [
dict(type='LoadImageFromFile', file_client_args=dict(backend='disk')),
dict(type='LoadAnnotations', with_bbox=True),
dict(
type='Mosaic',
img_scale=(960, 960),
use_cached=True,
max_cached_images=20,
random_pop=False,
pad_val=114.0),
dict(
type='mmdet.RandomResize',
scale=(1280, 1280),
ratio_range=(0.5, 2.0),
resize_type='mmdet.Resize',
keep_ratio=True),
dict(type='mmdet.RandomCrop', crop_size=(960, 960)),
dict(type='mmdet.YOLOXHSVRandomAug'),
dict(type='mmdet.RandomFlip', prob=0.5),
dict(type='mmdet.Pad', size=(960, 960), pad_val=dict(img=(114, 114, 114))),
dict(
type='YOLOXMixUp',
img_scale=(960, 960),
ratio_range=(1.0, 1.0),
max_cached_images=10,
use_cached=True,
random_pop=False,
pad_val=(114, 114, 114),
prob=0.5),
dict(type='mmdet.PackDetInputs')
]
train_pipeline_stage2 = [
dict(type='LoadImageFromFile', file_client_args=dict(backend='disk')),
dict(type='LoadAnnotations', with_bbox=True),
dict(
type='mmdet.RandomResize',
scale=(960, 960),
ratio_range=(0.5, 2.0),
resize_type='mmdet.Resize',
keep_ratio=True),
dict(type='mmdet.RandomCrop', crop_size=(960, 960)),
dict(type='mmdet.YOLOXHSVRandomAug'),
dict(type='mmdet.RandomFlip', prob=0.5),
dict(type='mmdet.Pad', size=(960, 960), pad_val=dict(img=(114, 114, 114))),
dict(type='mmdet.PackDetInputs')
]
test_pipeline = [
dict(type='LoadImageFromFile', file_client_args=dict(backend='disk')),
dict(type='mmdet.Resize', scale=(960, 960), keep_ratio=True),
dict(type='mmdet.Pad', size=(960, 960), pad_val=dict(img=(114, 114, 114))),
dict(type='LoadAnnotations', with_bbox=True, _scope_='mmdet'),
dict(
type='mmdet.PackDetInputs',
meta_keys=('img_id', 'img_path', 'ori_shape', 'img_shape',
'scale_factor'))
]
train_dataloader = dict(
batch_size=16,
num_workers=10,
persistent_workers=True,
pin_memory=True,
collate_fn=dict(type='yolov5_collate'),
sampler=dict(type='DefaultSampler', shuffle=True),
dataset=dict(
type='YOLOv5CocoDataset',
data_root='data/coco/',
ann_file='annotations/instances_train2017.json',
data_prefix=dict(img='train2017/'),
filter_cfg=dict(filter_empty_gt=True, min_size=32),
pipeline=[
dict(
type='LoadImageFromFile',
file_client_args=dict(backend='disk')),
dict(type='LoadAnnotations', with_bbox=True),
dict(
type='Mosaic',
img_scale=(960, 960),
use_cached=True,
max_cached_images=20,
random_pop=False,
pad_val=114.0),
dict(
type='mmdet.RandomResize',
scale=(1280, 1280),
ratio_range=(0.5, 2.0),
resize_type='mmdet.Resize',
keep_ratio=True),
dict(type='mmdet.RandomCrop', crop_size=(960, 960)),
dict(type='mmdet.YOLOXHSVRandomAug'),
dict(type='mmdet.RandomFlip', prob=0.5),
dict(
type='mmdet.Pad',
size=(960, 960),
pad_val=dict(img=(114, 114, 114))),
dict(
type='YOLOXMixUp',
img_scale=(960, 960),
ratio_range=(1.0, 1.0),
max_cached_images=10,
use_cached=True,
random_pop=False,
pad_val=(114, 114, 114),
prob=0.5),
dict(type='mmdet.PackDetInputs')
]))
val_dataloader = dict(
batch_size=32,
num_workers=10,
persistent_workers=True,
pin_memory=True,
drop_last=False,
sampler=dict(type='DefaultSampler', shuffle=False),
dataset=dict(
type='YOLOv5CocoDataset',
data_root='data/coco/',
ann_file='annotations/instances_val2017.json',
data_prefix=dict(img='val2017/'),
test_mode=True,
batch_shapes_cfg=None,
pipeline=[
dict(
type='LoadImageFromFile',
file_client_args=dict(backend='disk')),
dict(type='mmdet.Resize', scale=(960, 960), keep_ratio=True),
dict(
type='mmdet.Pad',
size=(960, 960),
pad_val=dict(img=(114, 114, 114))),
dict(type='LoadAnnotations', with_bbox=True, _scope_='mmdet'),
dict(
type='mmdet.PackDetInputs',
meta_keys=('img_id', 'img_path', 'ori_shape', 'img_shape',
'scale_factor'))
]))
test_dataloader = dict(
batch_size=32,
num_workers=10,
persistent_workers=True,
pin_memory=True,
drop_last=False,
sampler=dict(type='DefaultSampler', shuffle=False),
dataset=dict(
type='YOLOv5CocoDataset',
data_root='data/coco/',
ann_file='annotations/instances_val2017.json',
data_prefix=dict(img='val2017/'),
test_mode=True,
batch_shapes_cfg=None,
pipeline=[
dict(
type='LoadImageFromFile',
file_client_args=dict(backend='disk')),
dict(type='mmdet.Resize', scale=(960, 960), keep_ratio=True),
dict(
type='mmdet.Pad',
size=(960, 960),
pad_val=dict(img=(114, 114, 114))),
dict(type='LoadAnnotations', with_bbox=True, _scope_='mmdet'),
dict(
type='mmdet.PackDetInputs',
meta_keys=('img_id', 'img_path', 'ori_shape', 'img_shape',
'scale_factor'))
]))
val_evaluator = dict(
type='mmdet.CocoMetric',
proposal_nums=(100, 1, 10),
ann_file='data/coco/annotations/instances_val2017.json',
metric='bbox')
test_evaluator = dict(
type='mmdet.CocoMetric',
proposal_nums=(100, 1, 10),
ann_file='data/coco/annotations/instances_val2017.json',
metric='bbox')
optim_wrapper = dict(
type='OptimWrapper',
optimizer=dict(type='AdamW', lr=0.004, weight_decay=0.05),
paramwise_cfg=dict(
norm_decay_mult=0, bias_decay_mult=0, bypass_duplicate=True))
param_scheduler = [
dict(
type='LinearLR', start_factor=1e-05, by_epoch=False, begin=0,
end=1000),
dict(
type='CosineAnnealingLR',
eta_min=0.0002,
begin=150,
end=300,
T_max=150,
by_epoch=True,
convert_to_iter_based=True)
]
custom_hooks = [
dict(
type='EMAHook',
ema_type='ExpMomentumEMA',
momentum=0.0002,
update_buffers=True,
strict_load=False,
priority=49),
dict(
type='mmdet.PipelineSwitchHook',
switch_epoch=280,
switch_pipeline=[
dict(
type='LoadImageFromFile',
file_client_args=dict(backend='disk')),
dict(type='LoadAnnotations', with_bbox=True),
dict(
type='mmdet.RandomResize',
scale=(960, 960),
ratio_range=(0.5, 2.0),
resize_type='mmdet.Resize',
keep_ratio=True),
dict(type='mmdet.RandomCrop', crop_size=(960, 960)),
dict(type='mmdet.YOLOXHSVRandomAug'),
dict(type='mmdet.RandomFlip', prob=0.5),
dict(
type='mmdet.Pad',
size=(960, 960),
pad_val=dict(img=(114, 114, 114))),
dict(type='mmdet.PackDetInputs')
])
]
train_cfg = dict(
type='EpochBasedTrainLoop',
max_epochs=300,
val_interval=10,
dynamic_intervals=[(280, 1)])
val_cfg = dict(type='ValLoop')
test_cfg = dict(type='TestLoop')
checkpoint = 'https://download.openmmlab.com/mmdetection/v3.0/rtmdet/cspnext_rsb_pretrain/cspnext-s_imagenet_600e.pth'
checkpoint_file = 'https://download.openmmlab.com/mmrazor/v1/ofa/ofa_mobilenet_subnet_8xb256_in1k_note8_lat%4031ms_top1%4072.8_finetune%4025.py_20221214_0939-981a8b2a.pth'
fix_subnet = 'https://download.openmmlab.com/mmrazor/v1/yolo_nas_backbone/OFA_SUBNET_NOTE8_LAT31.yaml'
channels = [40, 112, 160]
find_unused_parameters = True
launcher = 'none'
work_dir = './work_dirs/rtmdet_tiny_ofa_lat31_syncbn_16xb16-300e_coco'
The error
raceback (most recent call last):
File "/home/pika/miniconda3/envs/mmyolo/lib/python3.8/site-packages/mmengine/registry/build_functions.py", line 121, in build_from_cfg
obj = obj_cls(**args) # type: ignore
File "/home/pika/mmrazor/mmrazor/models/architectures/backbones/searchable_mobilenet_v3.py", line 90, in __init__
super().__init__(init_cfg)
TypeError: __init__() takes 1 positional argument but 2 were given
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/pika/miniconda3/envs/mmyolo/lib/python3.8/site-packages/mmengine/registry/build_functions.py", line 121, in build_from_cfg
obj = obj_cls(**args) # type: ignore
File "/home/pika/mmrazor/mmrazor/registry/registry.py", line 118, in sub_model
model = MODELS.build(cfg)
File "/home/pika/miniconda3/envs/mmyolo/lib/python3.8/site-packages/mmengine/registry/registry.py", line 545, in build
return self.build_func(cfg, *args, **kwargs, registry=self)
File "/home/pika/mmrazor/mmrazor/registry/registry.py", line 49, in build_razor_model_from_cfg
razor_model = build_from_cfg(cfg, registry, default_args)
File "/home/pika/miniconda3/envs/mmyolo/lib/python3.8/site-packages/mmengine/registry/build_functions.py", line 135, in build_from_cfg
raise type(e)(
TypeError: class `AttentiveMobileNetV3` in mmrazor/models/architectures/backbones/searchable_mobilenet_v3.py: __init__() takes 1 positional argument but 2 were given
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/pika/miniconda3/envs/mmyolo/lib/python3.8/site-packages/mmengine/registry/build_functions.py", line 121, in build_from_cfg
obj = obj_cls(**args) # type: ignore
File "/home/pika/mmyolo/mmyolo/models/detectors/yolo_detector.py", line 41, in __init__
super().__init__(
File "/home/pika/miniconda3/envs/mmyolo/lib/python3.8/site-packages/mmdet/models/detectors/single_stage.py", line 30, in __init__
self.backbone = MODELS.build(backbone)
File "/home/pika/miniconda3/envs/mmyolo/lib/python3.8/site-packages/mmengine/registry/registry.py", line 545, in build
return self.build_func(cfg, *args, **kwargs, registry=self)
File "/home/pika/miniconda3/envs/mmyolo/lib/python3.8/site-packages/mmengine/registry/build_functions.py", line 241, in build_model_from_cfg
return build_from_cfg(cfg, registry, default_args)
File "/home/pika/miniconda3/envs/mmyolo/lib/python3.8/site-packages/mmengine/registry/build_functions.py", line 135, in build_from_cfg
raise type(e)(
TypeError: class `sub_model` in mmrazor/registry/registry.py: class `AttentiveMobileNetV3` in mmrazor/models/architectures/backbones/searchable_mobilenet_v3.py: __init__() takes 1 positional argument but 2 were given
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "tools/train.py", line 115, in <module>
main()
File "tools/train.py", line 104, in main
runner = Runner.from_cfg(cfg)
File "/home/pika/miniconda3/envs/mmyolo/lib/python3.8/site-packages/mmengine/runner/runner.py", line 439, in from_cfg
runner = cls(
File "/home/pika/miniconda3/envs/mmyolo/lib/python3.8/site-packages/mmengine/runner/runner.py", line 406, in __init__
self.model = self.build_model(model)
File "/home/pika/miniconda3/envs/mmyolo/lib/python3.8/site-packages/mmengine/runner/runner.py", line 813, in build_model
model = MODELS.build(model)
File "/home/pika/miniconda3/envs/mmyolo/lib/python3.8/site-packages/mmengine/registry/registry.py", line 545, in build
return self.build_func(cfg, *args, **kwargs, registry=self)
File "/home/pika/miniconda3/envs/mmyolo/lib/python3.8/site-packages/mmengine/registry/build_functions.py", line 241, in build_model_from_cfg
return build_from_cfg(cfg, registry, default_args)
File "/home/pika/miniconda3/envs/mmyolo/lib/python3.8/site-packages/mmengine/registry/build_functions.py", line 135, in build_from_cfg
raise type(e)(
TypeError: class `YOLODetector` in mmyolo/models/detectors/yolo_detector.py: class `sub_model` in mmrazor/registry/registry.py: class `AttentiveMobileNetV3` in mmrazor/models/architectures/backbones/searchable_mobilenet_v3.py: __init__() takes 1 positional argument but 2 were given
How is the config passing two arguments to the AttentiveMobileNetV3? @hhaAndroid I have checkout through different points in history for both mmyolo and mmrazor for the pull requests related to this configs, did 'pip install -v -e .' to ensure the changes are applied, but without success.
Now i am trying to figure out what exactly is passed to the AttentiveMobileNetV3, but without success.
Reset on pull request, issue still persist. #453
这应该是mmcls合并到mmpretrain造成的问题,需要单独安装mmcls,方法如下,希望对你有所帮助 解决方法: mmpretrain 中有mmcls分支,升级至 1.0.0rc2以上版本 git clone -b 1.x https://github.com/open-mmlab/mmclassification.git cd mmclassification mim install -e .