Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
ModelZoo
SOLOv2-pytorch
Commits
f4da38a7
Commit
f4da38a7
authored
Jan 20, 2020
by
Kamran Melikov
Committed by
Kai Chen
Jan 20, 2020
Browse files
Add ability to overwite existing module in Registry (#1982)
Changes to be committed: modified: mmdet/utils/registry.py
parent
4b984a7c
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
7 additions
and
4 deletions
+7
-4
mmdet/utils/registry.py
mmdet/utils/registry.py
+7
-4
No files found.
mmdet/utils/registry.py
View file @
f4da38a7
import
inspect
from
functools
import
partial
import
mmcv
...
...
@@ -25,7 +26,7 @@ class Registry(object):
def
get
(
self
,
key
):
return
self
.
_module_dict
.
get
(
key
,
None
)
def
_register_module
(
self
,
module_class
):
def
_register_module
(
self
,
module_class
,
force
=
False
):
"""Register a module.
Args:
...
...
@@ -35,13 +36,15 @@ class Registry(object):
raise
TypeError
(
'module must be a class, but got {}'
.
format
(
type
(
module_class
)))
module_name
=
module_class
.
__name__
if
module_name
in
self
.
_module_dict
:
if
not
force
and
module_name
in
self
.
_module_dict
:
raise
KeyError
(
'{} is already registered in {}'
.
format
(
module_name
,
self
.
name
))
self
.
_module_dict
[
module_name
]
=
module_class
def
register_module
(
self
,
cls
):
self
.
_register_module
(
cls
)
def
register_module
(
self
,
cls
=
None
,
force
=
False
):
if
cls
is
None
:
return
partial
(
self
.
register_module
,
force
=
force
)
self
.
_register_module
(
cls
,
force
=
force
)
return
cls
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment