CoolFace
Apppublic

karolmajek/maxdeeplab

sourceHugging Faceupdated 5y agoView on Hugging Face
0likes
test_utils.py32 linesDownload Raw Back to model
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"""This file contains utility functions for the model tests."""17import numpy as np18import tensorflow as tf19 20 21def create_test_input(batch, height, width, channels):22  """Creates test input tensor."""23  input_tensor = np.tile(24      np.reshape(25          np.reshape(np.arange(height), [height, 1]) +26          np.reshape(np.arange(width), [1, width]),27          [1, height, width, 1]),28      [batch, 1, 1, channels])29  # Normalize the input tensor so that the outputs are not too large.30  input_tensor = (input_tensor * 2 / np.max(input_tensor)) - 131  return tf.cast(input_tensor, tf.float32)32