Puzer / stylegan-encoder

StyleGAN Encoder - converts real images to latent space
Other
1.07k stars 166 forks source link

KeyError: "The name 'G_synthesis_1/_Run/concat:0' refers to a Tensor which does not exist. The operation, 'G_synthesis_1/_Run/concat', does not exist in the graph." #46

Closed eluzzi5 closed 3 years ago

eluzzi5 commented 3 years ago

Getting this error after running the following with TensorFlow 1.x in Google Colab on a GPU runtime: !python encode_images.py aligned_images/ generated_images/ latent_representations/ --iterations 1000

Full error: Traceback (most recent call last): File "encode_images.py", line 80, in main() File "encode_images.py", line 53, in main generator = Generator(Gs_network, args.batch_size, randomize_noise=args.randomize_noise) File "/content/stylegan/encoder/generator_model.py", line 35, in init self.generator_output = self.graph.get_tensor_by_name('G_synthesis_1/_Run/concat:0') File "/tensorflow-1.15.2/python3.6/tensorflow_core/python/framework/ops.py", line 3783, in get_tensor_by_name return self.as_graph_element(name, allow_tensor=True, allow_operation=False) File "/tensorflow-1.15.2/python3.6/tensorflow_core/python/framework/ops.py", line 3607, in as_graph_element return self._as_graph_element_locked(obj, allow_tensor, allow_operation) File "/tensorflow-1.15.2/python3.6/tensorflow_core/python/framework/ops.py", line 3649, in _as_graph_element_locked "graph." % (repr(name), repr(op_name))) KeyError: "The name 'G_synthesis_1/_Run/concat:0' refers to a Tensor which does not exist. The operation, 'G_synthesis_1/_Run/concat', does not exist in the graph."

Any help would be greatly appreciated!

dagdelenmustafa commented 3 years ago

Could you find a solution ?

eluzzi5 commented 3 years ago

Could you find a solution ?

No, I could not :( Can anyone help?

dagdelenmustafa commented 3 years ago

Hey @eluzzi5 !!!

I just discover that this repo uses tensorflow 1.14 and if you work on colab the versions does not match. And sometimes although the colab displays you are using GPU environment, tensorflow don't see your GPUs. So if you follow the following steps your problem might be solved.

Uninstall current tensorflow and install tensorflow 1.14: !pip uninstall -y tensorflow-gpu !pip uninstall -y tensorflow !pip install tensorflow-gpu==1.14

Import tensorflow and check your version: import tensorflow print(tensorflow.__version__)

Finaly Check your availiable GPUs: tensorflow.test.is_gpu_available()

eluzzi5 commented 3 years ago

Hey @eluzzi5 !!!

I just discover that this repo uses tensorflow 1.14 and if you work on colab the versions does not match. And sometimes although the colab displays you are using GPU environment, tensorflow don't see your GPUs. So if you follow the following steps your problem might be solved.

Uninstall current tensorflow and install tensorflow 1.14: !pip uninstall -y tensorflow-gpu !pip uninstall -y tensorflow !pip install tensorflow-gpu==1.14

Import tensorflow and check your version: import tensorflow print(tensorflow.__version__)

Finaly Check your availiable GPUs: tensorflow.test.is_gpu_available()

@dagdelenmustafa That fixed everything for me! Thank you SO much!