KeyError: ‘NumClassCheckHook is already registered in hook’

Published onesixx on

https://programmerah.com/mmdetection-error-when-running-voc-py-keyerror-numclasscheckhook-is-already-registered-in-hook-29406/

… is already registered in …

재등록을 위해 force=True 추가

에러상황

import sys
#sys.path.append(os.path.dirname(os.path.abspath(__file__)))
sys.path.append(ROOT_DIR) # '/home/sixx/git'
from mmdetection.mmdet.datasets.builder import DATASETS
from mmdetection.mmdet.datasets.custom  import CustomDataset
---------------------------------------------------------------------------
KeyError                                  Traceback (most recent call last)
~/xx/mymm/oxford/tools/sixx_middle_dataset.py in 
----> 40 from mmdetection.mmdet.datasets.builder import DATASETS

~/xx/mmdetection/mmdet/datasets/__init__.py in 
     10 from .lvis import LVISDataset, LVISV1Dataset, LVISV05Dataset
     11 from .samplers import DistributedGroupSampler, DistributedSampler, GroupSampler
---> 12 from .utils import (NumClassCheckHook, get_loading_pipeline,
     13                     replace_ImageToTensor)
     14 from .voc import VOCDataset

~/xx/mmdetection/mmdet/datasets/utils.py in 
    114 
    115 @HOOKS.register_module()
--> 116 class NumClassCheckHook(Hook):
    117 
    118     def _check_head(self, runner):

~/.conda/envs/mmlab38/lib/python3.8/site-packages/mmcv/utils/registry.py in _register(cls)
    310         # use it as a decorator: @x.register_module()
    311         def _register(cls):
--> 312             self._register_module(
    313                 module_class=cls, module_name=name, force=force)
    314             return cls

~/.conda/envs/mmlab38/lib/python3.8/site-packages/mmcv/utils/registry.py in _register_module(self, module_class, module_name, force)
    244         for name in module_name:
    245             if not force and name in self._module_dict:
--> 246                 raise KeyError(f'{name} is already registered '
    247                                f'in {self.name}')
    248             self._module_dict[name] = module_class

KeyError: 'NumClassCheckHook is already registered in hook'

해결

# before
@HOOKS.register_module()
# After
@HOOKS.register_module(name='NumClassCheckHook', force=True)
Categories: vision

onesixx

Blog Owner

Subscribe
Notify of
guest

0 Comments
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x