yunjey / stargan

StarGAN - Official PyTorch Implementation (CVPR 2018)
MIT License
5.23k stars 970 forks source link

test pre-trained models(256x256), result is not right, what's wrong? #102

Open pxEkin opened 5 years ago

pxEkin commented 5 years ago

code is: model = Generator() model = model.cuda() model.load_state_dict(torch.load("./stargan_celeba_256/models/200000-G.ckpt")) model = model.eval()

pilImg = Image.open("256x256.jpg") npImg = np.array(pilImg) example_img = torch.from_numpy(npImg).float().unsqueeze(0) print(example_img.shape) example_img = example_img.permute(0, 3, 1, 2) print(example_img.shape) print("======RGB data [0, 255]======") print(example_img) example_img = example_img.div(255) example_img = example_img.sub(0.5) example_img = example_img.div(0.5) example_img = example_img.cuda()

example_c = torch.cuda.FloatTensor([[0,0,1,0,0]])

imgGen = model(example_img, example_c) save_image(imgGen, "./%s.png" % 100, normalize=True)

result is: 100

rex-yue-wu commented 5 years ago

you need to denormalize the image. Check solver.denorm()

raikuma commented 4 years ago

Disable this line.

model = model.eval()

It works for me.

ujjawalcse commented 4 years ago

Have you resolved the issue @ToBigboss by using these two methods given by @rex-yue-wu and @raikuma ? I tested the solver.denorm with the line 'model.eval()' commented but result didn't improve.

07hyx06 commented 4 years ago

Disable this line.

model = model.eval()

It works for me.

Hi! What about your generated image quality?I got very ugly outputs when i loaded pretrained model 200000-G

tmp6ah556n2_wps图片

despoisj commented 4 years ago

Has someone investigated this .eval() issue. Is it an issue with the InstanceNorm2D layer?