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
9da12cdd
Commit
9da12cdd
authored
Jul 01, 2020
by
Kaushik Shivakumar
Browse files
remove unnecessary file
parent
b978005f
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
0 additions
and
133 deletions
+0
-133
research/object_detection/meta_architectures/context_rcnn_lib_test_tf1.py
...detection/meta_architectures/context_rcnn_lib_test_tf1.py
+0
-133
No files found.
research/object_detection/meta_architectures/context_rcnn_lib_test_tf1.py
deleted
100644 → 0
View file @
b978005f
# Lint as: python3
# Copyright 2020 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.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# ==============================================================================
"""Tests for context_rcnn_lib."""
from
__future__
import
absolute_import
from
__future__
import
division
from
__future__
import
print_function
import
unittest
from
absl.testing
import
parameterized
import
tensorflow.compat.v1
as
tf
from
object_detection.meta_architectures
import
context_rcnn_lib
from
object_detection.utils
import
test_case
from
object_detection.utils
import
tf_version
_NEGATIVE_PADDING_VALUE
=
-
100000
class
ContextRcnnLibTest
(
parameterized
.
TestCase
,
test_case
.
TestCase
,
tf
.
test
.
TestCase
):
"""Tests for the functions in context_rcnn_lib."""
def
test_compute_valid_mask
(
self
):
num_elements
=
tf
.
constant
(
3
,
tf
.
int32
)
num_valid_elementss
=
tf
.
constant
((
1
,
2
),
tf
.
int32
)
valid_mask
=
context_rcnn_lib
.
compute_valid_mask
(
num_valid_elementss
,
num_elements
)
expected_valid_mask
=
tf
.
constant
([[
1
,
0
,
0
],
[
1
,
1
,
0
]],
tf
.
float32
)
self
.
assertAllEqual
(
valid_mask
,
expected_valid_mask
)
def
test_filter_weight_value
(
self
):
weights
=
tf
.
ones
((
2
,
3
,
2
),
tf
.
float32
)
*
4
values
=
tf
.
ones
((
2
,
2
,
4
),
tf
.
float32
)
valid_mask
=
tf
.
constant
([[
True
,
True
],
[
True
,
False
]],
tf
.
bool
)
filtered_weights
,
filtered_values
=
context_rcnn_lib
.
filter_weight_value
(
weights
,
values
,
valid_mask
)
expected_weights
=
tf
.
constant
([[[
4
,
4
],
[
4
,
4
],
[
4
,
4
]],
[[
4
,
_NEGATIVE_PADDING_VALUE
+
4
],
[
4
,
_NEGATIVE_PADDING_VALUE
+
4
],
[
4
,
_NEGATIVE_PADDING_VALUE
+
4
]]])
expected_values
=
tf
.
constant
([[[
1
,
1
,
1
,
1
],
[
1
,
1
,
1
,
1
]],
[[
1
,
1
,
1
,
1
],
[
0
,
0
,
0
,
0
]]])
self
.
assertAllEqual
(
filtered_weights
,
expected_weights
)
self
.
assertAllEqual
(
filtered_values
,
expected_values
)
# Changes the valid_mask so the results will be different.
valid_mask
=
tf
.
constant
([[
True
,
True
],
[
False
,
False
]],
tf
.
bool
)
filtered_weights
,
filtered_values
=
context_rcnn_lib
.
filter_weight_value
(
weights
,
values
,
valid_mask
)
expected_weights
=
tf
.
constant
(
[[[
4
,
4
],
[
4
,
4
],
[
4
,
4
]],
[[
_NEGATIVE_PADDING_VALUE
+
4
,
_NEGATIVE_PADDING_VALUE
+
4
],
[
_NEGATIVE_PADDING_VALUE
+
4
,
_NEGATIVE_PADDING_VALUE
+
4
],
[
_NEGATIVE_PADDING_VALUE
+
4
,
_NEGATIVE_PADDING_VALUE
+
4
]]])
expected_values
=
tf
.
constant
([[[
1
,
1
,
1
,
1
],
[
1
,
1
,
1
,
1
]],
[[
0
,
0
,
0
,
0
],
[
0
,
0
,
0
,
0
]]])
self
.
assertAllEqual
(
filtered_weights
,
expected_weights
)
self
.
assertAllEqual
(
filtered_values
,
expected_values
)
@
parameterized
.
parameters
((
2
,
True
,
True
),
(
2
,
False
,
True
),
(
10
,
True
,
False
),
(
10
,
False
,
False
))
def
test_project_features
(
self
,
projection_dimension
,
is_training
,
normalize
):
features
=
tf
.
ones
([
2
,
3
,
4
],
tf
.
float32
)
projected_features
=
context_rcnn_lib
.
project_features
(
features
,
projection_dimension
,
is_training
,
context_rcnn_lib
.
ContextProjection
(
projection_dimension
,
False
),
normalize
=
normalize
)
# Makes sure the shape is correct.
self
.
assertAllEqual
(
projected_features
.
shape
,
[
2
,
3
,
projection_dimension
])
@
parameterized
.
parameters
(
(
2
,
10
,
1
),
(
3
,
10
,
2
),
(
4
,
20
,
3
),
(
5
,
20
,
4
),
(
7
,
20
,
5
),
)
def
test_attention_block
(
self
,
bottleneck_dimension
,
output_dimension
,
attention_temperature
):
input_features
=
tf
.
ones
([
2
,
3
,
4
],
tf
.
float32
)
context_features
=
tf
.
ones
([
2
,
2
,
3
],
tf
.
float32
)
valid_mask
=
tf
.
constant
([[
True
,
True
],
[
False
,
False
]],
tf
.
bool
)
is_training
=
False
#projection_layers = {context_rcnn_lib.KEY_NAME: context_rcnn_lib.ContextProjection(bottleneck_dimension, False), context_rcnn_lib.VALUE_NAME: context_rcnn_lib.ContextProjection(bottleneck_dimension, False),
# context_rcnn_lib.QUERY_NAME: context_rcnn_lib.ContextProjection(bottleneck_dimension, False)}
#Add in the feature layer because this is further down the pipeline and it isn't automatically injected.
#projection_layers['feature'] = context_rcnn_lib.ContextProjection(output_dimension, False)
attention_block
=
context_rcnn_lib
.
AttentionBlock
(
bottleneck_dimension
,
attention_temperature
,
False
)
attention_block
.
set_output_dimension
(
output_dimension
)
output_features
=
attention_block
([
input_features
,
context_features
],
is_training
,
valid_mask
)
# Makes sure the shape is correct.
self
.
assertAllEqual
(
output_features
.
shape
,
[
2
,
3
,
output_dimension
])
@
parameterized
.
parameters
(
True
,
False
)
def
test_compute_box_context_attention
(
self
,
is_training
):
box_features
=
tf
.
ones
([
2
,
3
,
4
,
4
,
4
],
tf
.
float32
)
context_features
=
tf
.
ones
([
2
,
5
,
6
],
tf
.
float32
)
valid_context_size
=
tf
.
constant
((
2
,
3
),
tf
.
int32
)
bottleneck_dimension
=
10
attention_temperature
=
1
attention_features
=
context_rcnn_lib
.
compute_box_context_attention
(
box_features
,
context_features
,
valid_context_size
,
bottleneck_dimension
,
attention_temperature
,
is_training
,
False
,
context_rcnn_lib
.
AttentionBlock
(
bottleneck_dimension
,
attention_temperature
,
False
))
# Makes sure the shape is correct.
self
.
assertAllEqual
(
attention_features
.
shape
,
[
2
,
3
,
1
,
1
,
4
])
if
__name__
==
'__main__'
:
tf
.
test
.
main
()
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