How to add new operation for mmdetection
See original GitHub issueHey! I implement a ROI pooling operation according to /mmcv/ops/deform_roi_pool.py. Then I recompile the whole library from the source, and I could use this module by calling “from mmcv.ops import xxx” now. However, when I try to use this operation in mmdetection, the program exits with an AssertionError like this:
cfg = { 'roi_layer': {'output_size': 7, 'sampling_ratio': 0, 'type': 'NewROI'}, 'type': 'SingleRoIExtractor'}
registry = Registry(name=roi_extractor, items={'GenericRoIExtractor': <class 'mmdet.models.roi_heads.roi_extractors.generic_roi_e..., 'SingleRoIExtractor': <class 'mmdet.models.roi_heads.roi_extractors.single_level_roi_extractor.SingleRoIExtractor'>})
default_args = None
def build_from_cfg(cfg, registry, default_args=None):
"""Build a module from config dict.
Args:
cfg (dict): Config dict. It should at least contain the key "type".
registry (:obj:`Registry`): The registry to search the type from.
default_args (dict, optional): Default initialization arguments.
Returns:
object: The constructed object.
"""
if not isinstance(cfg, dict):
raise TypeError(f'cfg must be a dict, but got {type(cfg)}')
if 'type' not in cfg:
if default_args is None or 'type' not in default_args:
raise KeyError(
'`cfg` or `default_args` must contain the key "type", '
f'but got {cfg}\n{default_args}')
if not isinstance(registry, Registry):
raise TypeError('registry must be an mmcv.Registry object, '
f'but got {type(registry)}')
if not (isinstance(default_args, dict) or default_args is None):
raise TypeError('default_args must be a dict or None, '
f'but got {type(default_args)}')
args = cfg.copy()
if default_args is not None:
for name, value in default_args.items():
args.setdefault(name, value)
obj_type = args.pop('type')
if isinstance(obj_type, str):
obj_cls = registry.get(obj_type)
if obj_cls is None:
raise KeyError(
f'{obj_type} is not in the {registry.name} registry')
elif inspect.isclass(obj_type):
obj_cls = obj_type
else:
raise TypeError(
f'type must be a str or valid type, but got {type(obj_type)}')
try:
return obj_cls(**args)
except Exception as e:
# Normal TypeError does not print class name.
> raise type(e)(f'{obj_cls.__name__}: {e}')
E AssertionError: SingleRoIExtractor:
../../miniconda3/envs/open-mmlab/lib/python3.7/site-packages/mmcv/utils/registry.py:182: AssertionError
Is there any other config I should change, like the adding ‘.register_module’ or so on? Great thanks for your help!!
Issue Analytics
- State:
- Created 2 years ago
- Comments:6 (4 by maintainers)
Top Results From Across the Web
Tutorial 3: Customize Data Pipelines
With the pipeline going on, each operator can add new keys (marked as green) to the result dict or update the existing keys...
Read more >how can I add new operations, such as rotate_nms. #1612
i have add a cuda extension to th ops directory and modify the setup.py, and i compiled it successfullly. but when i run...
Read more >MMDetection Tutorial - | notebook.community
This is the official colab tutorial for using MMDetection. In this tutorial, you will learn. Perform inference with a MMDet detector. Train a...
Read more >mmdet - PyPI
A brand new version of MMDetection v3.0.0rc0 was released in 31/8/2022: ... We appreciate all the contributors who implement their methods or add...
Read more >arXiv:1906.07155v1 [cs.CV] 17 Jun 2019
All basic bbox and mask operations run on GPUs. The training speed is faster than or ... MMDetection supports more methods and features...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Yeap. I have resolved this issue. I found that it’s because of the conda environment. I install mmcv-full in another conda environment and it’s strange that each time I try to import mmcv, it’s from that environment instead of my current one. I solve this problem by uninstall all the mmcv on my laptop and recompile it from the source. Great thanks for your help!
Thanks for your feedback.