Skip to content

Fix Tensorflow 2 backward compatibility #18

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion pytorch_pretrained_biggan/convert_tf_to_pytorch.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,11 @@ def extract_batch_norm_stats(tf_model_path, batch_norm_stats_path=None):
"Please see https://www.tensorflow.org/install/ for installation instructions for TensorFlow. "
"And see https://github.com/tensorflow/hub for installing Hub. "
"Probably pip install tensorflow tensorflow-hub")
tf.reset_default_graph()
try:
tf.reset_default_graph() # TF 1
except AttributeError:
tf.compat.v1.reset_default_graph() # TF 2 backward compatibility

logger.info('Loading BigGAN module from: {}'.format(tf_model_path))
module = hub.Module(tf_model_path)
inputs = {k: tf.placeholder(v.dtype, v.get_shape().as_list(), k)
Expand Down