tf-models-nightly 2.12.0.dev20230409__py2.py3-none-any.whl → 2.12.0.dev20230411__py2.py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- official/vision/ops/augment.py +84 -4
- {tf_models_nightly-2.12.0.dev20230409.dist-info → tf_models_nightly-2.12.0.dev20230411.dist-info}/METADATA +1 -1
- {tf_models_nightly-2.12.0.dev20230409.dist-info → tf_models_nightly-2.12.0.dev20230411.dist-info}/RECORD +7 -7
- {tf_models_nightly-2.12.0.dev20230409.dist-info → tf_models_nightly-2.12.0.dev20230411.dist-info}/AUTHORS +0 -0
- {tf_models_nightly-2.12.0.dev20230409.dist-info → tf_models_nightly-2.12.0.dev20230411.dist-info}/LICENSE +0 -0
- {tf_models_nightly-2.12.0.dev20230409.dist-info → tf_models_nightly-2.12.0.dev20230411.dist-info}/WHEEL +0 -0
- {tf_models_nightly-2.12.0.dev20230409.dist-info → tf_models_nightly-2.12.0.dev20230411.dist-info}/top_level.txt +0 -0
official/vision/ops/augment.py
CHANGED
@@ -31,7 +31,6 @@ import inspect
|
|
31
31
|
import math
|
32
32
|
from typing import Any, List, Iterable, Optional, Text, Tuple
|
33
33
|
|
34
|
-
from keras.layers.preprocessing import image_preprocessing as image_ops
|
35
34
|
import numpy as np
|
36
35
|
import tensorflow as tf
|
37
36
|
from tensorflow_addons import image as tfa_image
|
@@ -171,15 +170,96 @@ def _convert_angles_to_transform(angles: tf.Tensor, image_width: tf.Tensor,
|
|
171
170
|
)
|
172
171
|
|
173
172
|
|
173
|
+
def _apply_transform_to_images(
|
174
|
+
images,
|
175
|
+
transforms,
|
176
|
+
fill_mode='reflect',
|
177
|
+
fill_value=0.0,
|
178
|
+
interpolation='bilinear',
|
179
|
+
output_shape=None,
|
180
|
+
name=None,
|
181
|
+
):
|
182
|
+
"""Applies the given transform(s) to the image(s).
|
183
|
+
|
184
|
+
Args:
|
185
|
+
images: A tensor of shape `(num_images, num_rows, num_columns,
|
186
|
+
num_channels)` (NHWC). The rank must be statically known (the shape is
|
187
|
+
not `TensorShape(None)`).
|
188
|
+
transforms: Projective transform matrix/matrices. A vector of length 8 or
|
189
|
+
tensor of size N x 8. If one row of transforms is [a0, a1, a2, b0, b1,
|
190
|
+
b2, c0, c1], then it maps the *output* point `(x, y)` to a transformed
|
191
|
+
*input* point `(x', y') = ((a0 x + a1 y + a2) / k, (b0 x + b1 y + b2) /
|
192
|
+
k)`, where `k = c0 x + c1 y + 1`. The transforms are *inverted* compared
|
193
|
+
to the transform mapping input points to output points. Note that
|
194
|
+
gradients are not backpropagated into transformation parameters.
|
195
|
+
fill_mode: Points outside the boundaries of the input are filled according
|
196
|
+
to the given mode (one of `{"constant", "reflect", "wrap", "nearest"}`).
|
197
|
+
fill_value: a float represents the value to be filled outside the
|
198
|
+
boundaries when `fill_mode="constant"`.
|
199
|
+
interpolation: Interpolation mode. Supported values: `"nearest"`,
|
200
|
+
`"bilinear"`.
|
201
|
+
output_shape: Output dimension after the transform, `[height, width]`. If
|
202
|
+
`None`, output is the same size as input image.
|
203
|
+
name: The name of the op. Fill mode behavior for each valid value is as
|
204
|
+
follows
|
205
|
+
- `"reflect"`: `(d c b a | a b c d | d c b a)` The input is extended by
|
206
|
+
reflecting about the edge of the last pixel.
|
207
|
+
- `"constant"`: `(k k k k | a b c d | k k k k)` The input is extended by
|
208
|
+
filling all values beyond the edge with the same constant value k = 0.
|
209
|
+
- `"wrap"`: `(a b c d | a b c d | a b c d)` The input is extended by
|
210
|
+
wrapping around to the opposite edge.
|
211
|
+
- `"nearest"`: `(a a a a | a b c d | d d d d)` The input is extended by
|
212
|
+
the nearest pixel. Input shape: 4D tensor with shape:
|
213
|
+
`(samples, height, width, channels)`, in `"channels_last"` format.
|
214
|
+
Output shape: 4D tensor with shape: `(samples, height, width, channels)`,
|
215
|
+
in `"channels_last"` format.
|
216
|
+
|
217
|
+
Returns:
|
218
|
+
Image(s) with the same type and shape as `images`, with the given
|
219
|
+
transform(s) applied. Transformed coordinates outside of the input image
|
220
|
+
will be filled with zeros.
|
221
|
+
"""
|
222
|
+
with tf.name_scope(name or 'transform'):
|
223
|
+
if output_shape is None:
|
224
|
+
output_shape = tf.shape(images)[1:3]
|
225
|
+
if not tf.executing_eagerly():
|
226
|
+
output_shape_value = tf.get_static_value(output_shape)
|
227
|
+
if output_shape_value is not None:
|
228
|
+
output_shape = output_shape_value
|
229
|
+
|
230
|
+
output_shape = tf.convert_to_tensor(
|
231
|
+
output_shape, tf.int32, name='output_shape'
|
232
|
+
)
|
233
|
+
|
234
|
+
if not output_shape.get_shape().is_compatible_with([2]):
|
235
|
+
raise ValueError(
|
236
|
+
'output_shape must be a 1-D Tensor of 2 elements: '
|
237
|
+
'new_height, new_width, instead got '
|
238
|
+
f'output_shape={output_shape}'
|
239
|
+
)
|
240
|
+
|
241
|
+
fill_value = tf.convert_to_tensor(fill_value, tf.float32, name='fill_value')
|
242
|
+
|
243
|
+
return tf.raw_ops.ImageProjectiveTransformV3(
|
244
|
+
images=images,
|
245
|
+
output_shape=output_shape,
|
246
|
+
fill_value=fill_value,
|
247
|
+
transforms=transforms,
|
248
|
+
fill_mode=fill_mode.upper(),
|
249
|
+
interpolation=interpolation.upper(),
|
250
|
+
)
|
251
|
+
|
252
|
+
|
174
253
|
def transform(image: tf.Tensor, transforms) -> tf.Tensor:
|
175
|
-
"""
|
254
|
+
"""Transforms an image."""
|
176
255
|
original_ndims = tf.rank(image)
|
177
256
|
transforms = tf.convert_to_tensor(transforms, dtype=tf.float32)
|
178
257
|
if transforms.shape.rank == 1:
|
179
258
|
transforms = transforms[None]
|
180
259
|
image = to_4d(image)
|
181
|
-
image =
|
182
|
-
images=image, transforms=transforms, interpolation='nearest'
|
260
|
+
image = _apply_transform_to_images(
|
261
|
+
images=image, transforms=transforms, interpolation='nearest'
|
262
|
+
)
|
183
263
|
return from_4d(image, original_ndims)
|
184
264
|
|
185
265
|
|
@@ -973,7 +973,7 @@ official/vision/ops/anchor.py,sha256=jW8F1js-bFCo4JGP4rFw4ti6mHhUuEfTEkQ1mvLhfe8
|
|
973
973
|
official/vision/ops/anchor_generator.py,sha256=WwASWaE5uR9oIB69lnK8mW2xUfRnLY0LsgyVX1BwsQQ,7234
|
974
974
|
official/vision/ops/anchor_generator_test.py,sha256=aihKzRV8SQFhNSzS9_SpJNSadL4KcUcj0vT5dgmnkIQ,5286
|
975
975
|
official/vision/ops/anchor_test.py,sha256=UHue1kHD184Lh5eJzWQ2w0UAZk9FjolYJ9Eg6b1hIbo,7623
|
976
|
-
official/vision/ops/augment.py,sha256
|
976
|
+
official/vision/ops/augment.py,sha256=-8Ag70G1lYw4EEvIgitbX8er9WgPYhlc-QNC4N5UK20,95292
|
977
977
|
official/vision/ops/augment_test.py,sha256=r7oM3uUgmSnwPhQGiamkwt9s3wmbavykGEiC7Cj4Mho,19453
|
978
978
|
official/vision/ops/box_matcher.py,sha256=DHx5Y9Le4CiIK73oxk1DBjB28-SRuo-IUEd3BzdrTa4,9057
|
979
979
|
official/vision/ops/box_matcher_test.py,sha256=1QPcFSKhKCx2L65tH7suEEosCb2oGLLF1xPmHSmGT5E,2428
|
@@ -1071,9 +1071,9 @@ tensorflow_models/__init__.py,sha256=Ciz_YBke6teb6y42QyQTUBDdXJAiV7Qdu1zOoZvYiKw
|
|
1071
1071
|
tensorflow_models/tensorflow_models_test.py,sha256=Kz2y4V-rtBhZFFfKD2soCq52hviSfJVV1L2ztqS-9oM,1385
|
1072
1072
|
tensorflow_models/nlp/__init__.py,sha256=3dULDpUBpDi9vljpXadq6oJrWH4y6z42Bz2d3hopYZw,807
|
1073
1073
|
tensorflow_models/vision/__init__.py,sha256=4y77XkHaH8qLls3-6ta4tMp3Xj8CLbB0ihH91HsQ9z4,833
|
1074
|
-
tf_models_nightly-2.12.0.
|
1075
|
-
tf_models_nightly-2.12.0.
|
1076
|
-
tf_models_nightly-2.12.0.
|
1077
|
-
tf_models_nightly-2.12.0.
|
1078
|
-
tf_models_nightly-2.12.0.
|
1079
|
-
tf_models_nightly-2.12.0.
|
1074
|
+
tf_models_nightly-2.12.0.dev20230411.dist-info/AUTHORS,sha256=1dG3fXVu9jlo7bul8xuix5F5vOnczMk7_yWn4y70uw0,337
|
1075
|
+
tf_models_nightly-2.12.0.dev20230411.dist-info/LICENSE,sha256=WxeBS_DejPZQabxtfMOM_xn8qoZNJDQjrT7z2wG1I4U,11512
|
1076
|
+
tf_models_nightly-2.12.0.dev20230411.dist-info/METADATA,sha256=UqRWh_MwOd_8qU5NYSZ-8lAym0CDeCCWHPoAKiMKpwU,1426
|
1077
|
+
tf_models_nightly-2.12.0.dev20230411.dist-info/WHEEL,sha256=kGT74LWyRUZrL4VgLh6_g12IeVl_9u9ZVhadrgXZUEY,110
|
1078
|
+
tf_models_nightly-2.12.0.dev20230411.dist-info/top_level.txt,sha256=gum2FfO5R4cvjl2-QtP-S1aNmsvIZaFFT6VFzU0f4-g,33
|
1079
|
+
tf_models_nightly-2.12.0.dev20230411.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|