MCPcopy Create free account
hub / github.com/DeepRec-AI/DeepRec / _CheckAtLeast3DImage

Function _CheckAtLeast3DImage

tensorflow/python/ops/image_ops_impl.py:200–239  ·  view source on GitHub ↗

Assert that we are working with properly shaped image. Args: image: >= 3-D Tensor of size [*, height, width, depth] require_static: If `True`, requires that all dimensions of `image` are known and non-zero. Raises: ValueError: if image.shape is not a [>= 3] vector. Returns

(image, require_static=True)

Source from the content-addressed store, hash-verified

198
199
200def _CheckAtLeast3DImage(image, require_static=True):
201 """Assert that we are working with properly shaped image.
202
203 Args:
204 image: >= 3-D Tensor of size [*, height, width, depth]
205 require_static: If `True`, requires that all dimensions of `image` are known
206 and non-zero.
207
208 Raises:
209 ValueError: if image.shape is not a [>= 3] vector.
210
211 Returns:
212 An empty list, if `image` has fully defined dimensions. Otherwise, a list
213 containing an assert op is returned.
214 """
215 try:
216 if image.get_shape().ndims is None:
217 image_shape = image.get_shape().with_rank(3)
218 else:
219 image_shape = image.get_shape().with_rank_at_least(3)
220 except ValueError:
221 raise ValueError("'image' must be at least three-dimensional.")
222 if require_static and not image_shape.is_fully_defined():
223 raise ValueError('\'image\' must be fully defined.')
224 if any(x == 0 for x in image_shape):
225 raise ValueError('all dims of \'image.shape\' must be > 0: %s' %
226 image_shape)
227 if not image_shape.is_fully_defined():
228 return [
229 check_ops.assert_positive(
230 array_ops.shape(image),
231 ["all dims of 'image.shape' "
232 'must be > 0.']),
233 check_ops.assert_greater_equal(
234 array_ops.rank(image),
235 3,
236 message="'image' must be at least three-dimensional.")
237 ]
238 else:
239 return []
240
241
242def _AssertGrayscaleImage(image):

Callers 5

_AssertAtLeast3DImageFunction · 0.85
pad_to_bounding_boxFunction · 0.85
crop_to_bounding_boxFunction · 0.85

Calls 7

anyFunction · 0.85
with_rankMethod · 0.80
with_rank_at_leastMethod · 0.80
is_fully_definedMethod · 0.80
get_shapeMethod · 0.45
shapeMethod · 0.45
rankMethod · 0.45

Tested by

no test coverage detected