mahmoudnafifi / HistoGAN

Reference code for the paper HistoGAN: Controlling Colors of GAN-Generated and Real Images via Color Histograms (CVPR 2021).
MIT License
267 stars 27 forks source link

Can't do correct upsampling #15

Closed Alexasandrovich closed 2 years ago

Alexasandrovich commented 2 years ago

Hi! Unable to do correct upsampling in rehistoGAN.py on my dataset. That is, if you take the standard 256x256 network output, the colours change normally. But if you add --upsampling_output option, the picture becomes faded, i.e. it gets predominantly white. I changed the dimensionality to be a multiple of two, but it didn't help either.

Running it like this: python rehistoGAN.py --name Universal_rehistoGAN_v0 --generate True --input_image my_inp_img.png --target_hist my_goal_img.png --gpu 0 --network_capacity 18 -upsampling_output True

What could be the problem? Thanks in advance for the answer

P.S. The pictures show a person, some buildings, trees and bushes, i.e. the image was taken inside the city

mahmoudnafifi commented 2 years ago

Could you please post the image before and after to have a better understanding of the issue you’ve faced?

Alexasandrovich commented 2 years ago

Could you please post the image before and after to have a better understanding of the issue you’ve faced?

https://drive.google.com/folderview?id=1vIvQW93ddpLwnYeRMDKKsAJYxl3iewFG

Generated pictures with --upsampling_output (predominantly white color) and without

mahmoudnafifi commented 2 years ago

Interesting! Probably the bug is that the reference image in the upsampling is in 0-255 range? Since you have the setup of HistoGAN in your device, do you mind checking the value of reference image after this line? It should be a in the 0-1 range.

Sorry that i cannot check it myself because I don’t have the setup of HistoGAN environment installed in my side at this moment.

Thanks!

mahmoudnafifi commented 2 years ago

Please post here if you find the reason of the issue. Thanks!

Alexasandrovich commented 2 years ago

Please post here if you find the reason of the issue. Thanks!

In method pyramid_upsampling variable "target" is in range [0, 255], but reference is in range [0, 1]. I fix it as "target = torch.squeeze(target, dim=0).cpu().detach().numpy() / 255" in the same method