alirezatwk / Convolutional-Neural-Network-Based-Image-Watermarking-using-Discrete-Wavelet-Transform

Apache License 2.0
21 stars 2 forks source link

How to solve this error #4

Open 3254657307 opened 1 year ago

3254657307 commented 1 year ago

TypeError: 'NoneType' object cannot be interpreted as an integer

alirezatwk commented 1 year ago

Hi.

Could you please provide us more information about your environment and when this error occurred?

jinzhi666 commented 1 year ago
/home/admin/miniconda3/envs/tf25_py39_admin/lib/python3.9/site-packages/tensorflow/python/keras/backend.py:6112: UserWarning: `tf.keras.backend.random_binomial` is deprecated, and will be removed in a future version.Please use `tf.keras.backend.random_bernoulli` instead.
  warnings.warn('`tf.keras.backend.random_binomial` is deprecated, '
Traceback (most recent call last):
  File "/home/admin/code/Watermarking/DWTMark/trainer.py", line 21, in <module>
    model = WaveTFModel(image_size=IMAGE_SIZE, watermark_size=WATERMARK_SIZE).get_model()
  File "/home/admin/code/Watermarking/DWTMark/models/wavetf_model.py", line 111, in get_model
    attack_layer = self.attack_simulator(wavelet_inverse_watermarked_image, attack_id_layer)
  File "/home/admin/code/Watermarking/DWTMark/models/wavetf_model.py", line 76, in attack_simulator
    condition = Lambda(lambda x: tf.switch_case(
  File "/home/admin/miniconda3/envs/tf25_py39_admin/lib/python3.9/site-packages/tensorflow/python/keras/engine/base_layer.py", line 969, in __call__
    return self._functional_construction_call(inputs, args, kwargs,
  File "/home/admin/miniconda3/envs/tf25_py39_admin/lib/python3.9/site-packages/tensorflow/python/keras/engine/base_layer.py", line 1107, in _functional_construction_call
    outputs = self._keras_tensor_symbolic_call(
  File "/home/admin/miniconda3/envs/tf25_py39_admin/lib/python3.9/site-packages/tensorflow/python/keras/engine/base_layer.py", line 840, in _keras_tensor_symbolic_call
    return self._infer_output_signature(inputs, args, kwargs, input_masks)
  File "/home/admin/miniconda3/envs/tf25_py39_admin/lib/python3.9/site-packages/tensorflow/python/keras/engine/base_layer.py", line 880, in _infer_output_signature
    outputs = call_fn(inputs, *args, **kwargs)
  File "/home/admin/miniconda3/envs/tf25_py39_admin/lib/python3.9/site-packages/tensorflow/python/keras/layers/core.py", line 919, in call
    result = self.function(inputs, **kwargs)
  File "/home/admin/code/Watermarking/DWTMark/models/wavetf_model.py", line 76, in <lambda>
    condition = Lambda(lambda x: tf.switch_case(
  File "/home/admin/miniconda3/envs/tf25_py39_admin/lib/python3.9/site-packages/tensorflow/python/ops/control_flow_ops.py", line 3653, in switch_case
    return _indexed_case_helper(branch_fns, default, branch_index, name)
  File "/home/admin/miniconda3/envs/tf25_py39_admin/lib/python3.9/site-packages/tensorflow/python/ops/control_flow_ops.py", line 3360, in _indexed_case_helper
    return cond_v2.indexed_case(
  File "/home/admin/miniconda3/envs/tf25_py39_admin/lib/python3.9/site-packages/tensorflow/python/ops/cond_v2.py", line 1005, in indexed_case
    func_graph_module.func_graph_from_py_func(
  File "/home/admin/miniconda3/envs/tf25_py39_admin/lib/python3.9/site-packages/tensorflow/python/framework/func_graph.py", line 999, in func_graph_from_py_func
    func_outputs = python_func(*func_args, **func_kwargs)
  File "/home/admin/code/Watermarking/DWTMark/models/wavetf_model.py", line 82, in <lambda>
    3: lambda: jpeg_function(x[1]),
  File "/home/admin/code/Watermarking/DWTMark/attacks/jpeg_attack.py", line 25, in jpeg_function
    return JPEGAttack()(x)
  File "/home/admin/miniconda3/envs/tf25_py39_admin/lib/python3.9/site-packages/tensorflow/python/keras/engine/base_layer.py", line 1030, in __call__
    outputs = call_fn(inputs, *args, **kwargs)
  File "/home/admin/miniconda3/envs/tf25_py39_admin/lib/python3.9/site-packages/tensorflow/python/autograph/impl/api.py", line 695, in wrapper
    raise e.ag_error_metadata.to_exception(e)
TypeError: in user code:

    /home/admin/code/Watermarking/DWTMark/attacks/jpeg_attack.py:20 call  *
        outputs = Lambda(lambda x: self.jpeg(x), output_shape=(10, 256, 256, 1))(inputs)
    /home/admin/code/Watermarking/DWTMark/attacks/jpeg_attack.py:15 jpeg  *
        for i in range(batch):
    /home/admin/miniconda3/envs/tf25_py39_admin/lib/python3.9/site-packages/tensorflow/python/autograph/operators/py_builtins.py:365 range_  **
        return _py_range(start_or_stop, stop, step)
    /home/admin/miniconda3/envs/tf25_py39_admin/lib/python3.9/site-packages/tensorflow/python/autograph/operators/py_builtins.py:390 _py_range
        return range(start_or_stop)

    TypeError: 'NoneType' object cannot be interpreted as an integer

tensorflow2.5.0 CUDA11.2 python3.9 cudnn8.1

3254657307 commented 1 year ago

I have the same problem, did you solve it, how did you solve it, thanks

jinzhi666 commented 1 year ago

I have the same problem, did you solve it, how did you solve it, thanks

Hello, can you give your contact information? We can communicate together.

3254657307 commented 1 year ago

你好,我的名字就是我的QQ号码,欢迎联系

Gnnoy commented 10 months ago

请问你解决这个问题了吗

1chuanchuan commented 4 months ago

我有同样的问题,你解决了吗,你是怎么解决的,谢谢

您好,您能提供您的联系方式吗?我们可以一起交流。

Hello, I also encountered this problem, would you please solve it?