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

How can I train this model on different images ? #69

Open
purushottam22 opened this issue Oct 22, 2021 · 1 comment
Open

How can I train this model on different images ? #69

purushottam22 opened this issue Oct 22, 2021 · 1 comment

Comments

@purushottam22
Copy link

  • Windows 10.

Description

I tried to run this model on different images (like leena). I get segmentation fault.

I want to train this model on different images.

@kompowiec
Copy link

kompowiec commented Nov 4, 2024

you have in tutorial... example code (make sure add "default" folder inside).

# Imports
import numpy as np
from steganogan import SteganoGAN
from steganogan.loader import DataLoader
from steganogan.encoders import BasicEncoder, DenseEncoder
from steganogan.decoders import BasicDecoder, DenseDecoder
from steganogan.critics import BasicCritic

# Load Data
train = DataLoader('/home/$USER/wallpapers', limit=np.inf, shuffle=True, batch_size=3)
validation = DataLoader('/home/$USER/wallpapers', limit=np.inf, shuffle=True, batch_size=3)


# Create SteganoGAN Instance
steganogan = SteganoGAN(
    data_depth=1,                   # Number of layers for representing data
    encoder=BasicEncoder,           # Choose between BasicEncoder or DenseEncoder
    decoder=BasicDecoder,           # Choose between BasicDecoder or DenseDecoder
    critic=BasicCritic,             # BasicCritic is used here
    hidden_size=32,                 # Number of channels for hidden layers
    cuda=True,                      # Enable CUDA if available
    verbose=True                    # Print training info to console
)

# Train and Save the Model
steganogan.fit(train, validation, epochs=99)
steganogan.save('demo.steg')  # Save model as 'demo.steg'

# Load the Model
# If you have a saved model and want to load it:
steganogan = SteganoGAN.load(architecture='basic', path='demo.steg', cuda=True, verbose=True)

# Encoding
input_image = 'input.png'
output_image = 'output.png'
secret_message = 'This is a super secret message!'
steganogan.encode(input_image, output_image, secret_message)
print("Encoding completed.")

# Decoding
decoded_message = steganogan.decode(output_image)
print("Decoded message:", decoded_message)

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