Skip to content
New issue

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

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

Already on GitHub? # to your account

TypeError: FastRCNN: AVARoIHead: LFBInferHead: __init__() got an unexpected keyword argument 'pretrained' #1382

Closed
michael-camilleri opened this issue Jan 12, 2022 · 3 comments · Fixed by #1386

Comments

@michael-camilleri
Copy link
Contributor

Description

I am trying to run Spatio-Temporal Action Localisation on a small sample of the AVA dataset (to get me started with the library), but am running into an issue with the LFB model. Specifically, the generation of the LFB features yields the following Exception:
"TypeError: FastRCNN: AVARoIHead: LFBInferHead: init() got an unexpected keyword argument 'pretrained'"

Reproduction

Installation

I installed MMCV, MMDet and MMAction2 from source and also from pip at different points to debug the error (each time tearing down the conda environment), but the issue remains.

This gives me the following envrionment:

sys.platform: linux
Python: 3.7.11 (default, Jul 27 2021, 14:32:16) [GCC 7.5.0]
CUDA available: True
GPU 0: Quadro K620
CUDA_HOME: /usr/local/cuda-10.2
NVCC: Cuda compilation tools, release 10.2, V10.2.89
GCC: gcc (Ubuntu 7.5.0-3ubuntu1~18.04) 7.5.0
PyTorch: 1.10.1+cu102
PyTorch compiling details: PyTorch built with:
  - GCC 7.3
  - C++ Version: 201402
  - Intel(R) Math Kernel Library Version 2020.0.0 Product Build 20191122 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 10.2
  - 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_70,code=sm_70
  - CuDNN 7.6.5
  - Magma 2.5.2
  - Build settings: BLAS_INFO=mkl, BUILD_TYPE=Release, CUDA_VERSION=10.2, CUDNN_VERSION=7.6.5, 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+cu102
OpenCV: 4.5.5
MMCV: 1.4.3
MMCV Compiler: GCC 7.5
MMCV CUDA Compiler: 10.2
MMAction2: 0.21.0+0dde60b

Setup (Code/DataSet)

python tools/test.py PATH/TO/CONFIG PATH/TO/CHECKPOINT --eval mAP

Stack Trace:

Exception ignored in: <function LFBInferHead.__del__ at 0x7fe020a744d0>
Traceback (most recent call last):
  File "[home]/MMAction2/mmaction/models/heads/lfb_infer_head.py", line 88, in __del__
    assert len(self.all_features) == len(self.all_metadata), (
  File "[home]/miniconda3/envs/py3mma/lib/python3.7/site-packages/torch/nn/modules/module.py", line 1178, in __getattr__
    type(self).__name__, name))
AttributeError: 'LFBInferHead' object has no attribute 'all_features'
Traceback (most recent call last):
  File "[home]/MMCV/mmcv/utils/registry.py", line 52, in build_from_cfg
    return obj_cls(**args)
TypeError: __init__() got an unexpected keyword argument 'pretrained'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "[home]/MMCV/mmcv/utils/registry.py", line 52, in build_from_cfg
    return obj_cls(**args)
  File "[home]/MMDet/mmdet/models/roi_heads/base_roi_head.py", line 27, in __init__
    self.shared_head = build_shared_head(shared_head)
  File "[home]/MMDet/mmdet/models/builder.py", line 35, in build_shared_head
    return SHARED_HEADS.build(cfg)
  File "[home]/MMCV/mmcv/utils/registry.py", line 212, in build
    return self.build_func(*args, **kwargs, registry=self)
  File "[home]/MMCV/mmcv/cnn/builder.py", line 27, in build_model_from_cfg
    return build_from_cfg(cfg, registry, default_args)
  File "[home]/MMCV/mmcv/utils/registry.py", line 55, in build_from_cfg
    raise type(e)(f'{obj_cls.__name__}: {e}')
TypeError: LFBInferHead: __init__() got an unexpected keyword argument 'pretrained'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "[home]/MMCV/mmcv/utils/registry.py", line 52, in build_from_cfg
    return obj_cls(**args)
  File "[home]/MMDet/mmdet/models/detectors/fast_rcnn.py", line 25, in __init__
    init_cfg=init_cfg)
  File "[home]/MMDet/mmdet/models/detectors/two_stage.py", line 50, in __init__
    self.roi_head = build_head(roi_head)
  File "[home]/MMDet/mmdet/models/builder.py", line 40, in build_head
    return HEADS.build(cfg)
  File "[home]/MMCV/mmcv/utils/registry.py", line 212, in build
    return self.build_func(*args, **kwargs, registry=self)
  File "[home]/MMCV/mmcv/cnn/builder.py", line 27, in build_model_from_cfg
    return build_from_cfg(cfg, registry, default_args)
  File "[home]/MMCV/mmcv/utils/registry.py", line 55, in build_from_cfg
    raise type(e)(f'{obj_cls.__name__}: {e}')
TypeError: AVARoIHead: LFBInferHead: __init__() got an unexpected keyword argument 'pretrained'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "tools/test.py", line 365, in <module>
    main()
  File "tools/test.py", line 350, in main
    outputs = inference_pytorch(args, cfg, distributed, data_loader)
  File "tools/test.py", line 146, in inference_pytorch
    cfg.model, train_cfg=None, test_cfg=cfg.get('test_cfg'))
  File "[home]/MMAction2/mmaction/models/builder.py", line 81, in build_model
    return build_detector(cfg, train_cfg, test_cfg)
  File "[home]/MMDet/mmdet/models/builder.py", line 59, in build_detector
    cfg, default_args=dict(train_cfg=train_cfg, test_cfg=test_cfg))
  File "[home]/MMCV/mmcv/utils/registry.py", line 212, in build
    return self.build_func(*args, **kwargs, registry=self)
  File "[home]/MMCV/mmcv/cnn/builder.py", line 27, in build_model_from_cfg
    return build_from_cfg(cfg, registry, default_args)
  File "[home]/MMCV/mmcv/utils/registry.py", line 55, in build_from_cfg
    raise type(e)(f'{obj_cls.__name__}: {e}')
TypeError: FastRCNN: AVARoIHead: LFBInferHead: __init__() got an unexpected keyword argument 'pretrained'
@dreamerlin
Copy link
Collaborator

@michael-camilleri
Copy link
Contributor Author

Thanks

It seems that class already contains pretrained in its __init__().

Instead, I added pretrained in the __init__() of LFBInferHead instead. This seems to be working

@michael-camilleri
Copy link
Contributor Author

I have created a pull request for this: #1386

@kennymckormick kennymckormick linked a pull request Jan 15, 2022 that will close this issue
kennymckormick pushed a commit that referenced this issue Jan 15, 2022
* Added  argument to LFBInferHead:__init__()

* Fixed bug in assert statement printout

* Finalised proper formatting

* Fixed another related issue with pretrained
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants