CycleGan训练报错总结:There is no latest_net_G.pth in the program-generated model
1,All errors are reported as follows:
Traceback (most recent call last):
File “C:/Users/Administrator/Desktop/pytorch-CycleGAN-and-pix2pix-master/test.py”, line 52, in
model.setup(opt) # regular setup: load and print networks; create schedulers
File “C:\Users\Administrator\Desktop\pytorch-CycleGAN-and-pix2pix-master\models\base_model.py”, line 88, in setup
self.load_networks(load_suffix)
File “C:\Users\Administrator\Desktop\pytorch-CycleGAN-and-pix2pix-master\models\base_model.py”, line 192, in load_networks
state_dict = torch.load(load_path, map_location=str(self.device))
File “E:\Anaconda3\envs\pytorch-gpu-Gan\lib\site-packages\torch\serialization.py”, line 594, in load
with _open_file_like(f, ‘rb’) as opened_file:
File “E:\Anaconda3\envs\pytorch-gpu-Gan\lib\site-packages\torch\serialization.py”, line 230, in _open_file_like
return _open_file(name_or_buffer, mode)
File “E:\Anaconda3\envs\pytorch-gpu-Gan\lib\site-packages\torch\serialization.py”, line 211, in init
super(_open_file, self).init(open(name, mode))
FileNotFoundError: [Errno 2] No such file or directory: ‘./checkpoints\maps_cyclegan\latest_net_G.pth’
Here is the folder where I generated the model
C:\Users\Administrator\Desktop\pytorch-CycleGAN-and-pix2pix-master\checkpoints\maps_cyclegan:
-latest_net_D_A.pth
-latest_net_D_B.pth
-latest_net_G_A.pth
-latest_net_G_B.pth
There is no latest_net_G.pth in the program-generated model?
修改:latest_net_G_A.pth直接修改为latest_net_G.pth 从A生成B
2,修改后出现如下错误
参考:http://www.taodudu.cc/news/show-863207.html?action=onClick
经查找后,在base_model.py文件中199行
196 # patch InstanceNorm checkpoints prior to 0.4
197 for key in list(state_dict.keys()): # need to copy keys here because we mutate in loop
198 self.__patch_instance_norm_state_dict(state_dict, net, key.split('.'))
199 net.load_state_dict(state_dict,strict=False) #qcy 添加了strict=False
修改后正常运行