CoolFace
Apppublic

karolmajek/Axial-DeepLab-SWideRNet

sourceHugging Faceupdated 5y agoView on Hugging Face
0likes
autoaugment_utils_test.py41 linesDownload Raw Back to preprocessing
1# coding=utf-82# Copyright 2021 The Deeplab2 Authors.3#4# Licensed under the Apache License, Version 2.0 (the "License");5# you may not use this file except in compliance with the License.6# You may obtain a copy of the License at7#8#     http://www.apache.org/licenses/LICENSE-2.09#10# Unless required by applicable law or agreed to in writing, software11# distributed under the License is distributed on an "AS IS" BASIS,12# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.13# See the License for the specific language governing permissions and14# limitations under the License.15 16"""Tests for autoaugment_utils.py."""17 18import numpy as np19import tensorflow as tf20 21from deeplab2.data.preprocessing import autoaugment_utils22 23 24class AutoaugmentUtilsTest(tf.test.TestCase):25 26  def testAugmentWithNamedPolicy(self):27    num_classes = 328    np_image = np.random.randint(256, size=(13, 13, 3))29    image = tf.constant(np_image, dtype=tf.uint8)30    np_label = np.random.randint(num_classes, size=(13, 13, 1))31    label = tf.constant(np_label, dtype=tf.int32)32    image, label = autoaugment_utils.distort_image_with_autoaugment(33        image, label, ignore_label=255,34        augmentation_name='simple_classification_policy')35    self.assertTrue(image.numpy().any())36    self.assertTrue(label.numpy().any())37 38 39if __name__ == '__main__':40  tf.test.main()41