Skip to content

TypeError: <lambda>() got an unexpected keyword argument 'dtype' #33

@thima2017

Description

@thima2017

I'm trying to run stylize.py on Ubuntu 20.04 with the latest tensorflow (2.3.0) and keras (2.4.3). Tensorflow 1.* isn't available for python 3.8 shipped with Ubuntu 20.04.
I've changed tf.get_default_graph() to tf.compat.v1.get_default_graph() and tf.placeholder_with_default to tf.compat.v1.placeholder_with_default and everything seems worked until this:

Traceback (most recent call last):
  File "stylize.py", line 126, in <module>
    main()
  File "stylize.py", line 46, in main
    wct_model = WCT(checkpoints=args.checkpoints, 
  File "/full/path/WCT-TF2.3/wct.py", line 33, in __init__
    self.model = WCTModel(mode='test', relu_targets=relu_targets, vgg_path=vgg_path,
  File "/full/path/WCT-TF2.3/model.py", line 62, in __init__
    self.vgg_model = vgg_from_t7(vgg_path, target_layer=deepest_target)
  File "/full/path/WCT-TF2.3/vgg_normalised.py", line 35, in vgg_from_t7
    x = Conv2D(filters, kernel_size, padding='valid', activation=None, name=name,
  File "/home/user/.local/lib/python3.8/site-packages/tensorflow/python/keras/engine/base_layer.py", line 925, in __call__
    return self._functional_construction_call(inputs, args, kwargs,
  File "/home/user/.local/lib/python3.8/site-packages/tensorflow/python/keras/engine/base_layer.py", line 1098, in _functional_construction_call
    self._maybe_build(inputs)
  File "/home/user/.local/lib/python3.8/site-packages/tensorflow/python/keras/engine/base_layer.py", line 2643, in _maybe_build
    self.build(input_shapes)  # pylint:disable=not-callable
  File "/home/user/.local/lib/python3.8/site-packages/tensorflow/python/keras/layers/convolutional.py", line 197, in build
    self.kernel = self.add_weight(
  File "/home/user/.local/lib/python3.8/site-packages/tensorflow/python/keras/engine/base_layer.py", line 597, in add_weight
    variable = self._add_variable_with_custom_getter(
  File "/home/user/.local/lib/python3.8/site-packages/tensorflow/python/training/tracking/base.py", line 745, in _add_variable_with_custom_getter
    new_variable = getter(
  File "/home/user/.local/lib/python3.8/site-packages/tensorflow/python/keras/engine/base_layer_utils.py", line 133, in make_variable
    return tf_variables.VariableV1(
  File "/home/user/.local/lib/python3.8/site-packages/tensorflow/python/ops/variables.py", line 260, in __call__
    return cls._variable_v1_call(*args, **kwargs)
  File "/home/user/.local/lib/python3.8/site-packages/tensorflow/python/ops/variables.py", line 206, in _variable_v1_call
    return previous_getter(
  File "/home/user/.local/lib/python3.8/site-packages/tensorflow/python/ops/variables.py", line 199, in <lambda>
    previous_getter = lambda **kwargs: default_variable_creator(None, **kwargs)
  File "/home/user/.local/lib/python3.8/site-packages/tensorflow/python/ops/variable_scope.py", line 2583, in default_variable_creator
    return resource_variable_ops.ResourceVariable(
  File "/home/user/.local/lib/python3.8/site-packages/tensorflow/python/ops/variables.py", line 264, in __call__
    return super(VariableMetaclass, cls).__call__(*args, **kwargs)
  File "/home/user/.local/lib/python3.8/site-packages/tensorflow/python/ops/resource_variable_ops.py", line 1507, in __init__
    self._init_from_args(
  File "/home/user/.local/lib/python3.8/site-packages/tensorflow/python/ops/resource_variable_ops.py", line 1651, in _init_from_args
    initial_value() if init_from_fn else initial_value,
TypeError: <lambda>() got an unexpected keyword argument 'dtype'

Actually this log is after I converted the tree with tf_upgrade_v2. But the log after my manual editing was the same.
A command I used for running stylize.py:

python3 stylize.py --checkpoints models/relu5_1 models/relu4_1 models/relu3_1 models/relu2_1 models/relu1_1 --relu-targets relu5_1 relu4_1 relu3_1 relu2_1 relu1_1 --style-size 512 --alpha 0.8 --content-path imags --style-path styles --out-path output

An image is in imags directory, style image is in styles directory and output directory is empty one.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions