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

generated image could be better #8

Open
lonewolfnsp opened this issue Nov 21, 2021 · 1 comment
Open

generated image could be better #8

lonewolfnsp opened this issue Nov 21, 2021 · 1 comment

Comments

@lonewolfnsp
Copy link

I've run through the codes and was able to generate images by running the model. I realize that the images generated were sort of over exposed. I modified the codes to use pytorch's own save_image function, instead of opencv as was used in the codes, and found that I could achieve better results.

using a mean and std of:
mean = np.asarray([ 0.485, 0.456, 0.406 ])
std = np.asarray([ 0.229, 0.224, 0.225 ])
I used this transforms for loading:
transforms.ToTensor(),
transforms.Normalize(mean, std, inplace=True), # normalize image based on mean and std of ImageNet dataset
transforms.Lambda(lambda x: x.mul(255.))

and these transforms for saving:
transforms.Lambda(lambda x: x.div(255.) ),
transforms.Normalize((-1 * mean / std), (1.0 / std),inplace=True)

saving to file uses torch.utils.save_image function which accepts tensor.

couple of thing that puzzles me:

  1. running the training is very fast. 3000 epochs completed within 6+ mins. I could not figure out how you made it so fast. could you please advice me?
    1. loss backward doesn't require retain_graph=True. I independently wrote one myself and it gave error during training, about the graph being freed and calling basckward a second time. I only managed to train it by setting retain_graph to True. Could you please enlighten me why you could reuse the content and style outputs for the respective images, and only generates the outputs for the optimizing_umg and yet don't need to set retain_graph to True?
@sbetzin
Copy link

sbetzin commented Jul 1, 2022

Thank you for this information. I was able to add your comments to this piece of code. (Thanks for your Notebook).

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