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
c4ce3a9e
Unverified
Commit
c4ce3a9e
authored
Apr 29, 2022
by
srihari-humbarwadi
Browse files
make keys to panoptic masks configurable in `TfExampleDecoder`
parent
a9e15bd9
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
23 additions
and
9 deletions
+23
-9
official/vision/beta/projects/panoptic_maskrcnn/configs/panoptic_deeplab.py
...ta/projects/panoptic_maskrcnn/configs/panoptic_deeplab.py
+9
-3
official/vision/beta/projects/panoptic_maskrcnn/dataloaders/panoptic_deeplab_input.py
...s/panoptic_maskrcnn/dataloaders/panoptic_deeplab_input.py
+11
-5
official/vision/beta/projects/panoptic_maskrcnn/tasks/panoptic_deeplab.py
...beta/projects/panoptic_maskrcnn/tasks/panoptic_deeplab.py
+3
-1
No files found.
official/vision/beta/projects/panoptic_maskrcnn/configs/panoptic_deeplab.py
View file @
c4ce3a9e
# Copyright 202
1
The TensorFlow Authors. All Rights Reserved.
# Copyright 202
2
The TensorFlow Authors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
...
...
@@ -51,10 +51,16 @@ class Parser(hyperparams.Config):
dtype
=
'float32'
@
dataclasses
.
dataclass
class
TfExampleDecoder
(
common
.
TfExampleDecoder
):
"""A simple TF Example decoder config."""
panoptic_category_mask_key
:
str
=
'image/panoptic/category_mask'
panoptic_instance_mask_key
:
str
=
'image/panoptic/instance_mask'
@
dataclasses
.
dataclass
class
DataDecoder
(
common
.
DataDecoder
):
"""Data decoder config."""
simple_decoder
:
common
.
TfExampleDecoder
=
common
.
TfExampleDecoder
()
simple_decoder
:
TfExampleDecoder
=
TfExampleDecoder
()
@
dataclasses
.
dataclass
...
...
@@ -164,7 +170,7 @@ class PanopticDeeplabTask(cfg.TaskConfig):
evaluation
:
Evaluation
=
Evaluation
()
@
exp_factory
.
register_config_factory
(
'panoptic_deeplab_coco'
)
@
exp_factory
.
register_config_factory
(
'panoptic_deeplab_
resnet_
coco'
)
def
panoptic_deeplab_coco
()
->
cfg
.
ExperimentConfig
:
"""COCO panoptic segmentation with Panoptic Deeplab."""
train_steps
=
200000
...
...
official/vision/beta/projects/panoptic_maskrcnn/dataloaders/panoptic_deeplab_input.py
View file @
c4ce3a9e
...
...
@@ -41,16 +41,22 @@ def _compute_gaussian_from_std(sigma):
class
TfExampleDecoder
(
tf_example_decoder
.
TfExampleDecoder
):
"""Tensorflow Example proto decoder."""
def
__init__
(
self
,
regenerate_source_id
):
def
__init__
(
self
,
regenerate_source_id
:
bool
,
panoptic_category_mask_key
:
str
=
'image/panoptic/category_mask'
,
panoptic_instance_mask_key
:
str
=
'image/panoptic/instance_mask'
):
super
(
TfExampleDecoder
,
self
).
__init__
(
include_mask
=
True
,
regenerate_source_id
=
regenerate_source_id
)
self
.
_panoptic_category_mask_key
=
panoptic_category_mask_key
self
.
_panoptic_instance_mask_key
=
panoptic_instance_mask_key
self
.
_panoptic_keys_to_features
=
{
'image/
panoptic
/
category_mask
'
:
panoptic
_
category_mask
_key
:
tf
.
io
.
FixedLenFeature
((),
tf
.
string
,
default_value
=
''
),
'image/
panoptic
/
instance_mask
'
:
panoptic
_
instance_mask
_key
:
tf
.
io
.
FixedLenFeature
((),
tf
.
string
,
default_value
=
''
)
}
...
...
@@ -61,9 +67,9 @@ class TfExampleDecoder(tf_example_decoder.TfExampleDecoder):
serialized_example
,
self
.
_panoptic_keys_to_features
)
category_mask
=
tf
.
io
.
decode_image
(
parsed_tensors
[
'image/
panoptic
/
category_mask
'
],
channels
=
1
)
parsed_tensors
[
self
.
_
panoptic
_
category_mask
_key
],
channels
=
1
)
instance_mask
=
tf
.
io
.
decode_image
(
parsed_tensors
[
'image/
panoptic
/
instance_mask
'
],
channels
=
1
)
parsed_tensors
[
self
.
_
panoptic
_
instance_mask
_key
],
channels
=
1
)
category_mask
.
set_shape
([
None
,
None
,
1
])
instance_mask
.
set_shape
([
None
,
None
,
1
])
...
...
official/vision/beta/projects/panoptic_maskrcnn/tasks/panoptic_deeplab.py
View file @
c4ce3a9e
...
...
@@ -90,7 +90,9 @@ class PanopticDeeplabTask(base_task.Task):
if
params
.
decoder
.
type
==
'simple_decoder'
:
decoder
=
panoptic_deeplab_input
.
TfExampleDecoder
(
regenerate_source_id
=
decoder_cfg
.
regenerate_source_id
)
regenerate_source_id
=
decoder_cfg
.
regenerate_source_id
,
panoptic_category_mask_key
=
decoder_cfg
.
panoptic_category_mask_key
,
panoptic_instance_mask_key
=
decoder_cfg
.
panoptic_instance_mask_key
)
else
:
raise
ValueError
(
'Unknown decoder type: {}!'
.
format
(
params
.
decoder
.
type
))
...
...
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