Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TypeError: FasterRCNN.__init__() got an unexpected keyword argument 'bbox_head' #11709

Open
Grushus opened this issue May 13, 2024 · 0 comments
Assignees

Comments

@Grushus
Copy link

Grushus commented May 13, 2024

Thanks for your error report and we appreciate it a lot.

Describe the bug
When training FasterRCNN model i get TypeError got an unexpected keyword argument 'bbox_head'.
Model used: faster-rcnn_r101_fpn_1x_coco.py

Reproduction

I used the train.py script

This is the config file


# Inherit and overwrite part of the config based on this config
_base_ = 'faster-rcnn_r101_fpn_1x_coco.py'

data_root = '/home/MMDetection/models_test/augmentum_output'

metainfo = {
    'classes': ('blue_helmet', 'no_helmet', 'red_helmet', 'white_helmet', 'yellow_helmet')
}

train_dataloader = dict(
    batch_size=20,
    dataset=dict(
        data_root=data_root,
        metainfo=metainfo,
        data_prefix=dict(img='train/images'),
        ann_file='/home/MMDetection/models_test/augmentum_output/train/coco.json'))

val_dataloader = dict(
    dataset=dict(
        data_root=data_root,
        metainfo=metainfo,
        data_prefix=dict(img='val/images'),
        ann_file='/home/MMDetection/models_test/augmentum_output/val/coco.json'))

test_dataloader = dict(
    dataset=dict(
        data_root=data_root,
        metainfo=metainfo,
        data_prefix=dict(img='test/images'),
        ann_file='/home/MMDetection/models_test/augmentum_output/test/coco.json'))

val_evaluator = dict(ann_file='/home/MMDetection/models_test/augmentum_output/val/coco.json')

test_evaluator = dict(ann_file='/home/MMDetection/models_test/augmentum_output/test/coco.json')

model = dict(bbox_head=dict(num_classes=5))



train_cfg = dict(type='EpochBasedTrainLoop', 
                    max_epochs=5, 
                    val_interval=1)

default_hooks = dict(
    checkpoint=dict(
        type="CheckpointHook",
        save_best='coco/bbox_mAP',
        rule='greater',
        interval=2,
        save_begin=4
    )
)

# load COCO pre-trained weight
load_from = '/home/MMDetection/models_test/checkpoint/faster_rcnn_r101_fpn_1x_coco_20200130-f513f705.pth'


  1. Did you make any modifications on the code or config? Did you understand what you have modified?
    Yes

  2. What dataset did you use?
    Custom head vs helmet dataset

Environment

