Open Fresh-Orange opened 5 years ago
the same error,have you solved it?
the same error,have you solved it?
Yes, I solved it by modifying the following two lines in perceptual_model.py
self.ref_img_features = tf.get_variable('ref_img_features', shape=generated_img_features.shape,
dtype='float32', initializer=tf.initializers.zeros())
self.features_weight = tf.get_variable('features_weight', shape=generated_img_features.shape,
dtype='float32', initializer=tf.initializers.zeros())
to
in_shape = (1, generated_img_features.shape[1], generated_img_features.shape[2], generated_img_features.shape[3])
self.ref_img_features = tf.get_variable('ref_img_features',
shape=in_shape,
dtype='float32', initializer=tf.initializers.zeros())
self.features_weight = tf.get_variable('features_weight', shape=in_shape,
dtype='float32', initializer=tf.initializers.zeros())
When I run “python3 encode_images.py aligned_images/ generated_images/ latent_representations/”,I get the errer:
Traceback (most recent call last): File "encode_images.py", line 86, in
main()
File "encode_images.py", line 61, in main
perceptual_model.build_perceptual_model(generator.generated_image)
File "/media/data2/laixc/stylegan-encoder/encoder/perceptual_model.py", line 41, in build_perceptual_model
dtype='float32', initializer=tf.initializers.zeros())
File "/usr/local/lib/python3.5/dist-packages/tensorflow/python/ops/variable_scope.py", line 1328, in get_variable
constraint=constraint)
File "/usr/local/lib/python3.5/dist-packages/tensorflow/python/ops/variable_scope.py", line 1090, in get_variable
constraint=constraint)
File "/usr/local/lib/python3.5/dist-packages/tensorflow/python/ops/variable_scope.py", line 435, in get_variable
constraint=constraint)
File "/usr/local/lib/python3.5/dist-packages/tensorflow/python/ops/variable_scope.py", line 404, in _true_getter
use_resource=use_resource, constraint=constraint)
File "/usr/local/lib/python3.5/dist-packages/tensorflow/python/ops/variable_scope.py", line 764, in _get_single_variable
"but instead was %s." % (name, shape))
ValueError: Shape of a new variable (ref_img_features) must be fully defined, but instead was (?, 64, 64, 256).