Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error modifying age of own images #18

Open
shiyingZhang90 opened this issue Apr 26, 2020 · 1 comment
Open

Error modifying age of own images #18

shiyingZhang90 opened this issue Apr 26, 2020 · 1 comment

Comments

@shiyingZhang90
Copy link

This is follow up of issue #3
Hi Robert,

I get exactly the same error at the end of the issue. I'm wondering would you kindly share the solution for that?
Below is my error, thanks so much:

Traceback (most recent call last):
File "edit_photo.py", line 94, in
main()
File "edit_photo.py", line 90, in main
move_latent_and_save(w, direction_file, coeffs, Gs_network, Gs_syn_kwargs)
File "edit_photo.py", line 31, in move_latent_and_save
images = Gs_network.components.synthesis.run(new_latent_vector, **Gs_syn_kwargs)
File "/usr/local/google/home/ellaz/github/generators-with-stylegan2/dnnlib/tflib/network.py", line 442, in run
mb_out = tf.get_default_session().run(out_expr, dict(zip(in_expr, mb_in)))
File "/usr/local/google/home/ellaz/anaconda3/lib/python3.6/site-packages/tensorflow/python/client/session.py", line 950, in run
run_metadata_ptr)
File "/usr/local/google/home/ellaz/anaconda3/lib/python3.6/site-packages/tensorflow/python/client/session.py", line 1173, in _run
feed_dict_tensor, options, run_metadata)
File "/usr/local/google/home/ellaz/anaconda3/lib/python3.6/site-packages/tensorflow/python/client/session.py", line 1350, in _do_run
run_metadata)
File "/usr/local/google/home/ellaz/anaconda3/lib/python3.6/site-packages/tensorflow/python/client/session.py", line 1370, in _do_call
raise type(e)(node_def, op, message)
tensorflow.python.framework.errors_impl.InvalidArgumentError: 2 root error(s) found.
(0) Invalid argument: In[0] is not a matrix. Instead it has shape [1]
[[node G_synthesis_1/_Run/G_synthesis/128x128/Conv1/MatMul (defined at :46) ]]
[[G_synthesis_1/_Run/saturate_cast/_1453]]
(1) Invalid argument: In[0] is not a matrix. Instead it has shape [1]
[[node G_synthesis_1/_Run/G_synthesis/128x128/Conv1/MatMul (defined at :46) ]]
0 successful operations.
0 derived errors ignored.

Errors may have originated from an input operation.
Input Source operations connected to node G_synthesis_1/_Run/G_synthesis/128x128/Conv1/MatMul:
G_synthesis_1/_Run/G_synthesis/128x128/Conv1/strided_slice (defined at :455)
G_synthesis_1/_Run/G_synthesis/128x128/Conv1/mul_1 (defined at :36)

Input Source operations connected to node G_synthesis_1/_Run/G_synthesis/128x128/Conv1/MatMul:
G_synthesis_1/_Run/G_synthesis/128x128/Conv1/strided_slice (defined at :455)
G_synthesis_1/_Run/G_synthesis/128x128/Conv1/mul_1 (defined at :36)

Original stack trace for 'G_synthesis_1/_Run/G_synthesis/128x128/Conv1/MatMul':
File "edit_photo.py", line 94, in
main()
File "edit_photo.py", line 90, in main
move_latent_and_save(w, direction_file, coeffs, Gs_network, Gs_syn_kwargs)
File "edit_photo.py", line 31, in move_latent_and_save
images = Gs_network.components.synthesis.run(new_latent_vector, **Gs_syn_kwargs)
File "/usr/local/google/home/ellaz/github/generators-with-stylegan2/dnnlib/tflib/network.py", line 417, in run
out_gpu = net_gpu.get_output_for(*in_gpu, return_as_list=True, **dynamic_kwargs)
File "/usr/local/google/home/ellaz/github/generators-with-stylegan2/dnnlib/tflib/network.py", line 221, in get_output_for
out_expr = self._build_func(*final_inputs, **build_kwargs)
File "", line 498, in G_synthesis_stylegan2
File "", line 470, in block
File "", line 455, in layer
File "", line 98, in modulated_conv2d_layer
File "", line 46, in dense_layer
File "/usr/local/google/home/ellaz/anaconda3/lib/python3.6/site-packages/tensorflow/python/util/dispatch.py", line 180, in wrapper
return target(*args, **kwargs)
File "/usr/local/google/home/ellaz/anaconda3/lib/python3.6/site-packages/tensorflow/python/ops/math_ops.py", line 2647, in matmul
a, b, transpose_a=transpose_a, transpose_b=transpose_b, name=name)
File "/usr/local/google/home/ellaz/anaconda3/lib/python3.6/site-packages/tensorflow/python/ops/gen_math_ops.py", line 5925, in mat_mul
name=name)
File "/usr/local/google/home/ellaz/anaconda3/lib/python3.6/site-packages/tensorflow/python/framework/op_def_library.py", line 788, in _apply_op_helper
op_def=op_def)
File "/usr/local/google/home/ellaz/anaconda3/lib/python3.6/site-packages/tensorflow/python/util/deprecation.py", line 507, in new_func
return func(*args, **kwargs)
File "/usr/local/google/home/ellaz/anaconda3/lib/python3.6/site-packages/tensorflow/python/framework/ops.py", line 3616, in create_op
op_def=op_def)
File "/usr/local/google/home/ellaz/anaconda3/lib/python3.6/site-packages/tensorflow/python/framework/ops.py", line 2005, in init
self._traceback = tf_stack.extract_stack()

@Vis5
Copy link

Vis5 commented Apr 29, 2020

I had the same error and I fixed it by putting the following code after loading with numpy.
w = w[np.newaxis, ...]
Unfortunately my results are not great. My custom image turns black :(

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants