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
ResNet50_tensorflow
Commits
edee549f
Unverified
Commit
edee549f
authored
Mar 06, 2022
by
srihari-humbarwadi
Browse files
added `_parse_data` with `is_training` flag
parent
7e4f1ef3
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
13 additions
and
57 deletions
+13
-57
official/vision/beta/projects/panoptic_maskrcnn/dataloaders/panoptic_deeplab_input.py
...s/panoptic_maskrcnn/dataloaders/panoptic_deeplab_input.py
+13
-57
No files found.
official/vision/beta/projects/panoptic_maskrcnn/dataloaders/panoptic_deeplab_input.py
View file @
edee549f
...
@@ -149,6 +149,7 @@ class Parser(parser.Parser):
...
@@ -149,6 +149,7 @@ class Parser(parser.Parser):
self
.
_groundtruth_padded_size
[
0
],
self
.
_groundtruth_padded_size
[
0
],
self
.
_groundtruth_padded_size
[
1
])
self
.
_groundtruth_padded_size
[
1
])
mask
-=
1
mask
-=
1
# Assign ignore label to the padded region.
# Assign ignore label to the padded region.
mask
=
tf
.
where
(
mask
=
tf
.
where
(
tf
.
equal
(
mask
,
-
1
),
tf
.
equal
(
mask
,
-
1
),
...
@@ -157,8 +158,7 @@ class Parser(parser.Parser):
...
@@ -157,8 +158,7 @@ class Parser(parser.Parser):
mask
=
tf
.
squeeze
(
mask
,
axis
=
0
)
mask
=
tf
.
squeeze
(
mask
,
axis
=
0
)
return
mask
return
mask
def
_parse_train_data
(
self
,
data
):
def
_parse_data
(
self
,
data
,
is_training
):
"""Parses data for training."""
image
=
data
[
'image'
]
image
=
data
[
'image'
]
image
=
preprocess_ops
.
normalize_image
(
image
)
image
=
preprocess_ops
.
normalize_image
(
image
)
...
@@ -170,7 +170,7 @@ class Parser(parser.Parser):
...
@@ -170,7 +170,7 @@ class Parser(parser.Parser):
dtype
=
tf
.
float32
)
dtype
=
tf
.
float32
)
# Flips image randomly during training.
# Flips image randomly during training.
if
self
.
_aug_rand_hflip
:
if
self
.
_aug_rand_hflip
and
is_training
:
masks
=
tf
.
stack
([
category_mask
,
instance_mask
],
axis
=
0
)
masks
=
tf
.
stack
([
category_mask
,
instance_mask
],
axis
=
0
)
image
,
_
,
masks
=
preprocess_ops
.
random_horizontal_flip
(
image
,
_
,
masks
=
preprocess_ops
.
random_horizontal_flip
(
image
=
image
,
masks
=
masks
)
image
=
image
,
masks
=
masks
)
...
@@ -182,22 +182,22 @@ class Parser(parser.Parser):
...
@@ -182,22 +182,22 @@ class Parser(parser.Parser):
image
,
image
,
self
.
_output_size
,
self
.
_output_size
,
self
.
_output_size
,
self
.
_output_size
,
aug_scale_min
=
self
.
_aug_scale_min
,
aug_scale_min
=
self
.
_aug_scale_min
if
is_training
else
1.0
,
aug_scale_max
=
self
.
_aug_scale_max
)
aug_scale_max
=
self
.
_aug_scale_max
if
is_training
else
1.0
)
category_mask
=
self
.
_resize_and_crop_mask
(
category_mask
=
self
.
_resize_and_crop_mask
(
category_mask
,
category_mask
,
image_info
,
image_info
,
is_training
=
True
)
is_training
=
is_training
)
instance_mask
=
self
.
_resize_and_crop_mask
(
instance_mask
=
self
.
_resize_and_crop_mask
(
instance_mask
,
instance_mask
,
image_info
,
image_info
,
is_training
=
True
)
is_training
=
is_training
)
centers_heatmap
,
centers_offset
=
self
.
_encode_centers_and_offets
(
centers_heatmap
,
centers_offset
=
self
.
_encode_centers_and_offets
(
instance_mask
=
instance_mask
[:,
:,
0
])
instance_mask
=
instance_mask
[:,
:,
0
])
# Cast image as self._dtype
# Cast image
and labels
as self._dtype
image
=
tf
.
cast
(
image
,
dtype
=
self
.
_dtype
)
image
=
tf
.
cast
(
image
,
dtype
=
self
.
_dtype
)
category_mask
=
tf
.
cast
(
category_mask
,
dtype
=
self
.
_dtype
)
category_mask
=
tf
.
cast
(
category_mask
,
dtype
=
self
.
_dtype
)
instance_mask
=
tf
.
cast
(
instance_mask
,
dtype
=
self
.
_dtype
)
instance_mask
=
tf
.
cast
(
instance_mask
,
dtype
=
self
.
_dtype
)
...
@@ -216,57 +216,13 @@ class Parser(parser.Parser):
...
@@ -216,57 +216,13 @@ class Parser(parser.Parser):
}
}
return
image
,
labels
return
image
,
labels
def
_parse_train_data
(
self
,
data
):
"""Parses data for training."""
return
self
.
_parse_data
(
data
=
data
,
is_training
=
True
)
def
_parse_eval_data
(
self
,
data
):
def
_parse_eval_data
(
self
,
data
):
"""Parses data for evaluation."""
"""Parses data for evaluation."""
image
=
data
[
'image'
]
return
self
.
_parse_data
(
data
=
data
,
is_training
=
False
)
image
=
preprocess_ops
.
normalize_image
(
image
)
# shape of masks: [H, W]
category_mask
=
tf
.
cast
(
data
[
'groundtruth_panoptic_category_mask'
][:,
:,
0
],
dtype
=
tf
.
float32
)
instance_mask
=
tf
.
cast
(
data
[
'groundtruth_panoptic_instance_mask'
][:,
:,
0
],
dtype
=
tf
.
float32
)
# Resizes and crops image.
image
,
image_info
=
preprocess_ops
.
resize_and_crop_image
(
image
,
self
.
_output_size
,
self
.
_output_size
,
aug_scale_min
=
1.0
,
aug_scale_max
=
1.0
)
category_mask
=
self
.
_resize_and_crop_mask
(
category_mask
,
image_info
,
is_training
=
False
)
instance_mask
=
self
.
_resize_and_crop_mask
(
instance_mask
,
image_info
,
is_training
=
False
)
centers_heatmap
,
centers_offset
=
self
.
_encode_centers_and_offets
(
instance_mask
=
instance_mask
[:,
:,
0
])
# Cast image as self._dtype
image
=
tf
.
cast
(
image
,
dtype
=
self
.
_dtype
)
category_mask
=
tf
.
cast
(
category_mask
,
dtype
=
self
.
_dtype
)
instance_mask
=
tf
.
cast
(
instance_mask
,
dtype
=
self
.
_dtype
)
centers_heatmap
=
tf
.
cast
(
centers_heatmap
,
dtype
=
self
.
_dtype
)
centers_offset
=
tf
.
cast
(
centers_offset
,
dtype
=
self
.
_dtype
)
things_mask
=
tf
.
cast
(
tf
.
not_equal
(
instance_mask
,
self
.
_ignore_label
),
dtype
=
self
.
_dtype
)
labels
=
{
'category_mask'
:
category_mask
,
'instance_mask'
:
instance_mask
,
'centers_heatmap'
:
centers_heatmap
,
'centers_offset'
:
centers_offset
,
'things_mask'
:
things_mask
}
return
image
,
labels
def
_encode_centers_and_offets
(
self
,
instance_mask
):
def
_encode_centers_and_offets
(
self
,
instance_mask
):
"""Generates center heatmaps and offets from instance id mask
"""Generates center heatmaps and offets from instance id mask
...
...
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