open-mmlab / mmdetection

OpenMMLab Detection Toolbox and Benchmark
https://mmdetection.readthedocs.io
Apache License 2.0
29.24k stars 9.41k forks source link

TypeError: __init__() missing 4 required positional arguments: 'casting', 'from_', 'to', and 'i' #5307

Closed kevins99 closed 2 years ago

kevins99 commented 3 years ago

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

Describe the bug While training a custom dataset on RefineMask(https://github.com/zhanggang001/RefineMask), I get the following error

Traceback (most recent call last):
  File "./tools/train_pascal.py", line 65, in <module>
    meta=meta)
  File "/home2/kevins99/RefineMask/mmdet/apis/train.py", line 145, in train_detector
    runner.run(data_loaders, cfg.workflow, cfg.total_epochs)
  File "/home2/kevins99/anaconda3/envs/refinemask/lib/python3.7/site-packages/mmcv/runner/epoch_based_runner.py", line 122, in run
    epoch_runner(data_loaders[i], **kwargs)
  File "/home2/kevins99/anaconda3/envs/refinemask/lib/python3.7/site-packages/mmcv/runner/epoch_based_runner.py", line 27, in train
    for i, data_batch in enumerate(data_loader):
  File "/home2/kevins99/anaconda3/envs/refinemask/lib/python3.7/site-packages/torch/utils/data/dataloader.py", line 345, in __next__
    data = self._next_data()
  File "/home2/kevins99/anaconda3/envs/refinemask/lib/python3.7/site-packages/torch/utils/data/dataloader.py", line 856, in _next_data
    return self._process_data(data)
  File "/home2/kevins99/anaconda3/envs/refinemask/lib/python3.7/site-packages/torch/utils/data/dataloader.py", line 881, in _process_data
    data.reraise()
  File "/home2/kevins99/anaconda3/envs/refinemask/lib/python3.7/site-packages/torch/_utils.py", line 395, in reraise
    raise self.exc_type(msg)
TypeError: __init__() missing 4 required positional arguments: 'casting', 'from_', 'to', and 'i'

