VITA-Group / EnlightenGAN

[IEEE TIP] "EnlightenGAN: Deep Light Enhancement without Paired Supervision" by Yifan Jiang, Xinyu Gong, Ding Liu, Yu Cheng, Chen Fang, Xiaohui Shen, Jianchao Yang, Pan Zhou, Zhangyang Wang
Other
890 stars 198 forks source link

Problems while testing image with CPU #44

Closed kuang22 closed 4 years ago

kuang22 commented 4 years ago

Hello, I'm trying to test the pre-trained model with CPU. First, I put the two vgg16.weight and vgg16.t7 in the directory "model", then I put 200_net_G_A.pth in the checkpoints/enlightening directory and create test_dataset/testA and test_dataset/testB. To test with CPU, I add the option "--gpu_ids -1" in the scripts/script.py to the "python predict.py" options. Then I find there is still the problem of loading gpu which occurs at the if len(gpu_ids) >= 0: netG.cuda(device=gpu_ids[0]) netG = torch.nn.DataParallel(netG, gpu_ids) netG.apply(weights_init) return netG I change the >= into > ( because when gpu_ids -1 then len(gpu_ids)=0 ) then get the unexpected KeyError: 'unexpected key "module.conv1_1.weight" in state_dict' Then I go to the corresponding closed issue for help but meet the problem he met which is left unsoloved, I don't understand why that issue is closed. In a word, I want to test the model with CPU, and obviously I made some mistakes. So hope that you can help me! thx in advance!

wasdyouli commented 4 years ago

你好,我也遇到了相似的错误,RuntimeError: Error(s) in loading state_dict for UnetGenerator: 我搜索到的解决方法是将base_model.py中的network.load_state_dict(torch.load(save_path))改为network.load_state_dict(torch.load(save_path),False)就可以完成模型加载了,希望能帮到你 @yumouse

kuang22 commented 4 years ago

@wasdyouli thanks a lot first~ Could I ask all your modifications based on the latest master branch code to test models with CPU? I'm not sure whether some modifications made before is valid or redundant and whether they would conflict with yours.

wasdyouli commented 4 years ago

@yumouse 抱歉,我也是刚好遇到和你相似的问题,目前还没有完成在CPU上的测试,你可以先尝试我说的方法,根据你之前的描述,模型加载部分应该是可以完成的 .

kuang22 commented 4 years ago

@wasdyouli Ok, thx anyway! I will keep trying.

jinzhenmu commented 4 years ago

@yumouse 请问一下python scripts/script.py --predict或者 python predict.py,是否需要翻墙用外网?

yifanjiang19 commented 4 years ago

@yumouse no need