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

i can't encode. #96

Open
kompowiec opened this issue Nov 6, 2024 · 2 comments
Open

i can't encode. #96

kompowiec opened this issue Nov 6, 2024 · 2 comments

Comments

@kompowiec
Copy link

  • SteganoGAN version or git commit:
  • Python version (output of python --version): Python 3.12.7
  • Pip version (output of pip --version): pip 24.3.1 from /usr/lib/python3.12/site-packages/pip (python 3.12)
  • PyTorch version (output of python -c "import torch; print(torch.__version__)"): 2.3.1
  • Operating System: ArcoLinux (Arch linux)

Description

steganogan encode -v in.png "Hello world" -o out.png

/home/kompowiec2/myenv/lib/python3.12/site-packages/torch/serialization.py:1113: SourceChangeWarning: source code of class 'torch.nn.modules.container.Sequential' has changed. you can retrieve the original source code by accessing the object's source attribute or set torch.nn.Module.dump_patches = True and use the patch tool to revert the changes.
warnings.warn(msg, SourceChangeWarning)
/home/kompowiec2/myenv/lib/python3.12/site-packages/torch/serialization.py:1113: SourceChangeWarning: source code of class 'torch.nn.modules.conv.Conv2d' has changed. you can retrieve the original source code by accessing the object's source attribute or set torch.nn.Module.dump_patches = True and use the patch tool to revert the changes.
warnings.warn(msg, SourceChangeWarning)
/home/kompowiec2/myenv/lib/python3.12/site-packages/torch/serialization.py:1113: SourceChangeWarning: source code of class 'torch.nn.modules.activation.LeakyReLU' has changed. you can retrieve the original source code by accessing the object's source attribute or set torch.nn.Module.dump_patches = True and use the patch tool to revert the changes.
warnings.warn(msg, SourceChangeWarning)
/home/kompowiec2/myenv/lib/python3.12/site-packages/torch/serialization.py:1113: SourceChangeWarning: source code of class 'torch.nn.modules.batchnorm.BatchNorm2d' has changed. you can retrieve the original source code by accessing the object's source attribute or set torch.nn.Module.dump_patches = True and use the patch tool to revert the changes.
warnings.warn(msg, SourceChangeWarning)
/home/kompowiec2/myenv/lib/python3.12/site-packages/torch/serialization.py:1113: SourceChangeWarning: source code of class 'steganogan.decoders.DenseDecoder' has changed. you can retrieve the original source code by accessing the object's source attribute or set torch.nn.Module.dump_patches = True and use the patch tool to revert the changes.
warnings.warn(msg, SourceChangeWarning)
/home/kompowiec2/myenv/lib/python3.12/site-packages/torch/serialization.py:1113: SourceChangeWarning: source code of class 'steganogan.critics.BasicCritic' has changed. you can retrieve the original source code by accessing the object's source attribute or set torch.nn.Module.dump_patches = True and use the patch tool to revert the changes.
warnings.warn(msg, SourceChangeWarning)
Traceback (most recent call last):
File "/home/kompowiec2/myenv/bin/steganogan", line 8, in
sys.exit(main())
^^^^^^
File "/home/kompowiec2/myenv/lib/python3.12/site-packages/steganogan/cli.py", line 88, in main
args.action(args)
File "/home/kompowiec2/myenv/lib/python3.12/site-packages/steganogan/cli.py", line 25, in _encode
steganogan = _get_steganogan(args)
^^^^^^^^^^^^^^^^^^^^^
File "/home/kompowiec2/myenv/lib/python3.12/site-packages/steganogan/cli.py", line 20, in _get_steganogan
return SteganoGAN.load(**steganogan_kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/kompowiec2/myenv/lib/python3.12/site-packages/steganogan/models.py", line 364, in load
steganogan = torch.load(path, map_location='cpu', weights_only=False)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/kompowiec2/myenv/lib/python3.12/site-packages/torch/serialization.py", line 1040, in load
return _legacy_load(opened_file, map_location, pickle_module, **pickle_load_args)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/kompowiec2/myenv/lib/python3.12/site-packages/torch/serialization.py", line 1272, in _legacy_load
result = unpickler.load()
^^^^^^^^^^^^^^^^
File "/home/kompowiec2/myenv/lib/python3.12/site-packages/torch/optim/adam.py", line 66, in setstate
super().setstate(state)
File "/home/kompowiec2/myenv/lib/python3.12/site-packages/torch/optim/optimizer.py", line 313, in setstate
self.defaults.setdefault('differentiable', False)
^^^^^^^^^^^^^
AttributeError: 'Adam' object has no attribute 'defaults'

What I Did

i modify steganogan/models.py:

steganogan = torch.load(path, map_location='cpu', weights_only=False)

ERROR: Could not find a version that satisfies the requirement torch==1.8.1 (from versions: 2.2.0, 2.2.1, 2.2.2, 2.3.0, 2.3.1, 2.4.0, 2.4.1, 2.5.0, 2.5.1)

[notice] A new release of pip is available: 24.2 -> 24.3.1
[notice] To update, run: pip install --upgrade pip
ERROR: No matching distribution found for torch==1.8.1

  1. Traceback (most recent call last):
    File "/home/kompowiec2/myenv/bin/steganogan", line 8, in
    sys.exit(main())
    ^^^^^^
    File "/home/kompowiec2/myenv/lib/python3.12/site-packages/steganogan/cli.py", line 88, in main
    args.action(args)
    File "/home/kompowiec2/myenv/lib/python3.12/site-packages/steganogan/cli.py", line 25, in _encode
    steganogan = _get_steganogan(args)
    ^^^^^^^^^^^^^^^^^^^^^
    File "/home/kompowiec2/myenv/lib/python3.12/site-packages/steganogan/cli.py", line 20, in _get_steganogan
    return SteganoGAN.load(**steganogan_kwargs)
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    File "/home/kompowiec2/myenv/lib/python3.12/site-packages/steganogan/models.py", line 364, in load
    steganogan = torch.load(path, map_location='cpu', weights_only=True)
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    File "/home/kompowiec2/myenv/lib/python3.12/site-packages/torch/serialization.py", line 1383, in load
    raise pickle.UnpicklingError(_get_wo_message(str(e))) from None
    _pickle.UnpicklingError: Weights only load failed. This file can still be loaded, to do so you have two options, do those steps only if you trust the source of the checkpoint.
    (1) Re-running torch.load with weights_only set to False will likely succeed, but it can result in arbitrary code execution. Do it only if you got the file from a trusted source.
    (2) Alternatively, to load with weights_only=True please check the recommended steps in the following error message.
    WeightsUnpickler error: Unsupported global: GLOBAL steganogan.models.SteganoGAN was not an allowed global by default. Please use torch.serialization.add_safe_globals([SteganoGAN]) to allowlist this global if you trust this class/function.

I don't know what else I can do. Model training works for me.

@bbtx2024
Copy link

bbtx2024 commented Nov 9, 2024

i ask gpt how to deal with it.
gpt told me to use docker
and i create a docker with python3.6 and encode successful.
now i cant decode
image

@kompowiec
Copy link
Author

kompowiec commented Nov 9, 2024

I also used chatgpt but they just suggested weights_only=False)

and i create a docker with python3.6 and encode successful.

now it's makes sense. I had no idea what version of python it required. As for torch, I'll probably have to manually download it from another source.

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