sys.platform: linux
Python: 3.10.12 (main, Jun 11 2023, 05:26:28) [GCC 11.4.0]
CUDA available: True
MUSA available: False
numpy_random_seed: 2147483648
GPU 0: NVIDIA A100-SXM4-40GB
CUDA_HOME: /usr/local/cuda
NVCC: Cuda compilation tools, release 12.2, V12.2.140
GCC: x86_64-linux-gnu-gcc (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0
PyTorch: 2.1.0a0+32f93b1
PyTorch compiling details: PyTorch built with:
  - GCC 11.2
  - C++ Version: 201703
  - Intel(R) oneAPI Math Kernel Library Version 2021.1-Product Build 20201104 for Intel(R) 64 architecture applications
  - Intel(R) MKL-DNN v2.7.3 (Git Hash N/A)
  - OpenMP 201511 (a.k.a. OpenMP 4.5)
  - LAPACK is enabled (usually provided by MKL)
  - NNPACK is enabled
  - CPU capability usage: AVX2
  - CUDA Runtime 12.2
  - NVCC architecture flags: -gencode;arch=compute_52,code=sm_52;-gencode;arch=compute_60,code=sm_60;-gencode;arch=compute_61,code=sm_61;-gencode;arch=compute_70,code=sm_70;-gencode;arch=compute_72,code=sm_72;-gencode;arch=compute_75,code=sm_75;-gencode;arch=compute_80,code=sm_80;-gencode;arch=compute_86,code=sm_86;-gencode;arch=compute_87,code=sm_87;-gencode;arch=compute_90,code=sm_90;-gencode;arch=compute_90,code=compute_90
  - CuDNN 8.9.5
  - Magma 2.6.2
  - Build settings: BLAS_INFO=mkl, BUILD_TYPE=Release, CUDA_VERSION=12.2, CUDNN_VERSION=8.9.5, CXX_COMPILER=/opt/rh/gcc-toolset-11/root/usr/bin/c++, CXX_FLAGS=-fno-gnu-unique -D_GLIBCXX_USE_CXX11_ABI=1 -fvisibility-inlines-hidden -DUSE_PTHREADPOOL -DNDEBUG -DUSE_KINETO -DLIBKINETO_NOROCTRACER -DUSE_FBGEMM -DUSE_QNNPACK -DUSE_PYTORCH_QNNPACK -DUSE_XNNPACK -DSYMBOLICATE_MOBILE_DEBUG_HANDLE -O2 -fPIC -Wall -Wextra -Werror=return-type -Werror=non-virtual-dtor -Werror=range-loop-construct -Werror=bool-operation -Wnarrowing -Wno-missing-field-initializers -Wno-type-limits -Wno-array-bounds -Wno-unknown-pragmas -Wno-unused-parameter -Wno-unused-function -Wno-unused-result -Wno-strict-overflow -Wno-strict-aliasing -Wno-stringop-overflow -Wno-psabi -Wno-error=pedantic -Wno-error=old-style-cast -Wno-invalid-partial-specialization -Wno-unused-private-field -Wno-aligned-allocation-unavailable -Wno-missing-braces -fdiagnostics-color=always -faligned-new -Wno-unused-but-set-variable -Wno-maybe-uninitialized -fno-math-errno -fno-trapping-math -Werror=format -Werror=cast-function-type -Wno-stringop-overflow, LAPACK_INFO=mkl, PERF_WITH_AVX=1, PERF_WITH_AVX2=1, PERF_WITH_AVX512=1, TORCH_DISABLE_GPU_ASSERTS=ON, TORCH_VERSION=2.1.0, 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=1, USE_NNPACK=ON, USE_OPENMP=ON, USE_ROCM=OFF, 

TorchVision: 0.16.0a0
OpenCV: 4.7.0
MMEngine: 0.10.4
MMDetection: 3.2.0+```

**Error traceback**
If applicable, paste the error trackback here.

```none
Traceback (most recent call last):
  File "/home/MMDetection/mmdetection/tools/train.py", line 121, in <module>
    main()
  File "/home/MMDetection/mmdetection/tools/train.py", line 110, in main
    runner = Runner.from_cfg(cfg)
  File "/usr/local/lib/python3.10/dist-packages/mmengine/runner/runner.py", line 462, in from_cfg
    runner = cls(
  File "/usr/local/lib/python3.10/dist-packages/mmengine/runner/runner.py", line 429, in __init__
    self.model = self.build_model(model)
  File "/usr/local/lib/python3.10/dist-packages/mmengine/runner/runner.py", line 836, in build_model
    model = MODELS.build(model)
  File "/usr/local/lib/python3.10/dist-packages/mmengine/registry/registry.py", line 570, in build
    return self.build_func(cfg, *args, **kwargs, registry=self)
  File "/usr/local/lib/python3.10/dist-packages/mmengine/registry/build_functions.py", line 232, in build_model_from_cfg
    return build_from_cfg(cfg, registry, default_args)
  File "/usr/local/lib/python3.10/dist-packages/mmengine/registry/build_functions.py", line 121, in build_from_cfg
    obj = obj_cls(**args)  # type: ignore
TypeError: FasterRCNN.__init__() got an unexpected keyword argument 'bbox_head'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants