MCPcopy Index your code
hub / github.com/tensorflow/tensorboard / test_image

Method test_image

tensorboard/data_compat_test.py:144–186  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

142 self._assert_noop(value)
143
144 def test_image(self):
145 with tf.compat.v1.Graph().as_default():
146 old_op = tf.compat.v1.summary.image(
147 "mona_lisa",
148 tf.image.convert_image_dtype(
149 tf.random.normal(shape=[1, 400, 200, 3]),
150 tf.uint8,
151 saturate=True,
152 ),
153 )
154 old_value = self._value_from_op(old_op)
155 assert old_value.HasField("image"), old_value
156 new_value = data_compat.migrate_value(old_value)
157
158 self.assertEqual("mona_lisa/image/0", new_value.tag)
159 expected_metadata = image_metadata.create_summary_metadata(
160 display_name="mona_lisa/image/0",
161 description="",
162 converted_to_tensor=True,
163 )
164
165 # Check serialized submessages...
166 plugin_content = image_metadata.parse_plugin_metadata(
167 new_value.metadata.plugin_data.content
168 )
169 expected_content = image_metadata.parse_plugin_metadata(
170 expected_metadata.plugin_data.content
171 )
172 self.assertEqual(plugin_content, expected_content)
173 # ...then check full metadata except plugin content, since
174 # serialized forms need not be identical.
175 new_value.metadata.plugin_data.content = (
176 expected_metadata.plugin_data.content
177 )
178 self.assertEqual(expected_metadata, new_value.metadata)
179
180 self.assertTrue(new_value.HasField("tensor"))
181 (width, height, data) = tensor_util.make_ndarray(new_value.tensor)
182 self.assertEqual(b"200", width)
183 self.assertEqual(b"400", height)
184 self.assertEqual(
185 tf.compat.as_bytes(old_value.image.encoded_image_string), data
186 )
187
188 def test_histogram(self):
189 with tf.compat.v1.Graph().as_default():

Callers

nothing calls this directly

Calls 3

_value_from_opMethod · 0.95
GraphMethod · 0.45
imageMethod · 0.45

Tested by

no test coverage detected