"examples/git@developer.sourcefind.cn:OpenDAS/torchaudio.git" did not exist on "13b2349af91fd02810c8813919a5ae08e617919e"
Commit e97979cb authored by Fan Yang's avatar Fan Yang Committed by A. Unique TensorFlower
Browse files

Internal change.

PiperOrigin-RevId: 408374423
parent fc2d4b69
...@@ -19,9 +19,6 @@ import os ...@@ -19,9 +19,6 @@ import os
from absl.testing import parameterized from absl.testing import parameterized
import tensorflow as tf import tensorflow as tf
from official.common import dataset_fn
from official.core import config_definitions as cfg
from official.core import input_reader
from official.projects.volumetric_models.dataloaders import segmentation_input_3d from official.projects.volumetric_models.dataloaders import segmentation_input_3d
from official.vision.beta.dataloaders import tfexample_utils from official.vision.beta.dataloaders import tfexample_utils
...@@ -33,19 +30,15 @@ class InputReaderTest(parameterized.TestCase, tf.test.TestCase): ...@@ -33,19 +30,15 @@ class InputReaderTest(parameterized.TestCase, tf.test.TestCase):
data_dir = os.path.join(self.get_temp_dir(), 'data') data_dir = os.path.join(self.get_temp_dir(), 'data')
tf.io.gfile.makedirs(data_dir) tf.io.gfile.makedirs(data_dir)
self._data_path = os.path.join(data_dir, 'data.tfrecord') self._data_path = os.path.join(data_dir, 'data.tfrecord')
# pylint: disable=g-complex-comprehension self._example = tfexample_utils.create_3d_image_test_example(
examples = [ image_height=32, image_width=32, image_volume=32, image_channel=2)
tfexample_utils.create_3d_image_test_example(
image_height=32, image_width=32, image_volume=32, image_channel=2)
for _ in range(20)
]
# pylint: enable=g-complex-comprehension
tfexample_utils.dump_to_tfrecord(self._data_path, tf_examples=examples)
@parameterized.parameters(([32, 32, 32], 2, 2)) @parameterized.parameters(
def testSegmentationInputReader(self, input_size, num_classes, num_channels): ([32, 32, 32], 2, 2, False),
params = cfg.DataConfig( ([32, 32, 32], 2, 2, True),
input_path=self._data_path, global_batch_size=2, is_training=False) )
def testSegmentationInputReader(self, input_size, num_classes, num_channels,
is_training):
decoder = segmentation_input_3d.Decoder() decoder = segmentation_input_3d.Decoder()
parser = segmentation_input_3d.Parser( parser = segmentation_input_3d.Parser(
...@@ -53,23 +46,16 @@ class InputReaderTest(parameterized.TestCase, tf.test.TestCase): ...@@ -53,23 +46,16 @@ class InputReaderTest(parameterized.TestCase, tf.test.TestCase):
num_classes=num_classes, num_classes=num_classes,
num_channels=num_channels) num_channels=num_channels)
reader = input_reader.InputReader( decoded_tensor = decoder.decode(self._example.SerializeToString())
params, image, labels = parser.parse_fn(is_training=is_training)(decoded_tensor)
dataset_fn=dataset_fn.pick_dataset_fn('tfrecord'),
decoder_fn=decoder.decode,
parser_fn=parser.parse_fn(params.is_training))
dataset = reader.read()
iterator = iter(dataset)
image, labels = next(iterator)
# Checks image shape. # Checks image shape.
self.assertEqual( self.assertEqual(
list(image.numpy().shape), list(image.numpy().shape),
[2, input_size[0], input_size[1], input_size[2], num_channels]) [input_size[0], input_size[1], input_size[2], num_channels])
self.assertEqual( self.assertEqual(
list(labels.numpy().shape), list(labels.numpy().shape),
[2, input_size[0], input_size[1], input_size[2], num_classes]) [input_size[0], input_size[1], input_size[2], num_classes])
if __name__ == '__main__': if __name__ == '__main__':
......
...@@ -31,7 +31,11 @@ class NNBlocks3DTest(parameterized.TestCase, tf.test.TestCase): ...@@ -31,7 +31,11 @@ class NNBlocks3DTest(parameterized.TestCase, tf.test.TestCase):
shape=(spatial_size, spatial_size, volume_size, filters * 4), shape=(spatial_size, spatial_size, volume_size, filters * 4),
batch_size=1) batch_size=1)
block = nn_blocks_3d.BottleneckBlock3DVolume( block = nn_blocks_3d.BottleneckBlock3DVolume(
filters=filters, strides=strides, use_projection=True) filters=filters,
strides=strides,
use_projection=True,
se_ratio=0.2,
stochastic_depth_drop_rate=0.2)
features = block(inputs) features = block(inputs)
...@@ -46,7 +50,11 @@ class NNBlocks3DTest(parameterized.TestCase, tf.test.TestCase): ...@@ -46,7 +50,11 @@ class NNBlocks3DTest(parameterized.TestCase, tf.test.TestCase):
inputs = tf.keras.Input( inputs = tf.keras.Input(
shape=(spatial_size, spatial_size, volume_size, filters), batch_size=1) shape=(spatial_size, spatial_size, volume_size, filters), batch_size=1)
block = nn_blocks_3d.ResidualBlock3DVolume( block = nn_blocks_3d.ResidualBlock3DVolume(
filters=filters, strides=strides, use_projection=True) filters=filters,
strides=strides,
use_projection=True,
se_ratio=0.2,
stochastic_depth_drop_rate=0.2)
features = block(inputs) features = block(inputs)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment