junyanz / pytorch-CycleGAN-and-pix2pix

Image-to-Image Translation in PyTorch
Other
23.07k stars 6.31k forks source link

How to eliminate strange border effect in the CycleGAN output image #1520

Open spinoza1791 opened 1 year ago

spinoza1791 commented 1 year ago

Need tips/advice on how best to reduce the unwanted border effects from CycleGAN. See output image examples: epoch200_fake_B epoch197_fake_B

Training command: python train.py --dataroot /cyclegan-catdog_imp2_512-data/catdog_imp2_512 --name catdog_imp2_512 --model cycle_gan --netG resnet_9blocks --display_id -1 --batch_size 16 --gpu_ids 0,1,2,3 --load_size 512 --crop_size 512 --n_epochs 150 --n_epochs_decay 150 --init_type xavier --norm instance

taesungp commented 1 year ago

How many images did you use in the dataset? This dataset may be a challenging one because the animal faces are not aligned.

junyanz commented 1 year ago

Maybe you could use some data augmentation. Currently, both your load_size and crop_size are 512. Maybe use load_size 580 and crop_size 512. Certain artifacts will go away if the model is trained long enough.

spinoza1791 commented 1 year ago

Maybe you could use some data augmentation. Currently, both your load_size and crop_size are 512. Maybe use load_size 580 and crop_size 512. Certain artifacts will go away if the model is trained long enough.

Images are all 512x512, so would I still benefit from load_size 580? I trained out 400 epochs with same issue.

spinoza1791 commented 1 year ago

How many images did you use in the dataset? This dataset may be a challenging one because the animal faces are not aligned.

TrainA - 1300 (photos of cats and dogs), TrainB - 500 (stylistic paint brush background). Would you please elaborate on the alignment of the faces and how to improve the data? Should I be avoiding style transfer with CycleGAN, and try for object transfiguration goals instead?

spinoza1791 commented 1 year ago

Found the solution here: https://github.com/junyanz/pytorch-CycleGAN-and-pix2pix/issues/782#issuecomment-538537477

Changing from instance to batch norm solves this specific border issue. The style transfer is less dramatic with batch norm apparently, but I will try to remedy this by tweaking other parameters.

Wenting-Xu commented 1 year ago

Found the solution here: #782 (comment)

Changing from instance to batch norm solves this specific border issue. The style transfer is less dramatic with batch norm apparently, but I will try to remedy this by tweaking other parameters.

I had a similar problem. Have you found any other solutions?