stargan-v2
stargan-v2 copied to clipboard
UnBoundLocalError
Similar to issue #11
After train, eval error happens when use 4 domains dataset.
Should I adjust lambda_ds for #domains-1, or adjust other variable to fit with # of domains?
python main.py --mode train --num_domains 4 --w_hpf 0 \
--lambda_reg 1 --lambda_sty 1 --lambda_ds 1 --lambda_cyc 1 \
--train_img_dir data/custom/train \
--val_img_dir data/custom/val
Calculating evaluation metrics...
Number of domains: 4
Preparing DataLoader for the evaluation phase...
Traceback (most recent call last):
File "main.py", line 182, in <module>
main(args)
File "main.py", line 59, in main
solver.train(loaders)
File "/home/ipsych/ML/Stargan_v2/core/solver.py", line 170, in train
calculate_metrics(nets_ema, args, i+1, mode='latent')
File "/home/ipsych/.conda/envs/Pytorch_1_4_0/lib/python3.7/site-packages/torch/autograd/grad_mode.py", line 49, in decorate_no_grad
return func(*args, **kwargs)
File "/home/ipsych/ML/Stargan_v2/metrics/eval.py", line 61, in calculate_metrics
iter_ref = iter(loader_ref)
UnboundLocalError: local variable 'loader_ref' referenced before assignment
@iPsych Please use the updated code. This commit should resolve the error.
@yunjey I try This commit and it fixed "StopIterationError" but not fix "UnboundLocalError" , as my test
@yunjey @Johnson-yue I am experiencing same issue related to loader_ref.
@iPsych I know that ,and I have same issue, maybe it was caused by different num_domains
@yunjey Hi, Does number of domains, or number of images for eval (currently very smaller than train images) can cause the problem?
Mistakenly put the stopiteration error in here.
@iPsych This is StopIteration Error not UnBoundLocalError and StopIteration Error was fixed in This commit I have checked . So maybe you upload false log ???
@Johnson-yue My bad.. The UnBoundLocalError disappeared, but StopIteration happens even with latest commit and latest sources.
@Johnson-yue, @yunjey I again face with the UnBoundLocalError with latest code. I patched eval.py with https://github.com/clovaai/stargan-v2/pull/9 but still face below errors.
3781] G/ref_sty: [0.1911] G/ref_ds: [0.6815] G/ref_cyc: [0.2138] G/lambda_ds: [1.8000]
Saving checkpoint into expr/checkpoints/050000_nets.ckpt...
Saving checkpoint into expr/checkpoints/050000_nets_ema.ckpt...
Saving checkpoint into expr/checkpoints/050000_optims.ckpt...
Calculating evaluation metrics...
Number of domains: 3
Preparing DataLoader for the evaluation phase...
Traceback (most recent call last):
File "main.py", line 182, in <module>
main(args)
File "main.py", line 59, in main
solver.train(loaders)
File "/home/ipsych/ML/stargan-v2/core/solver.py", line 170, in train
calculate_metrics(nets_ema, args, i+1, mode='latent')
File "/home/ipsych/.conda/envs/Pytorch_1_4_0/lib/python3.7/site-packages/torch/autograd/grad_mode.py", line 49, in decorate_no_grad
return func(*args, **kwargs)
File "/home/ipsych/ML/stargan-v2/metrics/eval.py", line 61, in calculate_metrics
iter_ref = iter(loader_ref)
UnboundLocalError: local variable 'loader_ref' referenced before assignment
i also have this error and use the lattest version of eval.py. how to solve it ?
@yunjey that commit doesn't solve it
setting --val_batch_size=1 solves the issue.