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
OpenDAS
MMCV
Commits
88f3cc3f
Commit
88f3cc3f
authored
May 17, 2022
by
liukuikun
Committed by
zhouzaida
Jul 19, 2022
Browse files
replace height, width with img_shape
parent
772069f2
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
12 additions
and
21 deletions
+12
-21
mmcv/transforms/loading.py
mmcv/transforms/loading.py
+7
-12
mmcv/transforms/processing.py
mmcv/transforms/processing.py
+2
-4
tests/test_transforms/test_transforms_loading.py
tests/test_transforms/test_transforms_loading.py
+3
-5
No files found.
mmcv/transforms/loading.py
View file @
88f3cc3f
...
...
@@ -17,10 +17,8 @@ class LoadImageFromFile(BaseTransform):
Modified Keys:
- img
- width
- height
- ori_width
- ori_height
- img_shape
- ori_shape
Args:
to_float32 (bool): Whether to convert the loaded image to a float32
...
...
@@ -68,11 +66,8 @@ class LoadImageFromFile(BaseTransform):
img
=
img
.
astype
(
np
.
float32
)
results
[
'img'
]
=
img
height
,
width
=
img
.
shape
[:
2
]
results
[
'height'
]
=
height
results
[
'width'
]
=
width
results
[
'ori_height'
]
=
height
results
[
'ori_width'
]
=
width
results
[
'img_shape'
]
=
img
.
shape
[:
2
]
results
[
'ori_shape'
]
=
img
.
shape
[:
2
]
return
results
def
__repr__
(
self
):
...
...
@@ -123,7 +118,7 @@ class LoadAnnotations(BaseTransform):
# In (x1, y1, x2, y2) order, float type. N is the number of bboxes
# in np.float32
'gt_bboxes': np.ndarray(N, 4)
# In np.int
32
type.
# In np.int
64
type.
'gt_bboxes_labels': np.ndarray(N, )
# In uint8 type.
'gt_seg_map': np.ndarray (H, W)
...
...
@@ -144,7 +139,7 @@ class LoadAnnotations(BaseTransform):
Added Keys:
- gt_bboxes (np.float32)
- gt_bboxes_labels (np.int
32
)
- gt_bboxes_labels (np.int
64
)
- gt_seg_map (np.uint8)
- gt_keypoints (np.float32)
...
...
@@ -211,7 +206,7 @@ class LoadAnnotations(BaseTransform):
for
instance
in
results
[
'instances'
]:
gt_bboxes_labels
.
append
(
instance
[
'bbox_label'
])
results
[
'gt_bboxes_labels'
]
=
np
.
array
(
gt_bboxes_labels
,
dtype
=
np
.
int
32
)
gt_bboxes_labels
,
dtype
=
np
.
int
64
)
def
_load_seg_map
(
self
,
results
:
dict
)
->
None
:
"""Private function to load semantic segmentation annotations.
...
...
mmcv/transforms/processing.py
View file @
88f3cc3f
...
...
@@ -286,8 +286,7 @@ class Pad(BaseTransform):
- img
- gt_seg_map
- height
- width
- img_shape
Added Keys:
...
...
@@ -382,8 +381,7 @@ class Pad(BaseTransform):
results
[
'pad_shape'
]
=
padded_img
.
shape
results
[
'pad_fixed_size'
]
=
self
.
size
results
[
'pad_size_divisor'
]
=
self
.
size_divisor
results
[
'height'
]
=
padded_img
.
shape
[
0
]
results
[
'width'
]
=
padded_img
.
shape
[
1
]
results
[
'img_shape'
]
=
padded_img
.
shape
[:
2
]
def
_pad_seg
(
self
,
results
:
dict
)
->
None
:
"""Pad semantic segmentation map according to
...
...
tests/test_transforms/test_transforms_loading.py
View file @
88f3cc3f
...
...
@@ -18,10 +18,8 @@ class TestLoadImageFromFile:
assert
results
[
'img_path'
]
==
osp
.
join
(
data_prefix
,
'color.jpg'
)
assert
results
[
'img'
].
shape
==
(
300
,
400
,
3
)
assert
results
[
'img'
].
dtype
==
np
.
uint8
assert
results
[
'height'
]
==
300
assert
results
[
'width'
]
==
400
assert
results
[
'ori_height'
]
==
300
assert
results
[
'ori_width'
]
==
400
assert
results
[
'img_shape'
]
==
(
300
,
400
)
assert
results
[
'ori_shape'
]
==
(
300
,
400
)
assert
repr
(
transform
)
==
transform
.
__class__
.
__name__
+
\
"(to_float32=False, color_type='color', "
+
\
"imdecode_backend='cv2', file_client_args={'backend': 'disk'})"
...
...
@@ -86,7 +84,7 @@ class TestLoadAnnotations:
results
=
transform
(
copy
.
deepcopy
(
self
.
results
))
assert
'gt_bboxes_labels'
in
results
assert
(
results
[
'gt_bboxes_labels'
]
==
np
.
array
([
1
,
2
])).
all
()
assert
results
[
'gt_bboxes_labels'
].
dtype
==
np
.
int
32
assert
results
[
'gt_bboxes_labels'
].
dtype
==
np
.
int
64
def
test_load_kps
(
self
):
transform
=
LoadAnnotations
(
...
...
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