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
1017eb4f
Commit
1017eb4f
authored
Apr 27, 2021
by
mibaumgartner
Browse files
add compose
parent
31d06041
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
35 additions
and
5 deletions
+35
-5
nndet/io/transforms/__init__.py
nndet/io/transforms/__init__.py
+4
-1
nndet/io/transforms/base.py
nndet/io/transforms/base.py
+25
-2
nndet/ptmodule/retinaunet/base.py
nndet/ptmodule/retinaunet/base.py
+6
-2
No files found.
nndet/io/transforms/__init__.py
View file @
1017eb4f
from
nndet.io.transforms.base
import
AbstractTransform
from
nndet.io.transforms.base
import
(
AbstractTransform
,
Compose
,
)
from
nndet.io.transforms.instances
import
(
Instances2Boxes
,
Instances2Segmentation
,
...
...
nndet/io/transforms/base.py
View file @
1017eb4f
from
typing
import
Any
from
typing
import
Any
,
Sequence
import
torch
...
...
@@ -30,4 +30,27 @@ class AbstractTransform(torch.nn.Module):
context
=
torch
.
no_grad
()
with
context
:
return
super
().
__call__
(
*
args
,
**
kwargs
)
\ No newline at end of file
return
super
().
__call__
(
*
args
,
**
kwargs
)
class
Compose
(
AbstractTransform
):
def
__init__
(
self
,
*
transforms
):
"""
Compose multiple transforms to one
Args:
transforms: transformations to compose
"""
super
().
__init__
(
grad
=
False
)
if
len
(
transforms
)
==
1
and
isinstance
(
transforms
[
0
],
Sequence
):
transforms
=
transforms
[
0
]
self
.
transforms
=
torch
.
nn
.
ModuleList
(
list
(
transforms
))
def
forward
(
self
,
**
batch
):
"""
Augment batch
"""
for
t
in
self
.
transforms
:
batch
=
t
(
**
batch
)
return
batch
nndet/ptmodule/retinaunet/base.py
View file @
1017eb4f
...
...
@@ -62,8 +62,12 @@ from nndet.inference.helper import predict_dir
from
nndet.inference.ensembler.segmentation
import
SegmentationEnsembler
from
nndet.inference.ensembler.detection
import
BoxEnsemblerSelective
from
rising.transforms
import
Compose
from
nndet.io.transforms
import
Instances2Boxes
,
Instances2Segmentation
,
FindInstances
from
nndet.io.transforms
import
(
Compose
,
Instances2Boxes
,
Instances2Segmentation
,
FindInstances
,
)
class
RetinaUNetModule
(
LightningBaseModuleSWA
):
...
...
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