UGATIT-pytorch icon indicating copy to clipboard operation
UGATIT-pytorch copied to clipboard

Error during test: local variable 'A2B' referenced before assignment

Open qiuyuchen14 opened this issue 6 years ago • 5 comments

I could successfully train the model on my own dataset, and I can see that the trained models are saved in the model folder already. However, I got the following error when I ran test code "python main.py --dataset experiment1 --phase test --light True". Do you know where might go wrong? Thanks! The error is: ''' [*] Load SUCCESS Traceback (most recent call last): File "main.py", line 83, in main() File "main.py", line 79, in main gan.test() File "/home/zoey/nas/zoey/github/UGATIT-pytorch/UGATIT.py", line 387, in test A2B = np.concatenate((A2B, np.concatenate((RGB2BGR(tensor2numpy(denorm(real_A[0]))), UnboundLocalError: local variable 'A2B' referenced before assignment '''

qiuyuchen14 avatar Aug 08 '19 00:08 qiuyuchen14

Could you please also help me to understand the images generated during the training? For example in the picture below, I got 7 rows of images, I don't understand why my 3rd, 5th, 6th, 7th rows are empty.

Screenshot from 2019-08-07 17-43-49

qiuyuchen14 avatar Aug 08 '19 00:08 qiuyuchen14

As for the first question, you could add

A2B = np.zeros((self.img_size * 7, 0, 3))
B2A = np.zeros((self.img_size * 7, 0, 3)) 

at the begining of test function.

For the second, I think your network is just broke, it is not correctly trained at all.

I suggest a warmup should be added at the beginning of training. For example, I linearly increased the learning rate from 0 to 0.0001 at the first 2000 iterations, which performed well in my task.

Trueyellow avatar Aug 08 '19 01:08 Trueyellow

As for the first question, you could add

A2B = np.zeros((self.img_size * 7, 0, 3))
B2A = np.zeros((self.img_size * 7, 0, 3)) 

at the begining of test function.

As I understand - test function isn't work? Add pr for fix it? or you already fix it, @Trueyellow?

zerezhka avatar Aug 10 '19 11:08 zerezhka

As for the first question, you could add

A2B = np.zeros((self.img_size * 7, 0, 3))
B2A = np.zeros((self.img_size * 7, 0, 3)) 

at the begining of test function.

As I understand - test function isn't work? Add pr for fix it? or you already fix it, @Trueyellow?

Yes, the originial test function doesn't work. In fact, according to my usage, the pytorch version of UGATIT has many differences compared with tensorflow version. If I have time, I would open a PR to fix all those differences(BUGs). If anyone want to training a new model from scratch and reproduce the result like paper, I suggest the tensorflow version.

Trueyellow avatar Aug 11 '19 08:08 Trueyellow

Same question here as what @qiuyuchen14 asked.

w32zhong avatar Aug 11 '19 17:08 w32zhong