This occurs when I run the training script. I have converted my dataset into the COCO annotation format and have ensured that my instance IDs do NOT repeat and also that my Polygons are sent as an array of polygons(https://discuss.pytorch.org/t/bug-in-pytorch-with-yolact/110573). The script runs perfectly with the default settings provided for COCO. Reproduction

  1. What command or script did you run?
python ./tools/train.py ./configs/refinemask/pascal/r50-refinemask-2.py 
  1. Did you make any modifications on the code or config? Did you understand what you have modified? I changed the number of classes in the relevant areas of the config file, the path of the DATA_ROOT folder and the annotations file. Further, in the dataloader I have replaced the COCO classes with the relevant classes that I need.

  2. What dataset did you use? I am currently using the PascalParts dataset(converted to the COCO format for Object level instance Segmentation). I have ensured that all the keys are present. Environment

    
    sys.platform: linux
    Python: 3.7.10 (default, Feb 26 2021, 18:47:35) [GCC 7.3.0]
    CUDA available: True
    CUDA_HOME: /usr/local/cuda
    NVCC: Cuda compilation tools, release 10.2, V10.2.89
    GPU 0: GeForce GTX 1080 Ti
    GCC: gcc (Ubuntu 5.5.0-12ubuntu1~16.04) 5.5.0 20171010
    PyTorch: 1.5.0
    PyTorch compiling details: PyTorch built with:
    - GCC 7.3
    - C++ Version: 201402
    - Intel(R) oneAPI Math Kernel Library Version 2021.2-Product Build 20210312 for Intel(R) 64 architecture applications
    - Intel(R) MKL-DNN v0.21.1 (Git Hash 7d2fd500bc78936d1d648ca713b901012f470dbc)
    - OpenMP 201511 (a.k.a. OpenMP 4.5)
    - 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_61,code=sm_61;-gencode;arch=compute_70,code=sm_70;-gencode;arch=compute_75,code=sm_75;-gencode;arch=compute_37,code=compute_37
    - CuDNN 7.6.5
    - Magma 2.5.2
    - Build settings: BLAS=MKL, BUILD_TYPE=Release, CXX_FLAGS= -Wno-deprecated -fvisibility-inlines-hidden -fopenmp -DNDEBUG -DUSE_FBGEMM -DUSE_QNNPACK -DUSE_PYTORCH_QNNPACK -DUSE_XNNPACK -DUSE_INTERNAL_THREADPOOL_IMPL -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-strict-overflow -Wno-strict-aliasing -Wno-error=deprecated-declarations -Wno-stringop-overflow -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, PERF_WITH_AVX=1, PERF_WITH_AVX2=1, PERF_WITH_AVX512=1, USE_CUDA=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, USE_STATIC_DISPATCH=OFF, 

TorchVision: 0.6.0a0+82fd1c8 OpenCV: 4.5.2 MMCV: 1.0.5 MMDetection: ('2.3.0',) MMDetection Compiler: GCC 5.5 MMDetection CUDA Compiler: 10.2


**Error traceback**

```none
loading annotations into memory...
Done (t=1.94s)
creating index...
index created!
loading annotations into memory...
Done (t=2.00s)
creating index...
index created!
CFG WORKFLOW [('train', 1)]
data loader [<torch.utils.data.dataloader.DataLoader object at 0x1490de6e3550>]
2021-06-06 22:02:51,965 - mmdet - INFO - Start running, host: kevins99@gnode39, work_dir: /home2/kevins99/RefineMask/checkpoint
[06/06 22:02:51] mmdet INFO: Start running, host: kevins99@gnode39, work_dir: /home2/kevins99/RefineMask/checkpoint
2021-06-06 22:02:51,965 - mmdet - INFO - workflow: [('train', 1)], max: 12 epochs
[06/06 22:02:51] mmdet INFO: workflow: [('train', 1)], max: 12 epochs
Traceback (most recent call last):
  File "./tools/train_pascal.py", line 65, in <module>
    meta=meta)
  File "/home2/kevins99/RefineMask/mmdet/apis/train.py", line 145, in train_detector
    runner.run(data_loaders, cfg.workflow, cfg.total_epochs)
  File "/home2/kevins99/anaconda3/envs/refinemask/lib/python3.7/site-packages/mmcv/runner/epoch_based_runner.py", line 122, in run
    epoch_runner(data_loaders[i], **kwargs)
  File "/home2/kevins99/anaconda3/envs/refinemask/lib/python3.7/site-packages/mmcv/runner/epoch_based_runner.py", line 27, in train
    for i, data_batch in enumerate(data_loader):
  File "/home2/kevins99/anaconda3/envs/refinemask/lib/python3.7/site-packages/torch/utils/data/dataloader.py", line 345, in __next__
    data = self._next_data()
  File "/home2/kevins99/anaconda3/envs/refinemask/lib/python3.7/site-packages/torch/utils/data/dataloader.py", line 856, in _next_data
    return self._process_data(data)
  File "/home2/kevins99/anaconda3/envs/refinemask/lib/python3.7/site-packages/torch/utils/data/dataloader.py", line 881, in _process_data
    data.reraise()
  File "/home2/kevins99/anaconda3/envs/refinemask/lib/python3.7/site-packages/torch/_utils.py", line 395, in reraise
    raise self.exc_type(msg)
TypeError: __init__() missing 4 required positional arguments: 'casting', 'from_', 'to', and 'i'

Bug fix

hhaAndroid commented 3 years ago

@kevins99 Did you solve this problem?

G-Naughty commented 2 years ago

Did you solve this problem?

apanand14 commented 2 years ago

Hello @hhaAndroid @G-Naughty @kevins99 I'm facing the same error using the refine mask. I trained so many times. It had no issue. but having issue with some json files. i do not know how to solve this issue. Please, help me out if you have any solution.

VV-DL-JUMP commented 2 years ago

I‘m facing the same error。<- _ ->

VV-DL-JUMP commented 2 years ago

I solved this error just now, this error was caused by using numpy. In your code, must using operation such as "p[0::2] = w_scale", and you should modify it as "p[0::2] = p[0::2] w_scale". By this way that error can be solved.

cherrysherryplus commented 1 year ago

I solved this error just now, this error was caused by using numpy. In your code, must using operation such as "p[0::2] = w_scale", and you should modify it as "p[0::2] = p[0::2] w_scale". By this way that error can be solved.

it works. But i don't figure out why i should change these lines?