yanx27 / EverybodyDanceNow_reproduce_pytorch

Everybody dance now reproduced in pytorch
MIT License
608 stars 172 forks source link

AttributeError: module 'tensorboard.summary._tf.summary' has no attribute 'FileWriter' #102

Open ghost opened 3 years ago

ghost commented 3 years ago

I'm getting this error when running !python train_pose2vid.py on colab:

Traceback (most recent call last):
  File "train_pose2vid.py", line 127, in <module>
    main()
  File "train_pose2vid.py", line 43, in main
    visualizer = Visualizer(opt)
  File "/content/drive/My Drive/animation/EveryBodyDance/src/pix2pixHD/util/visualizer.py", line 26, in __init__
    self.writer = tf.summary.FileWriter(self.log_dir)
AttributeError: module 'tensorboard.summary._tf.summary' has no attribute 'FileWriter'

When I changed the line 26 in visualizer.py (as said in this issue: https://github.com/yanx27/EverybodyDanceNow_reproduce_pytorch/issues/99), I'm getting this error instead:

Traceback (most recent call last):
  File "train_pose2vid.py", line 127, in <module>
    main()
  File "train_pose2vid.py", line 43, in main
    visualizer = Visualizer(opt)
  File "/content/drive/My Drive/animation/EveryBodyDance/src/pix2pixHD/util/visualizer.py", line 26, in __init__
    self.writer = tf.compat.v1.summary.FileWriter(self.log_dir)
  File "/usr/local/lib/python3.7/dist-packages/tensorflow/python/summary/writer/writer.py", line 360, in __init__
    "v1.summary.FileWriter is not compatible with eager execution. "
RuntimeError: v1.summary.FileWriter is not compatible with eager execution. Use `tf.summary.create_file_writer`,or a `with v1.Graph().as_default():` context

P.S. I changed it to tf.summary.create_file_writer, as said in the error message, and for now I'm not getting this error (it's currently executing this sell)

Getting this error instead now (issue https://github.com/yanx27/EverybodyDanceNow_reproduce_pytorch/issues/48):

Traceback (most recent call last):
  File "train_pose2vid.py", line 127, in <module>
    main()
  File "train_pose2vid.py", line 84, in main
    errors = {k: v.data[0] if not isinstance(v, int) else v for k, v in loss_dict.items()}
  File "train_pose2vid.py", line 84, in <dictcomp>
    errors = {k: v.data[0] if not isinstance(v, int) else v for k, v in loss_dict.items()}
IndexError: invalid index of a 0-dim tensor. Use `tensor.item()` in Python or `tensor.item<T>()` in C++ to convert a 0-dim tensor to a number
dklingmann commented 3 years ago

What version of tensorflow are you using? You can find this by printing the __version__ attribute print(tensorflow.__version__) for example.

If you are using GoogleColab, try: import tensorflow.compat.v1 as tf tf.disable_v2_behavior() %tensorflow_version 1.x

before running !python train_pose2vid.py

The IndexError message is related to: errors = {k: v.data[0] if not isinstance(v, int) else v for k, v in loss_dict.items()} See #100 : replace v.data[0] with v.data.item()