stylegan2-pytorch
stylegan2-pytorch copied to clipboard
The pre-trained sytleGAN2 discriminator can not discriminate fake and real images
Hi, I want to use the pre-trained styleGAN2 discriminator as the supervision for training another image generation network. However, the pre-trained discriminator always outputs negative scores ( denotes fake images) whenever real or fake images are fed. Is it normal in GAN? Or is there a mistake in my usage? Here are my codes.
def fit_to_stylegan_range(x):
return 2 * x - 1 # Scale from range (0, 1) to range (-1, 1)
for path in files:
name = os.path.basename(path)
image = torch.from_numpy(np.asarray(Image.open(os.path.join(path)))) / 255.0
image = image.unsqueeze(0).permute(0, 3, 1, 2)
image = torch.nn.functional.interpolate(image, size=(512,512), mode="bicubic")
min_i = image.min()
max_i = image.max()
image = (image - min_i) / (max_i - min_i)
print("image min:{}, max:{} ".format(image.min().item(), image.max().item()))
image = fit_to_stylegan_range(image)
d_fake = discriminator(image)
prob_fake = F.softplus(d_fake)
print("{} discriminator: {}({})".format(name, prob_fake.item(), d_fake.item()))
@chobao Hi! I know your question was long time ago, but I am facing the same issue. Were you able to solve it?