zsyzzsoft / co-mod-gan

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

Error when running in Colab #45

Closed qo4on closed 2 years ago

qo4on commented 2 years ago

Does anyone know how to fix this?

!gdown -q --id 1M2dSxlJnCFNM6LblpB2nQCnaimgwaaKu
!git clone https://github.com/zsyzzsoft/co-mod-gan.git &> /dev/null
%tensorflow_version 1.x
%cd co-mod-gan

!python run_generator.py -c /content/co-mod-gan-ffhq-10-025000.pkl -i imgs/example_image.jpg -m imgs/example_mask.jpg -o imgs/example_output.jpg
Setting up TensorFlow plugin "fused_bias_act.cu": Preprocessing... Compiling... Loading... Done.
Setting up TensorFlow plugin "upfirdn_2d.cu": Preprocessing... Compiling... 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: Input to reshape is a tensor with 8405000 values, but the requested shape requires a multiple of 33620000
     [[{{node Gs/_Run/Gs/G_synthesis/E_1024x1024/Conv1_down/Reshape_1}}]]
     [[Gs/_Run/Gs/images_out/_1767]]
  (1) Invalid argument: Input to reshape is a tensor with 8405000 values, but the requested shape requires a multiple of 33620000
     [[{{node Gs/_Run/Gs/G_synthesis/E_1024x1024/Conv1_down/Reshape_1}}]]
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 34, in <module>
    main()
  File "run_generator.py", line 31, in main
    generate(**vars(args))
  File "run_generator.py", line 16, in generate
    fake = Gs.run(latent, None, real[np.newaxis], mask[np.newaxis], truncation_psi=truncation)[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: Input to reshape is a tensor with 8405000 values, but the requested shape requires a multiple of 33620000
     [[node Gs/_Run/Gs/G_synthesis/E_1024x1024/Conv1_down/Reshape_1 (defined at /tensorflow-1.15.2/python3.7/tensorflow_core/python/framework/ops.py:1748) ]]
     [[Gs/_Run/Gs/images_out/_1767]]
  (1) Invalid argument: Input to reshape is a tensor with 8405000 values, but the requested shape requires a multiple of 33620000
     [[node Gs/_Run/Gs/G_synthesis/E_1024x1024/Conv1_down/Reshape_1 (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/E_1024x1024/Conv1_down/Reshape_1':
  File "run_generator.py", line 34, in <module>
    main()
  File "run_generator.py", line 31, in main
    generate(**vars(args))
  File "run_generator.py", line 16, in generate
    fake = Gs.run(latent, None, real[np.newaxis], mask[np.newaxis], truncation_psi=truncation)[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 241, 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 384, in G_synthesis_RegionGAN
  File "<string>", line 355, in E_block
  File "<string>", line 58, in conv2d_layer
  File "/content/co-mod-gan/dnnlib/tflib/ops/upfirdn_2d.py", line 333, in conv_downsample_2d
    x = _simple_upfirdn_2d(x, k, pad0=(p+1)//2, pad1=p//2, data_format=data_format, impl=impl)
  File "/content/co-mod-gan/dnnlib/tflib/ops/upfirdn_2d.py", line 363, in _simple_upfirdn_2d
    y = tf.reshape(y, [-1, _shape(x, 1), _shape(y, 1), _shape(y, 2)])
  File "/tensorflow-1.15.2/python3.7/tensorflow_core/python/ops/array_ops.py", line 131, in reshape
    result = gen_array_ops.reshape(tensor, shape, name)
  File "/tensorflow-1.15.2/python3.7/tensorflow_core/python/ops/gen_array_ops.py", line 8115, in reshape
    "Reshape", tensor=tensor, shape=shape, 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()
qo4on commented 2 years ago

Sorry, I should have used the 512 size model co-mod-gan-ffhq-9-025000.pkl for your input images.