pytorch-CycleGAN-and-pix2pix icon indicating copy to clipboard operation
pytorch-CycleGAN-and-pix2pix copied to clipboard

--phase train: AttributeError: 'CycleGANModel' object has no attribute 'real_A'

Open MasterHM-ml opened this issue 3 years ago • 1 comments

Hello! I am training cycle_gan with dataset_mode equal to unaligned. My environment is: Python -> 3.8.10 torch -> 1.8.1+cu102 OS -> Linux Mint 20.2 Cinnamon

I had passed parameter --phase train however I am facing an error AttributeError: 'CycleGANModel' object has no attribute 'real_A' .

Complete stacktrace was

Traceback (most recent call last): File "train.py", line 43, in model.optimize_parameters() File "/home/aim-beast/Desktop/hamza/venv/pix2pix/models/cycle_gan_model.py", line 184, in optimize_parameters self.forward() # compute fake images and reconstruction images. File "/home/aim-beast/Desktop/hamza/venv/pix2pix/models/cycle_gan_model.py", line 115, in forward self.fake_B = self.netG_A(self.real_A) # G_A(A) AttributeError: 'CycleGANModel' object has no attribute 'real_A'

and I tracked file. I see in train.py file, line 43 function model.optimized_parameters() is called before call of model.set_input(). While model.set_input() initializes self.real_A and model.optimized_parameters() uses self.real_A.

Am I making a mistake or it's a bug?

MasterHM-ml avatar Mar 15 '22 13:03 MasterHM-ml

model.set_input() is called first in the training script https://github.com/junyanz/pytorch-CycleGAN-and-pix2pix/blob/003efc4c8819de47ff11b5a0af7ba09aee7f5fc1/train.py#L51-L52 Maybe you swapped them by accident?

AlexWilkinsonnn avatar Mar 18 '22 11:03 AlexWilkinsonnn

maybe. Thanks for update. Looking back at it after 1+ year.

MasterHM-ml avatar Jun 17 '23 08:06 MasterHM-ml