mit-han-lab / gan-compression

[CVPR 2020] GAN Compression: Efficient Architectures for Interactive Conditional GANs
Other
1.1k stars 148 forks source link

There is a bug in tensor2im #45

Closed Feywell closed 4 years ago

Feywell commented 4 years ago

The normlize is not work, when tensor.dim() == 4.

    if image_tensor.dim() == 4:
        # transform each image in the batch
        images_np = []
        for b in range(image_tensor.size(0)):
            one_image = image_tensor[b]
            one_image_np = tensor2im(one_image)
            images_np.append(one_image_np.reshape(1, *one_image_np.shape))
        images_np = np.concatenate(images_np, axis=0)

https://github.com/mit-han-lab/gan-compression/blob/master/utils/util.py#L69

lmxyy commented 4 years ago

Could you elaborate on this bug or provide some error logs? This code makes sense for me.

Feywell commented 4 years ago

Actually it doesn't return a error. It is not work, when normlize is False. Because I do not use normlize to prepare my own dataset.

lmxyy commented 4 years ago

It doesn't make sense to me, since the normalize flag only affects a linear normalization. What do you mean by "it is not work"? Does your program exit normally?

Feywell commented 4 years ago

If you use normlize=True, this code just ok. But It will go to https://github.com/mit-han-lab/gan-compression/blob/master/utils/util.py#L81 , when I set normlize=False.

So, I change it like follow: one_image_np = tensor2im(one_image, imtype=imtype, normalize=normalize)

lmxyy commented 4 years ago

I see. Thanks for reporting this. You could also send a pull request.