From 7b776f442281e0e081d3dc91dd818ccac0a7b67e Mon Sep 17 00:00:00 2001 From: RAFALAMAO <86860721+RAFALAMAO@users.noreply.github.com> Date: Sat, 19 Feb 2022 18:25:43 -0600 Subject: [PATCH 1/4] Update README.md --- README.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/README.md b/README.md index bd67ccd..c3545e3 100644 --- a/README.md +++ b/README.md @@ -41,6 +41,11 @@ pip3 install -r requirements.txt # Download our TecoGAN model, the _Vid4_ and _TOS_ scenes shown in our paper and video. python3 runGan.py 0 +*TENSORFLOW 2* +# For Tensorlow2 compatibility, you need to install: +pip install tf_slim +pip install tensorflow_addons + # Run the inference mode on the calendar scene. # You can take a look of the parameter explanations in the runGan.py, feel free to try other scenes! python3 runGan.py 1 From 600ec6f0b6e20e04b3d77bf3813612fafef2f45e Mon Sep 17 00:00:00 2001 From: RAFALAMAO Date: Sat, 19 Feb 2022 18:35:16 -0600 Subject: [PATCH 2/4] Tensor Flow 2 Compatibility --- README.md | 10 +++++----- lib/ops.py | 21 ++++++++++++--------- main.py | 8 +++++--- 3 files changed, 22 insertions(+), 17 deletions(-) diff --git a/README.md b/README.md index c3545e3..becba99 100644 --- a/README.md +++ b/README.md @@ -32,6 +32,11 @@ For further explanations of the parameters take a look at the runGan.py file. Note: evaluation (test case 2) currently requires an Nvidia GPU with `CUDA`. `tkinter` is also required and may be installed via the `python3-tk` package. +*TENSORFLOW 2* +# For Tensorlow2 compatibility, you need to install: +pip install tf_slim +pip install tensorflow_addons + ```bash # Install tensorflow1.8+, pip3 install --ignore-installed --upgrade tensorflow-gpu # or tensorflow @@ -41,11 +46,6 @@ pip3 install -r requirements.txt # Download our TecoGAN model, the _Vid4_ and _TOS_ scenes shown in our paper and video. python3 runGan.py 0 -*TENSORFLOW 2* -# For Tensorlow2 compatibility, you need to install: -pip install tf_slim -pip install tensorflow_addons - # Run the inference mode on the calendar scene. # You can take a look of the parameter explanations in the runGan.py, feel free to try other scenes! python3 runGan.py 1 diff --git a/lib/ops.py b/lib/ops.py index 9f8510c..73d9484 100644 --- a/lib/ops.py +++ b/lib/ops.py @@ -1,5 +1,6 @@ -import tensorflow as tf -import tensorflow.contrib.slim as slim +# import tensorflow as tf +import tensorflow.compat.v1 as tf +import tf_slim as slim import pdb import keras @@ -8,6 +9,8 @@ import collections from tensorflow.python.ops import summary_op_util +tf.disable_eager_execution() + ### tensorflow functions ###################################################### def preprocess(image): @@ -37,10 +40,10 @@ def conv2_tran(batch_input, kernel=3, output_channel=64, stride=1, use_bias=True with tf.variable_scope(scope): if use_bias: return slim.conv2d_transpose(batch_input, output_channel, [kernel, kernel], stride, 'SAME', data_format='NHWC', - activation_fn=None, weights_initializer=tf.contrib.layers.xavier_initializer()) + activation_fn=None, weights_initializer=tf.keras.initializers.glorot_normal()) else: return slim.conv2d_transpose(batch_input, output_channel, [kernel, kernel], stride, 'SAME', data_format='NHWC', - activation_fn=None, weights_initializer=tf.contrib.layers.xavier_initializer(), + activation_fn=None, weights_initializer=tf.keras.initializers.glorot_normal(), biases_initializer=None) # Define the convolution building block @@ -49,10 +52,10 @@ def conv2(batch_input, kernel=3, output_channel=64, stride=1, use_bias=True, sco with tf.variable_scope(scope): if use_bias: return slim.conv2d(batch_input, output_channel, [kernel, kernel], stride, 'SAME', data_format='NHWC', - activation_fn=None, weights_initializer=tf.contrib.layers.xavier_initializer()) + activation_fn=None, weights_initializer=tf.keras.initializers.glorot_normal()) else: return slim.conv2d(batch_input, output_channel, [kernel, kernel], stride, 'SAME', data_format='NHWC', - activation_fn=None, weights_initializer=tf.contrib.layers.xavier_initializer(), + activation_fn=None, weights_initializer=tf.keras.initializers.glorot_normal(), biases_initializer=None) @@ -62,10 +65,10 @@ def conv2_NCHW(batch_input, kernel=3, output_channel=64, stride=1, use_bias=True with tf.variable_scope(scope): if use_bias: return slim.conv2d(batch_input, output_channel, [kernel, kernel], stride, 'SAME', data_format='NCWH', - activation_fn=None, weights_initializer=tf.contrib.layers.xavier_initializer()) + activation_fn=None, weights_initializer=tf.keras.initializers.glorot_normal()) else: return slim.conv2d(batch_input, output_channel, [kernel, kernel], stride, 'SAME', data_format='NCWH', - activation_fn=None, weights_initializer=tf.contrib.layers.xavier_initializer(), + activation_fn=None, weights_initializer=tf.keras.initializers.glorot_normal(), biases_initializer=None) @@ -95,7 +98,7 @@ def maxpool(inputs, scope='maxpool'): # Our dense layer def denselayer(inputs, output_size): # Rachel todo, put it to Model variable_scope - denseLayer = tf.layers.Dense(output_size, activation=None, kernel_initializer=tf.contrib.layers.xavier_initializer()) + denseLayer = tf.layers.Dense(output_size, activation=None, kernel_initializer=tf.keras.initializers.glorot_normal()) output = denseLayer.apply(inputs) tf.add_to_collection( name=tf.GraphKeys.MODEL_VARIABLES, value=denseLayer.kernel ) #output = tf.layers.dense(inputs, output_size, activation=None, kernel_initializer=tf.contrib.layers.xavier_initializer()) diff --git a/main.py b/main.py index 9d361da..04326d4 100644 --- a/main.py +++ b/main.py @@ -7,7 +7,9 @@ 3 = INFO, WARNING, and ERROR messages are not printed Disable Logs for now ''' os.environ['TF_CPP_MIN_LOG_LEVEL'] = '3' -import tensorflow as tf +import tensorflow.compat.v1 as tf +import tensorflow_addons as tfa +import tf_slim as slim from tensorflow.python.util import deprecation deprecation._PRINT_DEPRECATION_WARNINGS = False import random as rn @@ -18,7 +20,6 @@ rn.seed(12345) tf.set_random_seed(1234) -import tensorflow.contrib.slim as slim import sys, shutil, subprocess from lib.ops import * @@ -26,6 +27,7 @@ from lib.frvsr import generator_F, fnet from lib.Teco import FRVSR, TecoGAN +tf.disable_eager_execution() Flags = tf.app.flags @@ -212,7 +214,7 @@ def testWhileTrain(FLAGS, testno = 0): gen_flow_lr = tf.pad(gen_flow_lr, paddings, "SYMMETRIC") gen_flow = upscale_four(gen_flow_lr*4.0) gen_flow.set_shape( output_shape[:-1]+[2] ) - pre_warp_hi = tf.contrib.image.dense_image_warp(pre_gen, gen_flow) + pre_warp_hi = tfa.image.dense_image_warp(pre_gen, gen_flow) before_ops = tf.assign(pre_warp, pre_warp_hi) print('Finish building the network') From 73d5183d4f59739f5b1d5c75284aa60201df423b Mon Sep 17 00:00:00 2001 From: RAFALAMAO Date: Sat, 19 Feb 2022 18:37:32 -0600 Subject: [PATCH 3/4] Tensor Flow 2 Compatibility --- README.md | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index becba99..25cadaf 100644 --- a/README.md +++ b/README.md @@ -32,10 +32,12 @@ For further explanations of the parameters take a look at the runGan.py file. Note: evaluation (test case 2) currently requires an Nvidia GPU with `CUDA`. `tkinter` is also required and may be installed via the `python3-tk` package. -*TENSORFLOW 2* -# For Tensorlow2 compatibility, you need to install: +### Tensorflow 2 +#### For Tensorlow2 compatibility, you need to install: +```bash pip install tf_slim pip install tensorflow_addons +```bash ```bash # Install tensorflow1.8+, From 28c09e26b5c03a59c7da6def5b1ac9dd88d8a57c Mon Sep 17 00:00:00 2001 From: RAFALAMAO Date: Sat, 19 Feb 2022 18:38:18 -0600 Subject: [PATCH 4/4] Tensor Flow 2 Compatibility --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 25cadaf..4e44b82 100644 --- a/README.md +++ b/README.md @@ -37,7 +37,7 @@ Note: evaluation (test case 2) currently requires an Nvidia GPU with `CUDA`. ```bash pip install tf_slim pip install tensorflow_addons -```bash +``` ```bash # Install tensorflow1.8+,