genforce / ghfeat

[CVPR 2021] Generative Hierarchical Features from Synthesizing Images
https://genforce.github.io/ghfeat/
157 stars 20 forks source link

Upgrading to TF 2.0 #8

Open snehalstomar opened 2 years ago

snehalstomar commented 2 years ago

Hi!

I am trying to upgrade the GHFeat model to Tensorflow 2.2 from Tensorflow 1.2 for my project. To this end, I used the tf_upgrade_v2 provided in TF2.0. The function made several changes however, It omitted making changes to files in the "dnnlib/" directory. So I am having to do those manually.

There's one statement in "dnnlib/tflib/network.py" which returns an error when interpreted with TF2.0, which I not being able to fix. The troublesome statement is Line 291, given as below:
exec(self._build_module_src, module.__dict__) # pylint: disable=exec-used. The error trace-back for the same is: exec(self._build_module_src, module.__dict__) # pylint: disable=exec-used File "<string>", line 11, in <module> ModuleNotFoundError: No module named 'tensorflow.contrib' I understand that I need to go to the file where module has been defined and change "tf.contrib." to "tf.compat.v1.contrib." / "tf_slim.". However since the trace-back mentions the filename as "String", I am not being able to figure out the file to which I need to make changes. I request the community and repository maintainers to kindly help me out in this regard.

So far, the following attempts of mine to fix this issue have failed:

  1. upgrading the Pickle PROTOCOL to 5
  2. following the steps given here
  3. trying out python's compile() function to figure out the path to the erroneous file

Looking forward to effective insights and discussions in this regard.

Thanks.