http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. """ from sparse_operation_kit import operations as sok_ops from tensorflow.python.framework import load_library, ops from tensorflow.python.ops import array_ops from tensorflow.python.framework.tensor_shape import TensorShape from tensorflow.python.ops import resource_variable_ops from tensorflow import __version__ as tf_version if tf_version.startswith("2"): using_tf2 = True elif tf_version.startswith("1"): using_tf2 = False else: raise RuntimeError("Not supported TF version: {}".format(tf_version)) import os def in_tensorflow2(): """ This function will tell whether the installed TensorFlow is 2.x """ return using_tf2
from __future__ import print_function, unicode_literals, absolute_import, division from six.moves import range, zip, map, reduce, filter import numpy as np import os import warnings import shutil import datetime from importlib import import_module from tensorflow import __version__ as _tf_version IS_TF_1 = _tf_version.startswith('1.') _KERAS = 'keras' if IS_TF_1 else 'tensorflow.keras' def keras_import(sub=None, *names): if sub is None: return import_module(_KERAS) else: mod = import_module('{_KERAS}.{sub}'.format(_KERAS=_KERAS,sub=sub)) if len(names) == 0: return mod elif len(names) == 1: return getattr(mod, names[0]) return tuple(getattr(mod, name) for name in names) import tensorflow as tf # if IS_TF_1: # import tensorflow as tf # else: # import tensorflow.compat.v1 as tf # # tf.disable_v2_behavior()
""" # Modules imported import sys import os import argparse import imghdr import numpy as np from cv2 import imread, imwrite, resize, cvtColor, COLOR_BGR2GRAY from tensorflow.keras.models import load_model from tensorflow import __version__ as tf_version #from PIL import Image #import matplotlib.pyplot as plt from models import istl from utils import root_sum_squared_error if tf_version.startswith('1'): from tensorflow import ConfigProto, Session config = ConfigProto() config.gpu_options.allow_growth = True sess = Session(config=config) else: from tensorflow import config physical_devices = config.experimental.list_physical_devices('GPU') config.experimental.set_memory_growth(physical_devices[0], True) # Constants CUBOIDS_LENGTH = 8 CUBOIDS_WIDTH = 224 CUBOIDS_HEIGHT = 224
""" Copyright (c) 2021, NVIDIA CORPORATION. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. """ """ optimizers from TensorFlow """ from .adam import Adam from tensorflow import __version__ as tf_version if tf_version.startswith("1"): from .lazy_adam import LazyAdamOptimizer __all__ = [item for item in dir() if not item.startswith("__")]