zsyzzsoft / co-mod-gan

[ICLR 2021, Spotlight] Large Scale Image Completion via Co-Modulated Generative Adversarial Networks
Other
448 stars 66 forks source link

run_generator.py throws rank do not match error #6

Closed karynaur closed 3 years ago

karynaur commented 3 years ago

I was trying to use the run_generator.py on example images in imgs/ and ended up running into this error.

!python run_generator.py -c /content/drive/MyDrive/co-mod-gan-ffhq-9-025000.pkl -i imgs/example_image.jpg -m imgs/example_mask.jpg -o output.jpg

Setting up TensorFlow plugin "fused_bias_act.cu": Preprocessing... Loading... Done.
Setting up TensorFlow plugin "upfirdn_2d.cu": Preprocessing... Loading... Done.
Traceback (most recent call last):
  File "/tensorflow-1.15.2/python3.7/tensorflow_core/python/client/session.py", line 1365, in _do_call
    return fn(*args)
  File "/tensorflow-1.15.2/python3.7/tensorflow_core/python/client/session.py", line 1350, in _run_fn
    target_list, run_metadata)
  File "/tensorflow-1.15.2/python3.7/tensorflow_core/python/client/session.py", line 1443, in _call_tf_sessionrun
    run_metadata)
tensorflow.python.framework.errors_impl.InvalidArgumentError: 2 root error(s) found.
  (0) Invalid argument: ConcatOp : Ranks of all input tensors should match: shape[0] = [1,512,512] vs. shape[1] = [1,3,512,512]
     [[{{node Gs/_Run/Gs/G_synthesis/concat}}]]
     [[Gs/_Run/Gs/images_out/_1587]]
  (1) Invalid argument: ConcatOp : Ranks of all input tensors should match: shape[0] = [1,512,512] vs. shape[1] = [1,3,512,512]
     [[{{node Gs/_Run/Gs/G_synthesis/concat}}]]
0 successful operations.
0 derived errors ignored.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "run_generator.py", line 35, in <module>
    main()
  File "run_generator.py", line 32, in main
    create_from_images(**vars(args))
  File "run_generator.py", line 18, in create_from_images
    fake = Gs.run(latent, None, real[np.newaxis], mask[np.newaxis])[0]
  File "/content/co-mod-gan/dnnlib/tflib/network.py", line 442, in run
    mb_out = tf.get_default_session().run(out_expr, dict(zip(in_expr, mb_in)))
  File "/tensorflow-1.15.2/python3.7/tensorflow_core/python/client/session.py", line 956, in run
    run_metadata_ptr)
  File "/tensorflow-1.15.2/python3.7/tensorflow_core/python/client/session.py", line 1180, in _run
    feed_dict_tensor, options, run_metadata)
  File "/tensorflow-1.15.2/python3.7/tensorflow_core/python/client/session.py", line 1359, in _do_run
    run_metadata)
  File "/tensorflow-1.15.2/python3.7/tensorflow_core/python/client/session.py", line 1384, in _do_call
    raise type(e)(node_def, op, message)
tensorflow.python.framework.errors_impl.InvalidArgumentError: 2 root error(s) found.
  (0) Invalid argument: ConcatOp : Ranks of all input tensors should match: shape[0] = [1,512,512] vs. shape[1] = [1,3,512,512]
     [[node Gs/_Run/Gs/G_synthesis/concat (defined at /tensorflow-1.15.2/python3.7/tensorflow_core/python/framework/ops.py:1748) ]]
     [[Gs/_Run/Gs/images_out/_1587]]
  (1) Invalid argument: ConcatOp : Ranks of all input tensors should match: shape[0] = [1,512,512] vs. shape[1] = [1,3,512,512]
     [[node Gs/_Run/Gs/G_synthesis/concat (defined at /tensorflow-1.15.2/python3.7/tensorflow_core/python/framework/ops.py:1748) ]]
0 successful operations.
0 derived errors ignored.

Original stack trace for 'Gs/_Run/Gs/G_synthesis/concat':
  File "run_generator.py", line 35, in <module>
    main()
  File "run_generator.py", line 32, in main
    create_from_images(**vars(args))
  File "run_generator.py", line 18, in create_from_images
    fake = Gs.run(latent, None, real[np.newaxis], mask[np.newaxis])[0]
  File "/content/co-mod-gan/dnnlib/tflib/network.py", line 417, in run
    out_gpu = net_gpu.get_output_for(*in_gpu, return_as_list=True, **dynamic_kwargs)
  File "/content/co-mod-gan/dnnlib/tflib/network.py", line 221, in get_output_for
    out_expr = self._build_func(*final_inputs, **build_kwargs)
  File "<string>", line 240, in G_main
  File "/content/co-mod-gan/dnnlib/tflib/network.py", line 221, in get_output_for
    out_expr = self._build_func(*final_inputs, **build_kwargs)
  File "<string>", line 387, in G_synthesis_RegionGAN
  File "/tensorflow-1.15.2/python3.7/tensorflow_core/python/util/dispatch.py", line 180, in wrapper
    return target(*args, **kwargs)
  File "/tensorflow-1.15.2/python3.7/tensorflow_core/python/ops/array_ops.py", line 1420, in concat
    return gen_array_ops.concat_v2(values=values, axis=axis, name=name)
  File "/tensorflow-1.15.2/python3.7/tensorflow_core/python/ops/gen_array_ops.py", line 1257, in concat_v2
    "ConcatV2", values=values, axis=axis, name=name)
  File "/tensorflow-1.15.2/python3.7/tensorflow_core/python/framework/op_def_library.py", line 794, in _apply_op_helper
    op_def=op_def)
  File "/tensorflow-1.15.2/python3.7/tensorflow_core/python/util/deprecation.py", line 507, in new_func
    return func(*args, **kwargs)
  File "/tensorflow-1.15.2/python3.7/tensorflow_core/python/framework/ops.py", line 3357, in create_op
    attrs, op_def, compute_device)
  File "/tensorflow-1.15.2/python3.7/tensorflow_core/python/framework/ops.py", line 3426, in _create_op_internal
    op_def=op_def)
  File "/tensorflow-1.15.2/python3.7/tensorflow_core/python/framework/ops.py", line 1748, in __init__
    self._traceback = tf_stack.extract_stack()```
zsyzzsoft commented 3 years ago

The problem should be fixed now.

karynaur commented 3 years ago

Thank you so much!!