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
6d6cd4ac
Commit
6d6cd4ac
authored
May 11, 2021
by
A. Unique TensorFlower
Committed by
TF Object Detection Team
May 11, 2021
Browse files
Internal change.
PiperOrigin-RevId: 373140072
parent
aa2b5e42
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
81 additions
and
71 deletions
+81
-71
research/object_detection/builders/preprocessor_builder.py
research/object_detection/builders/preprocessor_builder.py
+3
-2
research/object_detection/builders/preprocessor_builder_test.py
...ch/object_detection/builders/preprocessor_builder_test.py
+1
-0
research/object_detection/core/keypoint_ops.py
research/object_detection/core/keypoint_ops.py
+2
-0
research/object_detection/core/keypoint_ops_test.py
research/object_detection/core/keypoint_ops_test.py
+1
-0
research/object_detection/core/preprocessor.py
research/object_detection/core/preprocessor.py
+3
-0
research/object_detection/core/preprocessor_test.py
research/object_detection/core/preprocessor_test.py
+2
-0
research/object_detection/protos/preprocessor.proto
research/object_detection/protos/preprocessor.proto
+69
-69
No files found.
research/object_detection/builders/preprocessor_builder.py
View file @
6d6cd4ac
...
...
@@ -101,8 +101,8 @@ PREPROCESSING_FUNCTION_MAP = {
preprocessor
.
random_patch_gaussian
,
'rgb_to_gray'
:
preprocessor
.
rgb_to_gray
,
'scale_boxes_to_pixel_coordinates'
:
(
preprocessor
.
scale_boxes_to_pixel_coordinates
),
'scale_boxes_to_pixel_coordinates'
:
(
preprocessor
.
scale_boxes_to_pixel_coordinates
),
'subtract_channel_mean'
:
preprocessor
.
subtract_channel_mean
,
'convert_class_logits_to_softmax'
:
...
...
@@ -435,6 +435,7 @@ def build(preprocessor_step_config):
'output_size'
:
config
.
output_size
,
}
if
step_type
==
'random_jitter_boxes'
:
config
=
preprocessor_step_config
.
random_jitter_boxes
kwargs
=
get_random_jitter_kwargs
(
config
)
...
...
research/object_detection/builders/preprocessor_builder_test.py
View file @
6d6cd4ac
...
...
@@ -768,5 +768,6 @@ class PreprocessorBuilderTest(tf.test.TestCase):
self
.
assert_dictionary_close
(
args
,
{
'gamma'
:
2.2
,
'gain'
:
2.0
})
if
__name__
==
'__main__'
:
tf
.
test
.
main
()
research/object_detection/core/keypoint_ops.py
View file @
6d6cd4ac
...
...
@@ -317,6 +317,8 @@ def rot90(keypoints, rotation_permutation=None, scope=None):
return
new_keypoints
def
keypoint_weights_from_visibilities
(
keypoint_visibilities
,
per_keypoint_weights
=
None
):
"""Returns a keypoint weights tensor.
...
...
research/object_detection/core/keypoint_ops_test.py
View file @
6d6cd4ac
...
...
@@ -300,6 +300,7 @@ class KeypointOpsTest(test_case.TestCase):
output
,
expected_keypoints
=
self
.
execute
(
graph_fn
,
[])
self
.
assertAllClose
(
output
,
expected_keypoints
)
def
test_keypoint_weights_from_visibilities
(
self
):
def
graph_fn
():
keypoint_visibilities
=
tf
.
constant
([
...
...
research/object_detection/core/preprocessor.py
View file @
6d6cd4ac
...
...
@@ -69,6 +69,7 @@ from __future__ import print_function
import
functools
import
inspect
import
math
import
sys
import
six
...
...
@@ -4332,6 +4333,8 @@ def random_scale_crop_and_pad_to_square(
return
return_values
def
get_default_func_arg_map
(
include_label_weights
=
True
,
include_label_confidences
=
False
,
include_multiclass_scores
=
False
,
...
...
research/object_detection/core/preprocessor_test.py
View file @
6d6cd4ac
...
...
@@ -170,6 +170,7 @@ class PreprocessorTest(test_case.TestCase, parameterized.TestCase):
def
createTestMultiClassScores
(
self
):
return
tf
.
constant
([[
1.0
,
0.0
],
[
0.5
,
0.5
]],
dtype
=
tf
.
float32
)
def
expectedImagesAfterNormalization
(
self
):
images_r
=
tf
.
constant
([[[
0
,
0
,
0
,
0
],
[
-
1
,
-
1
,
0
,
0
],
[
-
1
,
0
,
0
,
0
],
[
0.5
,
0.5
,
0
,
0
]]],
...
...
@@ -4198,5 +4199,6 @@ class PreprocessorTest(test_case.TestCase, parameterized.TestCase):
self
.
assertAllEqual
(
image_original_shape_
,
image_gamma_shape_
)
if
__name__
==
'__main__'
:
tf
.
test
.
main
()
research/object_detection/protos/preprocessor.proto
View file @
6d6cd4ac
...
...
@@ -4,7 +4,7 @@ package object_detection.protos;
// Message for defining a preprocessing operation on input data.
// See: //third_party/tensorflow_models/object_detection/core/preprocessor.py
// Next ID: 4
0
// Next ID: 4
1
message
PreprocessingStep
{
oneof
preprocessing_step
{
NormalizeImage
normalize_image
=
1
;
...
...
@@ -30,7 +30,8 @@ message PreprocessingStep {
SSDRandomCrop
ssd_random_crop
=
21
;
SSDRandomCropPad
ssd_random_crop_pad
=
22
;
SSDRandomCropFixedAspectRatio
ssd_random_crop_fixed_aspect_ratio
=
23
;
SSDRandomCropPadFixedAspectRatio
ssd_random_crop_pad_fixed_aspect_ratio
=
24
;
SSDRandomCropPadFixedAspectRatio
ssd_random_crop_pad_fixed_aspect_ratio
=
24
;
RandomVerticalFlip
random_vertical_flip
=
25
;
RandomRotation90
random_rotation90
=
26
;
RGBtoGray
rgb_to_gray
=
27
;
...
...
@@ -55,8 +56,8 @@ message PreprocessingStep {
message
NormalizeImage
{
optional
float
original_minval
=
1
;
optional
float
original_maxval
=
2
;
optional
float
target_minval
=
3
[
default
=
0
];
optional
float
target_maxval
=
4
[
default
=
1
];
optional
float
target_minval
=
3
[
default
=
0
];
optional
float
target_maxval
=
4
[
default
=
1
];
}
// Randomly horizontally flips the image and detections with the specified
...
...
@@ -78,7 +79,7 @@ message RandomHorizontalFlip {
repeated
int32
keypoint_flip_permutation
=
1
;
// The probability of running this augmentation for each image.
optional
float
probability
=
2
[
default
=
0.5
];
optional
float
probability
=
2
[
default
=
0.5
];
}
// Randomly vertically flips the image and detections with the specified
...
...
@@ -99,7 +100,7 @@ message RandomVerticalFlip {
repeated
int32
keypoint_flip_permutation
=
1
;
// The probability of running this augmentation for each image.
optional
float
probability
=
2
[
default
=
0.5
];
optional
float
probability
=
2
[
default
=
0.5
];
}
// Randomly rotates the image and detections by 90 degrees counter-clockwise
...
...
@@ -112,48 +113,48 @@ message RandomRotation90 {
repeated
int32
keypoint_rot_permutation
=
1
;
// The probability of running this augmentation for each image.
optional
float
probability
=
2
[
default
=
0.5
];
optional
float
probability
=
2
[
default
=
0.5
];
}
// Randomly scales the values of all pixels in the image by some constant value
// between [minval, maxval], then clip the value to a range between [0, 1.0].
message
RandomPixelValueScale
{
optional
float
minval
=
1
[
default
=
0.9
];
optional
float
maxval
=
2
[
default
=
1.1
];
optional
float
minval
=
1
[
default
=
0.9
];
optional
float
maxval
=
2
[
default
=
1.1
];
}
// Randomly enlarges or shrinks image (keeping aspect ratio).
message
RandomImageScale
{
optional
float
min_scale_ratio
=
1
[
default
=
0.5
];
optional
float
max_scale_ratio
=
2
[
default
=
2.0
];
optional
float
min_scale_ratio
=
1
[
default
=
0.5
];
optional
float
max_scale_ratio
=
2
[
default
=
2.0
];
}
// Randomly convert entire image to grey scale.
message
RandomRGBtoGray
{
optional
float
probability
=
1
[
default
=
0.1
];
optional
float
probability
=
1
[
default
=
0.1
];
}
// Randomly changes image brightness by up to max_delta. Image outputs will be
// saturated between 0 and 1.
message
RandomAdjustBrightness
{
optional
float
max_delta
=
1
[
default
=
0.2
];
optional
float
max_delta
=
1
[
default
=
0.2
];
}
// Randomly scales contract by a value between [min_delta, max_delta].
message
RandomAdjustContrast
{
optional
float
min_delta
=
1
[
default
=
0.8
];
optional
float
max_delta
=
2
[
default
=
1.25
];
optional
float
min_delta
=
1
[
default
=
0.8
];
optional
float
max_delta
=
2
[
default
=
1.25
];
}
// Randomly alters hue by a value of up to max_delta.
message
RandomAdjustHue
{
optional
float
max_delta
=
1
[
default
=
0.02
];
optional
float
max_delta
=
1
[
default
=
0.02
];
}
// Randomly changes saturation by a value between [min_delta, max_delta].
message
RandomAdjustSaturation
{
optional
float
min_delta
=
1
[
default
=
0.8
];
optional
float
max_delta
=
2
[
default
=
1.25
];
optional
float
min_delta
=
1
[
default
=
0.8
];
optional
float
max_delta
=
2
[
default
=
1.25
];
}
// Performs a random color distortion. color_orderings should either be 0 or 1.
...
...
@@ -164,7 +165,7 @@ message RandomDistortColor {
// Randomly jitters corners of boxes in the image determined by ratio.
// ie. If a box is [100, 200] and ratio is 0.02, the corners can move by [1, 4].
message
RandomJitterBoxes
{
optional
float
ratio
=
1
[
default
=
0.05
];
optional
float
ratio
=
1
[
default
=
0.05
];
enum
JitterMode
{
DEFAULT
=
0
;
...
...
@@ -175,33 +176,32 @@ message RandomJitterBoxes {
// EXPAND - Only expands boxes
// SHRINK - Only shrinks boxes
// DEFAULT - Jitters each box boundary independently
optional
JitterMode
jitter_mode
=
2
[
default
=
DEFAULT
];
optional
JitterMode
jitter_mode
=
2
[
default
=
DEFAULT
];
}
// Randomly crops the image and bounding boxes.
message
RandomCropImage
{
// Cropped image must cover at least one box by this fraction.
optional
float
min_object_covered
=
1
[
default
=
1.0
];
optional
float
min_object_covered
=
1
[
default
=
1.0
];
// Aspect ratio bounds of cropped image.
optional
float
min_aspect_ratio
=
2
[
default
=
0.75
];
optional
float
max_aspect_ratio
=
3
[
default
=
1.33
];
optional
float
min_aspect_ratio
=
2
[
default
=
0.75
];
optional
float
max_aspect_ratio
=
3
[
default
=
1.33
];
// Allowed area ratio of cropped image to original image.
optional
float
min_area
=
4
[
default
=
0.1
];
optional
float
max_area
=
5
[
default
=
1.0
];
optional
float
min_area
=
4
[
default
=
0.1
];
optional
float
max_area
=
5
[
default
=
1.0
];
// Minimum overlap threshold of cropped boxes to keep in new image. If the
// ratio between a cropped bounding box and the original is less than this
// value, it is removed from the new image.
optional
float
overlap_thresh
=
6
[
default
=
0.3
];
optional
float
overlap_thresh
=
6
[
default
=
0.3
];
// Whether to clip the boxes to the cropped image.
optional
bool
clip_boxes
=
8
[
default
=
true
];
optional
bool
clip_boxes
=
8
[
default
=
true
];
// Probability of keeping the original image.
optional
float
random_coef
=
7
[
default
=
0.0
];
optional
float
random_coef
=
7
[
default
=
0.0
];
}
// Randomly adds padding to the image.
...
...
@@ -221,7 +221,8 @@ message RandomPadImage {
repeated
float
pad_color
=
5
;
}
// Randomly adds a padding of size [0, max_height_padding), [0, max_width_padding).
// Randomly adds a padding of size [0, max_height_padding), [0,
// max_width_padding).
message
RandomAbsolutePadImage
{
// Height will be padded uniformly at random from [0, max_height_padding).
optional
int32
max_height_padding
=
1
;
...
...
@@ -236,26 +237,26 @@ message RandomAbsolutePadImage {
// Randomly crops an image followed by a random pad.
message
RandomCropPadImage
{
// Cropping operation must cover at least one box by this fraction.
optional
float
min_object_covered
=
1
[
default
=
1.0
];
optional
float
min_object_covered
=
1
[
default
=
1.0
];
// Aspect ratio bounds of image after cropping operation.
optional
float
min_aspect_ratio
=
2
[
default
=
0.75
];
optional
float
max_aspect_ratio
=
3
[
default
=
1.33
];
optional
float
min_aspect_ratio
=
2
[
default
=
0.75
];
optional
float
max_aspect_ratio
=
3
[
default
=
1.33
];
// Allowed area ratio of image after cropping operation.
optional
float
min_area
=
4
[
default
=
0.1
];
optional
float
max_area
=
5
[
default
=
1.0
];
optional
float
min_area
=
4
[
default
=
0.1
];
optional
float
max_area
=
5
[
default
=
1.0
];
// Minimum overlap threshold of cropped boxes to keep in new image. If the
// ratio between a cropped bounding box and the original is less than this
// value, it is removed from the new image.
optional
float
overlap_thresh
=
6
[
default
=
0.3
];
optional
float
overlap_thresh
=
6
[
default
=
0.3
];
// Whether to clip the boxes to the cropped image.
optional
bool
clip_boxes
=
11
[
default
=
true
];
optional
bool
clip_boxes
=
11
[
default
=
true
];
// Probability of keeping the original image during the crop operation.
optional
float
random_coef
=
7
[
default
=
0.0
];
optional
float
random_coef
=
7
[
default
=
0.0
];
// Maximum dimensions for padded image. If unset, will use double the original
// image dimension as a lower bound. Both of the following fields should be
...
...
@@ -271,28 +272,28 @@ message RandomCropPadImage {
// Randomly crops an iamge to a given aspect ratio.
message
RandomCropToAspectRatio
{
// Aspect ratio.
optional
float
aspect_ratio
=
1
[
default
=
1.0
];
optional
float
aspect_ratio
=
1
[
default
=
1.0
];
// Minimum overlap threshold of cropped boxes to keep in new image. If the
// ratio between a cropped bounding box and the original is less than this
// value, it is removed from the new image.
optional
float
overlap_thresh
=
2
[
default
=
0.3
];
optional
float
overlap_thresh
=
2
[
default
=
0.3
];
// Whether to clip the boxes to the cropped image.
optional
bool
clip_boxes
=
3
[
default
=
true
];
optional
bool
clip_boxes
=
3
[
default
=
true
];
}
// Randomly adds black square patches to an image.
message
RandomBlackPatches
{
// The maximum number of black patches to add.
optional
int32
max_black_patches
=
1
[
default
=
10
];
optional
int32
max_black_patches
=
1
[
default
=
10
];
// The probability of a black patch being added to an image.
optional
float
probability
=
2
[
default
=
0.5
];
optional
float
probability
=
2
[
default
=
0.5
];
// Ratio between the dimension of the black patch to the minimum dimension of
// the image (patch_width = patch_height = min(image_height, image_width)).
optional
float
size_to_image_ratio
=
3
[
default
=
0.1
];
optional
float
size_to_image_ratio
=
3
[
default
=
0.1
];
}
// Randomly resizes the image up to [target_height, target_width].
...
...
@@ -307,20 +308,19 @@ message RandomResizeMethod {
message
RGBtoGray
{}
// Scales boxes from normalized coordinates to pixel coordinates.
message
ScaleBoxesToPixelCoordinates
{
}
message
ScaleBoxesToPixelCoordinates
{}
// Resizes images to [new_height, new_width].
message
ResizeImage
{
optional
int32
new_height
=
1
;
optional
int32
new_width
=
2
;
enum
Method
{
AREA
=
1
;
BICUBIC
=
2
;
BILINEAR
=
3
;
NEAREST_NEIGHBOR
=
4
;
AREA
=
1
;
BICUBIC
=
2
;
BILINEAR
=
3
;
NEAREST_NEIGHBOR
=
4
;
}
optional
Method
method
=
3
[
default
=
BILINEAR
];
optional
Method
method
=
3
[
default
=
BILINEAR
];
}
// Normalizes an image by subtracting a mean from each channel.
...
...
@@ -349,7 +349,7 @@ message SSDRandomCropOperation {
optional
float
overlap_thresh
=
6
;
// Whether to clip the boxes to the cropped image.
optional
bool
clip_boxes
=
8
[
default
=
true
];
optional
bool
clip_boxes
=
8
[
default
=
true
];
// Probability a crop operation is skipped.
optional
float
random_coef
=
7
;
...
...
@@ -382,7 +382,7 @@ message SSDRandomCropPadOperation {
optional
float
overlap_thresh
=
6
;
// Whether to clip the boxes to the cropped image.
optional
bool
clip_boxes
=
13
[
default
=
true
];
optional
bool
clip_boxes
=
13
[
default
=
true
];
// Probability a crop operation is skipped.
optional
float
random_coef
=
7
;
...
...
@@ -423,7 +423,7 @@ message SSDRandomCropFixedAspectRatioOperation {
optional
float
overlap_thresh
=
6
;
// Whether to clip the boxes to the cropped image.
optional
bool
clip_boxes
=
8
[
default
=
true
];
optional
bool
clip_boxes
=
8
[
default
=
true
];
// Probability a crop operation is skipped.
optional
float
random_coef
=
7
;
...
...
@@ -438,7 +438,7 @@ message SSDRandomCropFixedAspectRatio {
repeated
SSDRandomCropFixedAspectRatioOperation
operations
=
1
;
// Aspect ratio to crop to. This value is used for all crop operations.
optional
float
aspect_ratio
=
2
[
default
=
1.0
];
optional
float
aspect_ratio
=
2
[
default
=
1.0
];
}
message
SSDRandomCropPadFixedAspectRatioOperation
{
...
...
@@ -460,7 +460,7 @@ message SSDRandomCropPadFixedAspectRatioOperation {
optional
float
overlap_thresh
=
6
;
// Whether to clip the boxes to the cropped image.
optional
bool
clip_boxes
=
8
[
default
=
true
];
optional
bool
clip_boxes
=
8
[
default
=
true
];
// Probability a crop operation is skipped.
optional
float
random_coef
=
7
;
...
...
@@ -475,7 +475,7 @@ message SSDRandomCropPadFixedAspectRatio {
repeated
SSDRandomCropPadFixedAspectRatioOperation
operations
=
1
;
// Aspect ratio to pad to. This value is used for all crop and pad operations.
optional
float
aspect_ratio
=
2
[
default
=
1.0
];
optional
float
aspect_ratio
=
2
[
default
=
1.0
];
// Min ratio of padded image height and width to the input image's height and
// width. Two entries per operation.
...
...
@@ -490,7 +490,7 @@ message SSDRandomCropPadFixedAspectRatio {
// first.
message
ConvertClassLogitsToSoftmax
{
// Scale to use on logits before applying softmax.
optional
float
temperature
=
1
[
default
=
1.0
];
optional
float
temperature
=
1
[
default
=
1.0
];
}
// Randomly concatenates the image with itself horizontally and/or vertically.
...
...
@@ -504,7 +504,7 @@ message RandomSelfConcatImage {
// Apply an Autoaugment policy to the image and bounding boxes.
message
AutoAugmentImage
{
// What AutoAugment policy to apply to the Image
optional
string
policy_name
=
1
[
default
=
"v0"
];
optional
string
policy_name
=
1
[
default
=
"v0"
];
}
// Randomly drops ground truth boxes for a label with some probability.
...
...
@@ -516,9 +516,9 @@ message DropLabelProbabilistically {
optional
float
drop_probability
=
2
[
default
=
1.0
];
}
//Remap a set of labels to a new label.
//
Remap a set of labels to a new label.
message
RemapLabels
{
// Labels to be remapped.
// Labels to be remapped.
repeated
int32
original_labels
=
1
;
// Label to map to.
optional
int32
new_label
=
2
;
...
...
@@ -570,7 +570,6 @@ message RandomPatchGaussian {
// The augmentation is borrowed from [1]
// [1]: https://arxiv.org/abs/1904.07850
message
RandomSquareCropByScale
{
// The maximum size of the border. The border defines distance in pixels to
// the image boundaries that will not be considered as a center of a crop.
// To make sure that the border does not go over the center of the image,
...
...
@@ -579,12 +578,12 @@ message RandomSquareCropByScale {
optional
int32
max_border
=
1
[
default
=
128
];
// The minimum and maximum values of scale.
optional
float
scale_min
=
2
[
default
=
0.6
];
optional
float
scale_max
=
3
[
default
=
1.3
];
optional
float
scale_min
=
2
[
default
=
0.6
];
optional
float
scale_max
=
3
[
default
=
1.3
];
// The number of discrete scale values to randomly sample between
// [min_scale, max_scale]
optional
int32
num_scales
=
4
[
default
=
8
];
optional
int32
num_scales
=
4
[
default
=
8
];
}
// Randomly scale, crop, and then pad an image to the desired square output
...
...
@@ -600,12 +599,13 @@ message RandomScaleCropAndPadToSquare {
optional
int32
output_size
=
1
[
default
=
512
];
// The minimum and maximum values from which to sample the random scale.
optional
float
scale_min
=
2
[
default
=
0.1
];
optional
float
scale_max
=
3
[
default
=
2.0
];
optional
float
scale_min
=
2
[
default
=
0.1
];
optional
float
scale_max
=
3
[
default
=
2.0
];
}
// Adjusts the gamma of the image using the specified gamma and gain values.
message
AdjustGamma
{
optional
float
gamma
=
1
[
default
=
1.0
];
optional
float
gain
=
2
[
default
=
1.0
];
optional
float
gamma
=
1
[
default
=
1.0
];
optional
float
gain
=
2
[
default
=
1.0
];
}
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