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
fa06f822
Unverified
Commit
fa06f822
authored
Oct 27, 2021
by
srihari-humbarwadi
Browse files
added docstrings
parent
3982b139
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
18 additions
and
6 deletions
+18
-6
official/vision/beta/evaluation/panoptic_quality_evaluator.py
...cial/vision/beta/evaluation/panoptic_quality_evaluator.py
+6
-1
official/vision/beta/projects/panoptic_maskrcnn/modeling/layers/panoptic_segmentation_generator.py
...skrcnn/modeling/layers/panoptic_segmentation_generator.py
+11
-4
official/vision/beta/projects/panoptic_maskrcnn/modeling/panoptic_maskrcnn_model.py
...cts/panoptic_maskrcnn/modeling/panoptic_maskrcnn_model.py
+1
-1
No files found.
official/vision/beta/evaluation/panoptic_quality_evaluator.py
View file @
fa06f822
...
...
@@ -33,11 +33,16 @@ from official.vision.beta.evaluation import panoptic_quality
def
_crop_padding
(
mask
,
image_info
):
"""Crops padded masks to match original image shape.
Args:
mask: a padded mask tensor.
image_info: a tensor that holds information about original and preprocessed
images.
"""
image_shape
=
tf
.
cast
(
image_info
[
0
,
:],
tf
.
int32
)
mask
=
tf
.
image
.
crop_to_bounding_box
(
tf
.
expand_dims
(
mask
,
axis
=-
1
),
0
,
0
,
image_shape
[
0
],
image_shape
[
1
])
return
tf
.
expand_dims
(
mask
[:,
:,
0
],
axis
=
0
)
class
PanopticQualityEvaluator
:
...
...
official/vision/beta/projects/panoptic_maskrcnn/modeling/layers/panoptic_segmentation_generator.py
View file @
fa06f822
...
...
@@ -14,7 +14,7 @@
"""Contains definition for postprocessing layer to genrate panoptic segmentations."""
from
typing
import
List
,
Mapping
from
typing
import
List
import
tensorflow
as
tf
...
...
@@ -57,7 +57,7 @@ class PanopticSegmentationGenerator(tf.keras.layers.Layer):
assigned to any thing class. That is, void_instance_id are assigned to
both stuff regions and empty regions.
rescale_predictions: `bool`, whether to scale back prediction to original
image sizes. If True, image_info
`dict`
is used to rescale predictions.
image sizes. If True, image_info is used to rescale predictions.
**kwargs: additional kewargs arguments.
"""
self
.
_output_size
=
output_size
...
...
@@ -230,6 +230,13 @@ class PanopticSegmentationGenerator(tf.keras.layers.Layer):
return
results
def
_resize_and_pad_masks
(
self
,
mask
,
image_info
):
"""Resizes masks to match the original image shape and pads them to
`output_size`.
Args:
mask: a padded mask tensor.
image_info: a tensor that holds information about original and
preprocessed images.
"""
rescale_size
=
tf
.
cast
(
tf
.
math
.
ceil
(
image_info
[
1
,
:]
/
image_info
[
2
,
:]),
tf
.
int32
)
image_shape
=
tf
.
cast
(
image_info
[
0
,
:],
tf
.
int32
)
...
...
@@ -238,7 +245,7 @@ class PanopticSegmentationGenerator(tf.keras.layers.Layer):
mask
=
tf
.
image
.
resize
(
mask
,
rescale_size
,
method
=
tf
.
image
.
ResizeMethod
.
BILINEAR
)
method
=
'bilinear'
)
mask
=
tf
.
image
.
crop_to_bounding_box
(
mask
,
offsets
[
0
],
offsets
[
1
],
...
...
@@ -248,7 +255,7 @@ class PanopticSegmentationGenerator(tf.keras.layers.Layer):
mask
,
0
,
0
,
self
.
_output_size
[
0
],
self
.
_output_size
[
1
])
return
mask
def
call
(
self
,
inputs
:
tf
.
Tensor
,
image_info
:
Mapping
[
str
,
tf
.
Tensor
]
):
def
call
(
self
,
inputs
:
tf
.
Tensor
,
image_info
:
tf
.
Tensor
):
detections
=
inputs
batched_scores
=
detections
[
'detection_scores'
]
...
...
official/vision/beta/projects/panoptic_maskrcnn/modeling/panoptic_maskrcnn_model.py
View file @
fa06f822
...
...
@@ -143,7 +143,7 @@ class PanopticMaskRCNNModel(maskrcnn_model.MaskRCNNModel):
def
call
(
self
,
images
:
tf
.
Tensor
,
image_info
:
Mapping
[
str
,
tf
.
Tensor
]
,
image_info
:
tf
.
Tensor
,
anchor_boxes
:
Optional
[
Mapping
[
str
,
tf
.
Tensor
]]
=
None
,
gt_boxes
:
Optional
[
tf
.
Tensor
]
=
None
,
gt_classes
:
Optional
[
tf
.
Tensor
]
=
None
,
...
...
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