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

Bug In "Art Generation with Neural Style Transfer" #2

Open
niunuinui opened this issue Feb 21, 2020 · 1 comment
Open

Bug In "Art Generation with Neural Style Transfer" #2

niunuinui opened this issue Feb 21, 2020 · 1 comment

Comments

@niunuinui
Copy link

Hi, I learn a lot from your code! Thanks a lot!

I think there is a bug in the save_image function of Art Generation with Neural Style Transfer code. Since .detach() share the same memory, we should clone the input image first or the change will apply to the original image and mess the training.

Bellow is the fixed code for save_image

def save_image(path, imageO):
    # Un-normalize the image so that it looks good
    image=imageO.clone().detach()
    image = image.cpu().numpy().transpose(0, 2, 3, 1)
    image += CONFIG.MEANS
    image = np.clip(image[0], 0, 255).astype('uint8')

@r1ght0us
Copy link

Hi, I learn a lot from your code! Thanks a lot!

I think there is a bug in the save_image function of Art Generation with Neural Style Transfer code. Since .detach() share the same memory, we should clone the input image first or the change will apply to the original image and mess the training.

Bellow is the fixed code for save_image

def save_image(path, imageO):
    # Un-normalize the image so that it looks good
    image=imageO.clone().detach()
    image = image.cpu().numpy().transpose(0, 2, 3, 1)
    image += CONFIG.MEANS
    image = np.clip(image[0], 0, 255).astype('uint8')

牛逼好兄弟,终于找到原因了!!!!

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