Returns the dimensions of an image tensor. Args: image: A rank-D Tensor. For 3-D of shape: `[height, width, channels]`. rank: The expected rank of the image Returns: A list of corresponding to the dimensions of the input image. Dimensions that are statically known are python
(image, rank)
| 97 | |
| 98 | |
| 99 | def _ImageDimensions(image, rank): |
| 100 | """Returns the dimensions of an image tensor. |
| 101 | |
| 102 | Args: |
| 103 | image: A rank-D Tensor. For 3-D of shape: `[height, width, channels]`. |
| 104 | rank: The expected rank of the image |
| 105 | |
| 106 | Returns: |
| 107 | A list of corresponding to the dimensions of the |
| 108 | input image. Dimensions that are statically known are python integers, |
| 109 | otherwise they are integer scalar tensors. |
| 110 | """ |
| 111 | if image.get_shape().is_fully_defined(): |
| 112 | return image.get_shape().as_list() |
| 113 | else: |
| 114 | static_shape = image.get_shape().with_rank(rank).as_list() |
| 115 | dynamic_shape = array_ops.unstack(array_ops.shape(image), rank) |
| 116 | return [ |
| 117 | s if s is not None else d for s, d in zip(static_shape, dynamic_shape) |
| 118 | ] |
| 119 | |
| 120 | |
| 121 | def _Check3DImage(image, require_static=True): |
no test coverage detected