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
yaoyuping
nnDetection
Commits
df9daf18
Commit
df9daf18
authored
Jul 25, 2021
by
mibaumgartner
Browse files
deprecation and experimental decorators
parent
64ad8dfa
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
61 additions
and
1 deletion
+61
-1
nndet/arch/decoder/base.py
nndet/arch/decoder/base.py
+2
-0
nndet/utils/analysis.py
nndet/utils/analysis.py
+3
-1
nndet/utils/info.py
nndet/utils/info.py
+56
-0
No files found.
nndet/arch/decoder/base.py
View file @
df9daf18
...
...
@@ -22,6 +22,7 @@ from loguru import logger
from
nndet.arch.conv
import
conv_kwargs_helper
from
nndet.utils
import
to_dtype
from
nndet.utils.info
import
experimental
class
BaseUFPN
(
nn
.
Module
):
...
...
@@ -417,6 +418,7 @@ class UFPNModular(BaseUFPN):
class
PAUFPN
(
UFPNModular
):
@
experimental
def
__init__
(
self
,
conv
:
Callable
,
strides
:
Sequence
[
int
],
...
...
nndet/utils/analysis.py
View file @
df9daf18
...
...
@@ -39,7 +39,7 @@ import SimpleITK as sitk
from
nndet.core.boxes
import
box_iou_np
,
box_size_np
from
nndet.io.load
import
load_pickle
,
save_json
from
nndet.utils.info
import
maybe_verbose_iterable
from
nndet.utils.info
import
maybe_verbose_iterable
,
experimental
,
deprecate
def
collect_overview
(
prediction_dir
:
Path
,
gt_dir
:
Path
,
...
...
@@ -366,6 +366,7 @@ def plot_sizes_bar(all_pred, all_target, all_boxes, iou, score,
return
fig
,
ax
@
experimental
def
run_analysis_suite
(
prediction_dir
:
Path
,
gt_dir
:
Path
,
save_dir
:
Path
):
for
iou
,
score
in
maybe_verbose_iterable
(
list
(
product
([
0.1
,
0.5
],
[
0.1
,
0.5
]))):
_save_dir
=
save_dir
/
f
"iou_
{
iou
}
_score_
{
score
}
"
...
...
@@ -415,6 +416,7 @@ def run_analysis_suite(prediction_dir: Path, gt_dir: Path, save_dir: Path):
plt
.
close
()
@
deprecate
(
deprecate
=
"v0.1"
,
remove
=
"v0.2"
)
def
convert_box_to_nii_meta
(
pred_boxes
:
Tensor
,
pred_scores
:
Tensor
,
pred_labels
:
Tensor
,
...
...
nndet/utils/info.py
View file @
df9daf18
...
...
@@ -33,6 +33,8 @@ from typing import Union, Optional
from
pathlib
import
Path
from
git
import
Repo
,
InvalidGitRepositoryError
import
functools
import
inspect
class
SuppressPrint
:
def
__enter__
(
self
):
...
...
@@ -44,6 +46,60 @@ class SuppressPrint:
sys
.
stdout
=
self
.
_original_stdout
def
deprecate
(
replacement
:
Optional
[
str
]
=
None
,
deprecate
:
Optional
[
str
]
=
None
,
remove
:
Optional
[
str
]
=
None
,
):
"""
Deprecate functions and classes
Args:
replacement: Optional replacement of old element. if No
replacement is provided (None) this will expect that the function
will be removed completely.
deprecate: Optional version from when element is deprecated.
remove: Optional version from when element will be removed.
"""
def
decorator
(
func
):
@
functools
.
wraps
(
func
)
def
wrapper
(
*
args
,
**
kwargs
):
if
inspect
.
isclass
(
func
):
func_name
=
func
.
__class__
.
__name__
else
:
func_name
=
func
.
__name__
time_str
=
"now"
if
deprecate
is
None
else
deprecate
s
=
f
"
{
func_name
}
is deprecated from
{
time_str
}
!"
if
remove
is
not
None
:
s
+=
f
" It will be removed from nnDetection from
{
remove
}
"
if
replacement
is
not
None
:
s
+=
f
" The replacement is
{
replacement
}
."
else
:
s
+=
f
" There will be no replacement."
logger
.
warning
(
s
)
return
func
(
*
args
,
**
kwargs
)
return
wrapper
return
decorator
def
experimental
(
func
):
@
functools
.
wraps
(
func
)
def
wrapper
(
*
args
,
**
kwargs
):
if
inspect
.
isclass
(
func
):
func_name
=
func
.
__class__
.
__name__
else
:
func_name
=
func
.
__qualname__
logger
.
warning
(
f
"This feature (
{
func_name
}
) is experimental! "
"It might not implement all features or is only a simplification!"
)
return
func
(
*
args
,
**
kwargs
)
return
wrapper
def
get_requirements
():
"""
Get all installed packages from currently active environment
...
...
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