PyTorch-progressive_growing_of_gans icon indicating copy to clipboard operation
PyTorch-progressive_growing_of_gans copied to clipboard

output sample images are incorrectly normalized

Open jcpeterson opened this issue 6 years ago • 6 comments

Some of the sample images looked washed out. I suspect that the min/max pixel values of the real samples versus the generated ones are different. It fluctuates wildly on every output. This makes it hard to verify quality during training most of the time.

jcpeterson avatar Nov 27 '17 22:11 jcpeterson

Here's a quick hack to fix:

half = samples.shape[1] / 2
samples[:,:half,:] = samples[:,:half,:] - np.min(samples[:,:half,:])
samples[:,:half,:] = samples[:,:half,:] / np.max(samples[:,:half,:])
samples[:,half:,:] = samples[:,half:,:] - np.min(samples[:,half:,:])
samples[:,half:,:] = samples[:,half:,:] / np.max(samples[:,half:,:])

jcpeterson avatar Nov 28 '17 03:11 jcpeterson

although I also removed the white spacing

jcpeterson avatar Nov 28 '17 03:11 jcpeterson

Thx.

github-pengge avatar Nov 29 '17 07:11 github-pengge

this doesn't seem to be fully working for some reason. not sure why

jcpeterson avatar Dec 02 '17 07:12 jcpeterson

So do I. Cannot figure out why.

github-pengge avatar Dec 02 '17 12:12 github-pengge

Something like this seems to remove outlier values and fix the problem:

half = samples.shape[1] / 2

sd_fake = np.std(samples[:,:half,:])
m_fake = np.mean(samples[:,:half,:])
margin = m_fake + (sd_fake*4)

samples[np.where(samples[:,:half,:] > margin)] = margin
samples[np.where(samples[:,:half,:] < -margin)] = -margin

jcpeterson avatar Dec 16 '17 21:12 jcpeterson