mirror of
https://github.com/alibaba/EasyCV.git
synced 2025-06-03 14:49:00 +08:00
fix mmlab utils
Link: https://code.alibaba-inc.com/pai-vision/EasyCV/codereview/10316166 * fix mmlab utils
This commit is contained in:
parent
0a796ec2f1
commit
ae51a8c341
@ -21,24 +21,14 @@ try:
|
|||||||
from mmcv.runner.hooks import HOOKS
|
from mmcv.runner.hooks import HOOKS
|
||||||
import mmdet
|
import mmdet
|
||||||
HOOKS._module_dict.pop('YOLOXLrUpdaterHook', None)
|
HOOKS._module_dict.pop('YOLOXLrUpdaterHook', None)
|
||||||
from mmdet.models.builder import MODELS as MMMODELS
|
|
||||||
from mmdet.models.builder import BACKBONES as MMBACKBONES
|
|
||||||
from mmdet.models.builder import NECKS as MMNECKS
|
|
||||||
from mmdet.models.builder import HEADS as MMHEADS
|
|
||||||
from mmdet.core import BitmapMasks, PolygonMasks, encode_mask_results
|
from mmdet.core import BitmapMasks, PolygonMasks, encode_mask_results
|
||||||
from mmdet.core.mask import mask2bbox
|
from mmdet.core.mask import mask2bbox
|
||||||
MM_REGISTRY = {
|
|
||||||
MMDET: {
|
|
||||||
'model': MMMODELS,
|
|
||||||
'backbone': MMBACKBONES,
|
|
||||||
'neck': MMNECKS,
|
|
||||||
'head': MMHEADS
|
|
||||||
}
|
|
||||||
}
|
|
||||||
MM_ORIGINAL_REGISTRY = copy.deepcopy(MM_REGISTRY)
|
|
||||||
except ImportError:
|
except ImportError:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
MM_REGISTRY = None
|
||||||
|
MM_ORIGINAL_REGISTRY = None
|
||||||
|
|
||||||
EASYCV_REGISTRY_MAP = {
|
EASYCV_REGISTRY_MAP = {
|
||||||
'model': MODELS,
|
'model': MODELS,
|
||||||
'backbone': BACKBONES,
|
'backbone': BACKBONES,
|
||||||
@ -167,6 +157,24 @@ class MMAdapter:
|
|||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def reset_mm_registry():
|
def reset_mm_registry():
|
||||||
|
global MM_ORIGINAL_REGISTRY
|
||||||
|
global MM_REGISTRY
|
||||||
|
|
||||||
|
if MM_REGISTRY is None:
|
||||||
|
from mmdet.models.builder import MODELS as MMMODELS
|
||||||
|
from mmdet.models.builder import BACKBONES as MMBACKBONES
|
||||||
|
from mmdet.models.builder import NECKS as MMNECKS
|
||||||
|
from mmdet.models.builder import HEADS as MMHEADS
|
||||||
|
MM_REGISTRY = {
|
||||||
|
MMDET: {
|
||||||
|
'model': MMMODELS,
|
||||||
|
'backbone': MMBACKBONES,
|
||||||
|
'neck': MMNECKS,
|
||||||
|
'head': MMHEADS
|
||||||
|
}
|
||||||
|
}
|
||||||
|
MM_ORIGINAL_REGISTRY = copy.deepcopy(MM_REGISTRY)
|
||||||
|
|
||||||
for mmtype, registries in MM_ORIGINAL_REGISTRY.items():
|
for mmtype, registries in MM_ORIGINAL_REGISTRY.items():
|
||||||
for k, ori_v in registries.items():
|
for k, ori_v in registries.items():
|
||||||
MM_REGISTRY[mmtype][k]._module_dict = copy.deepcopy(
|
MM_REGISTRY[mmtype][k]._module_dict = copy.deepcopy(
|
||||||
|
@ -12,8 +12,7 @@ from easycv.apis.test import single_gpu_test
|
|||||||
from easycv.datasets import build_dataloader, build_dataset
|
from easycv.datasets import build_dataloader, build_dataset
|
||||||
from easycv.models.builder import build_model
|
from easycv.models.builder import build_model
|
||||||
from easycv.utils.config_tools import mmcv_config_fromfile
|
from easycv.utils.config_tools import mmcv_config_fromfile
|
||||||
from easycv.utils.mmlab_utils import (MM_REGISTRY, MMDET,
|
from easycv.utils.mmlab_utils import (dynamic_adapt_for_mmlab,
|
||||||
dynamic_adapt_for_mmlab,
|
|
||||||
remove_adapt_for_mmlab)
|
remove_adapt_for_mmlab)
|
||||||
|
|
||||||
|
|
||||||
@ -128,7 +127,17 @@ class MMLabUtilTest(unittest.TestCase):
|
|||||||
def test_reset(self):
|
def test_reset(self):
|
||||||
model = self._get_model()
|
model = self._get_model()
|
||||||
remove_adapt_for_mmlab(self.cfg)
|
remove_adapt_for_mmlab(self.cfg)
|
||||||
mmdet_registry = MM_REGISTRY[MMDET]
|
from mmdet.models.builder import MODELS as MMMODELS
|
||||||
|
from mmdet.models.builder import BACKBONES as MMBACKBONES
|
||||||
|
from mmdet.models.builder import NECKS as MMNECKS
|
||||||
|
from mmdet.models.builder import HEADS as MMHEADS
|
||||||
|
mmdet_registry = {
|
||||||
|
'model': MMMODELS,
|
||||||
|
'backbone': MMBACKBONES,
|
||||||
|
'neck': MMNECKS,
|
||||||
|
'head': MMHEADS
|
||||||
|
}
|
||||||
|
|
||||||
for module, registry in mmdet_registry.items():
|
for module, registry in mmdet_registry.items():
|
||||||
for k, v in registry.module_dict.items():
|
for k, v in registry.module_dict.items():
|
||||||
self.assertTrue('easycv' not in str(v))
|
self.assertTrue('easycv' not in str(v))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user