langmanbusi / Semantic-Aware-Low-Light-Image-Enhancement

Semantic-Aware LLIE. CVPR 2023
MIT License
189 stars 7 forks source link

seg_fea None for test_unpaired.py #18

Closed ShenZheng2000 closed 7 months ago

ShenZheng2000 commented 7 months ago

I am running:

python test_unpaired.py --opt LOL-L-SKF.yml

But got the following error:

OrderedDict([('manual_seed', 10), ('lr_G', 0.0005), ('weight_decay_G', 0), ('beta1', 0.9), ('beta2', 0.99), ('lr_scheme', 'MultiStepLR'), ('warmup_iter', 200), ('lr_steps_rel', [0.5, 0.75, 0.9, 0.95]), ('lr_gamma', 0.5), ('weight_l1', 0), ('weight_fl', 1), ('niter', 30000), ('val_freq', 200), ('lr_steps', [15000, 22500, 27000, 28500])])
Load ckpt from: ../ckpt/LOL-LLFlow-SKF/LOL_LLFlow_L_SKF.pth
0it [00:02, ?it/s]
Traceback (most recent call last):
  File "test_unpaired.py", line 160, in <module>
    main()
  File "test_unpaired.py", line 141, in main
    sr_t = model.get_sr(lq=lr_t.cuda(), heat=None)
  File "/longdata/anurag_storage/2PCNet/LLIE/Model/SKF/LLFlow_SKF/code/models/LLFlow_model.py", line 354, in get_sr
    return self.get_sr_with_z(lq, heat, seed, z, epses, seg_map, seg_ft)[0]
  File "/longdata/anurag_storage/2PCNet/LLIE/Model/SKF/LLFlow_SKF/code/models/LLFlow_model.py", line 377, in get_sr_with_z
    sr, logdet = self.netG(lr=lq, z=z, eps_std=heat, reverse=True, epses=epses, seg_map=seg_map, seg_fea=seg_fea)
  File "/home/aghosh/anaconda3/envs/2pcnetnew/lib/python3.8/site-packages/torch/nn/modules/module.py", line 1194, in _call_impl
    return forward_call(*input, **kwargs)
  File "/home/aghosh/anaconda3/envs/2pcnetnew/lib/python3.8/site-packages/torch/amp/autocast_mode.py", line 14, in decorate_autocast
    return func(*args, **kwargs)
  File "/longdata/anurag_storage/2PCNet/LLIE/Model/SKF/LLFlow_SKF/code/models/modules/LLFlow_pc_small_arch.py", line 138, in forward
    return self.reverse_flow(lr, z, y_onehot=y_label, eps_std=eps_std, epses=epses, lr_enc=lr_enc,
  File "/longdata/anurag_storage/2PCNet/LLIE/Model/SKF/LLFlow_SKF/code/models/modules/LLFlow_pc_small_arch.py", line 264, in reverse_flow
    lr_enc = self.rrdbPreprocessing(lr, seg_map, seg_fea)
  File "/longdata/anurag_storage/2PCNet/LLIE/Model/SKF/LLFlow_SKF/code/models/modules/LLFlow_pc_small_arch.py", line 236, in rrdbPreprocessing
    rrdbResults[k] = self.att_block_2(concat_1, seg_fea[1])
TypeError: 'NoneType' object is not subscriptable

While investigating the code, I noticed that the problem is that seg_feat is not being passed here. Consequently, when we proceed to the model, seg_feat is always None, which ultimately leads to the error mentioned above

Could you please address this issue?

langmanbusi commented 7 months ago

I didn't modify the test_unpaired.py file. You can refer to the readme file and use test.py to process the images. As for your error, you can see that

File "test_unpaired.py", line 141, in main
    sr_t = model.get_sr(lq=lr_t.cuda(), heat=None)

here, the model didn't receive the semantic map and features, thus in the forward function of the LLFlow_model, shown as:

File "/longdata/anurag_storage/2PCNet/LLIE/Model/SKF/LLFlow_SKF/code/models/LLFlow_model.py", line 354, in get_sr
    return self.get_sr_with_z(lq, heat, seed, z, epses, seg_map, seg_ft)[0] 

the features and maps are NoneType. And in the test.py file, we produce the features and map as follows:

with torch.cuda.amp.autocast():
    if opt['seg']:
        seg_map, seg_ft = seg_model(lr_t[:, 0:3, :, :].cuda())
    else:
        seg_map, seg_ft = None, None
    sr_t = model.get_sr(lq=lr_t.cuda(), heat=None, seg_map=seg_map, seg_ft=seg_ft)

You can see the differences between this model.get_sr() and which in the test_unpaired.py file.

Hope the reply can solve your problem. Have a good day!

langmanbusi commented 7 months ago

If you want to test you own data without GT, you can just set the GT path the same as the input path in the test.py file.