Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
F
food-round2
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
nikhil_rayaprolu
food-round2
Commits
c514be0d
Commit
c514be0d
authored
5 years ago
by
Cao Yuhang
Committed by
Kai Chen
5 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Add seg transform to Expand and MinIoUCrop (#1550)
* Add seg transform to Expand and MinIoUCrop * fix bug of repr
parent
fa2db159
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
mmdet/datasets/pipelines/transforms.py
+26
-3
26 additions, 3 deletions
mmdet/datasets/pipelines/transforms.py
with
26 additions
and
3 deletions
mmdet/datasets/pipelines/transforms.py
+
26
−
3
View file @
c514be0d
...
@@ -511,12 +511,19 @@ class Expand(object):
...
@@ -511,12 +511,19 @@ class Expand(object):
ratio_range (tuple): range of expand ratio.
ratio_range (tuple): range of expand ratio.
"""
"""
def
__init__
(
self
,
mean
=
(
0
,
0
,
0
),
to_rgb
=
True
,
ratio_range
=
(
1
,
4
)):
def
__init__
(
self
,
mean
=
(
0
,
0
,
0
),
to_rgb
=
True
,
ratio_range
=
(
1
,
4
),
seg_ignore_label
=
None
):
self
.
to_rgb
=
to_rgb
self
.
ratio_range
=
ratio_range
if
to_rgb
:
if
to_rgb
:
self
.
mean
=
mean
[::
-
1
]
self
.
mean
=
mean
[::
-
1
]
else
:
else
:
self
.
mean
=
mean
self
.
mean
=
mean
self
.
min_ratio
,
self
.
max_ratio
=
ratio_range
self
.
min_ratio
,
self
.
max_ratio
=
ratio_range
self
.
seg_ignore_label
=
seg_ignore_label
def
__call__
(
self
,
results
):
def
__call__
(
self
,
results
):
if
random
.
randint
(
2
):
if
random
.
randint
(
2
):
...
@@ -544,12 +551,23 @@ class Expand(object):
...
@@ -544,12 +551,23 @@ class Expand(object):
expand_mask
[
top
:
top
+
h
,
left
:
left
+
w
]
=
mask
expand_mask
[
top
:
top
+
h
,
left
:
left
+
w
]
=
mask
expand_gt_masks
.
append
(
expand_mask
)
expand_gt_masks
.
append
(
expand_mask
)
results
[
'
gt_masks
'
]
=
expand_gt_masks
results
[
'
gt_masks
'
]
=
expand_gt_masks
# not tested
if
'
gt_semantic_seg
'
in
results
:
assert
self
.
seg_ignore_label
is
not
None
gt_seg
=
results
[
'
gt_semantic_seg
'
]
expand_gt_seg
=
np
.
full
((
int
(
h
*
ratio
),
int
(
w
*
ratio
)),
self
.
seg_ignore_label
).
astype
(
gt_seg
.
dtype
)
expand_gt_seg
[
top
:
top
+
h
,
left
:
left
+
w
]
=
gt_seg
results
[
'
gt_semantic_seg
'
]
=
expand_gt_seg
return
results
return
results
def
__repr__
(
self
):
def
__repr__
(
self
):
repr_str
=
self
.
__class__
.
__name__
repr_str
=
self
.
__class__
.
__name__
repr_str
+=
'
(mean={}, to_rgb={}, ratio_range={})
'
.
format
(
repr_str
+=
'
(mean={}, to_rgb={}, ratio_range={},
'
\
self
.
mean
,
self
.
to_rgb
,
self
.
ratio_range
)
'
seg_ignore_label={})
'
.
format
(
self
.
mean
,
self
.
to_rgb
,
self
.
ratio_range
,
self
.
seg_ignore_label
)
return
repr_str
return
repr_str
...
@@ -626,6 +644,11 @@ class MinIoURandomCrop(object):
...
@@ -626,6 +644,11 @@ class MinIoURandomCrop(object):
gt_mask
[
patch
[
1
]:
patch
[
3
],
patch
[
0
]:
patch
[
2
]]
gt_mask
[
patch
[
1
]:
patch
[
3
],
patch
[
0
]:
patch
[
2
]]
for
gt_mask
in
valid_masks
for
gt_mask
in
valid_masks
]
]
# not tested
if
'
gt_semantic_seg
'
in
results
:
results
[
'
gt_semantic_seg
'
]
=
results
[
'
gt_semantic_seg
'
][
patch
[
1
]:
patch
[
3
],
patch
[
0
]:
patch
[
2
]]
return
results
return
results
def
__repr__
(
self
):
def
__repr__
(
self
):
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment