测试模型报错,请问需要怎么解决呢
jinghehehe opened this issue · 3 comments
RuntimeError: Error(s) in loading state_dict for Model:
Missing key(s) in state_dict: "Biliteral_Grid.SB1.conv1.conv2d.weight", "Biliteral_Grid.SB1.conv1.conv2d.bias", "Biliteral_Grid.SB1.conv2.conv2d.weight", "Biliteral_Grid.SB1.conv2.conv2d.bias", "Biliteral_Grid.SB1.conv_short.weight", "Biliteral_Grid.SB1.conv_short.bias", "Biliteral_Grid.SB2.conv1.conv2d.weight", "Biliteral_Grid.SB2.conv1.conv2d.bias", "Biliteral_Grid.SB2.conv2.conv2d.weight", "Biliteral_Grid.SB2.conv2.conv2d.bias", "Biliteral_Grid.SB2.conv_short.weight", "Biliteral_Grid.SB2.conv_short.bias", "Biliteral_Grid.SB3.conv1.conv2d.weight", "Biliteral_Grid.SB3.conv1.conv2d.bias", "Biliteral_Grid.SB3.conv2.conv2d.weight", "Biliteral_Grid.SB3.conv2.conv2d.bias", "Biliteral_Grid.SB3.conv_short.weight", "Biliteral_Grid.SB3.conv_short.bias", "Biliteral_Grid.conv1.conv2d.weight", "Biliteral_Grid.conv1.conv2d.bias", "Biliteral_Grid.conv2.conv2d.weight", "Biliteral_Grid.conv2.conv2d.bias", "Biliteral_Grid.L1.conv2d.weight", "Biliteral_Grid.L1.conv2d.bias", "Biliteral_Grid.L2.conv2d.weight", "Biliteral_Grid.L2.conv2d.bias", "Biliteral_Grid.G1.conv2d.weight", "Biliteral_Grid.G1.conv2d.bias", "Biliteral_Grid.G2.conv2d.weight", "Biliteral_Grid.G2.conv2d.bias", "Biliteral_Grid.G3.weight", "Biliteral_Grid.G3.bias", "Biliteral_Grid.G4.weight", "Biliteral_Grid.G4.bias", "Biliteral_Grid.G5.weight", "Biliteral_Grid.G5.bias", "Biliteral_Grid.G6.weight", "Biliteral_Grid.G6.bias", "Biliteral_Grid.F.conv2d.weight", "Biliteral_Grid.F.conv2d.bias", "Biliteral_Grid.T.conv2d.weight", "Biliteral_Grid.T.conv2d.bias", "guide.conv1.conv.weight", "guide.conv1.conv.bias", "guide.conv2.conv.weight", "guide.conv2.conv.bias".
Unexpected key(s) in state_dict: "0.weight", "0.bias", "2.weight", "2.bias", "5.weight", "5.bias", "9.weight", "9.bias", "12.weight", "12.bias", "16.weight", "16.bias", "19.weight", "19.bias", "22.weight", "22.bias", "25.weight", "25.bias", "29.weight", "29.bias", "32.weight", "32.bias", "35.weight", "35.bias", "38.weight", "38.bias", "42.weight", "42.bias", "45.weight", "45.bias", "48.weight", "48.bias", "51.weight", "51.bias".
RuntimeError: Error(s) in loading state_dict for Model:
Missing key(s) in state_dict: "Biliteral_Grid.SB1.conv1.conv2d.weight", "Biliteral_Grid.SB1.conv1.conv2d.bias", "Biliteral_Grid.SB1.conv2.conv2d.weight", "Biliteral_Grid.SB1.conv2.conv2d.bias", "Biliteral_Grid.SB1.conv_short.weight", "Biliteral_Grid.SB1.conv_short.bias", "Biliteral_Grid.SB2.conv1.conv2d.weight", "Biliteral_Grid.SB2.conv1.conv2d.bias", "Biliteral_Grid.SB2.conv2.conv2d.weight", "Biliteral_Grid.SB2.conv2.conv2d.bias", "Biliteral_Grid.SB2.conv_short.weight", "Biliteral_Grid.SB2.conv_short.bias", "Biliteral_Grid.SB3.conv1.conv2d.weight", "Biliteral_Grid.SB3.conv1.conv2d.bias", "Biliteral_Grid.SB3.conv2.conv2d.weight", "Biliteral_Grid.SB3.conv2.conv2d.bias", "Biliteral_Grid.SB3.conv_short.weight", "Biliteral_Grid.SB3.conv_short.bias", "Biliteral_Grid.conv1.conv2d.weight", "Biliteral_Grid.conv1.conv2d.bias", "Biliteral_Grid.conv2.conv2d.weight", "Biliteral_Grid.conv2.conv2d.bias", "Biliteral_Grid.L1.conv2d.weight", "Biliteral_Grid.L1.conv2d.bias", "Biliteral_Grid.L2.conv2d.weight", "Biliteral_Grid.L2.conv2d.bias", "Biliteral_Grid.G1.conv2d.weight", "Biliteral_Grid.G1.conv2d.bias", "Biliteral_Grid.G2.conv2d.weight", "Biliteral_Grid.G2.conv2d.bias", "Biliteral_Grid.G3.weight", "Biliteral_Grid.G3.bias", "Biliteral_Grid.G4.weight", "Biliteral_Grid.G4.bias", "Biliteral_Grid.G5.weight", "Biliteral_Grid.G5.bias", "Biliteral_Grid.G6.weight", "Biliteral_Grid.G6.bias", "Biliteral_Grid.F.conv2d.weight", "Biliteral_Grid.F.conv2d.bias", "Biliteral_Grid.T.conv2d.weight", "Biliteral_Grid.T.conv2d.bias", "guide.conv1.conv.weight", "guide.conv1.conv.bias", "guide.conv2.conv.weight", "guide.conv2.conv.bias".
Unexpected key(s) in state_dict: "0.weight", "0.bias", "2.weight", "2.bias", "5.weight", "5.bias", "9.weight", "9.bias", "12.weight", "12.bias", "16.weight", "16.bias", "19.weight", "19.bias", "22.weight", "22.bias", "25.weight", "25.bias", "29.weight", "29.bias", "32.weight", "32.bias", "35.weight", "35.bias", "38.weight", "38.bias", "42.weight", "42.bias", "45.weight", "45.bias", "48.weight", "48.bias", "51.weight", "51.bias".
请问你是使用了哪里的checkpoints,是自己训练的checkpoint吗
RuntimeError: Error(s) in loading state_dict for Model:
Missing key(s) in state_dict: "Biliteral_Grid.SB1.conv1.conv2d.weight", "Biliteral_Grid.SB1.conv1.conv2d.bias", "Biliteral_Grid.SB1.conv2.conv2d.weight", "Biliteral_Grid.SB1.conv2.conv2d.bias", "Biliteral_Grid.SB1.conv_short.weight", "Biliteral_Grid.SB1.conv_short.bias", "Biliteral_Grid.SB2.conv1.conv2d.weight", "Biliteral_Grid.SB2.conv1.conv2d.bias", "Biliteral_Grid.SB2.conv2.conv2d.weight", "Biliteral_Grid.SB2.conv2.conv2d.bias", "Biliteral_Grid.SB2.conv_short.weight", "Biliteral_Grid.SB2.conv_short.bias", "Biliteral_Grid.SB3.conv1.conv2d.weight", "Biliteral_Grid.SB3.conv1.conv2d.bias", "Biliteral_Grid.SB3.conv2.conv2d.weight", "Biliteral_Grid.SB3.conv2.conv2d.bias", "Biliteral_Grid.SB3.conv_short.weight", "Biliteral_Grid.SB3.conv_short.bias", "Biliteral_Grid.conv1.conv2d.weight", "Biliteral_Grid.conv1.conv2d.bias", "Biliteral_Grid.conv2.conv2d.weight", "Biliteral_Grid.conv2.conv2d.bias", "Biliteral_Grid.L1.conv2d.weight", "Biliteral_Grid.L1.conv2d.bias", "Biliteral_Grid.L2.conv2d.weight", "Biliteral_Grid.L2.conv2d.bias", "Biliteral_Grid.G1.conv2d.weight", "Biliteral_Grid.G1.conv2d.bias", "Biliteral_Grid.G2.conv2d.weight", "Biliteral_Grid.G2.conv2d.bias", "Biliteral_Grid.G3.weight", "Biliteral_Grid.G3.bias", "Biliteral_Grid.G4.weight", "Biliteral_Grid.G4.bias", "Biliteral_Grid.G5.weight", "Biliteral_Grid.G5.bias", "Biliteral_Grid.G6.weight", "Biliteral_Grid.G6.bias", "Biliteral_Grid.F.conv2d.weight", "Biliteral_Grid.F.conv2d.bias", "Biliteral_Grid.T.conv2d.weight", "Biliteral_Grid.T.conv2d.bias", "guide.conv1.conv.weight", "guide.conv1.conv.bias", "guide.conv2.conv.weight", "guide.conv2.conv.bias".
Unexpected key(s) in state_dict: "0.weight", "0.bias", "2.weight", "2.bias", "5.weight", "5.bias", "9.weight", "9.bias", "12.weight", "12.bias", "16.weight", "16.bias", "19.weight", "19.bias", "22.weight", "22.bias", "25.weight", "25.bias", "29.weight", "29.bias", "32.weight", "32.bias", "35.weight", "35.bias", "38.weight", "38.bias", "42.weight", "42.bias", "45.weight", "45.bias", "48.weight", "48.bias", "51.weight", "51.bias".请问你是使用了哪里的checkpoints,是自己训练的checkpoint吗
我也出现一样的错误,请问如何解决,模型采用你项目里文件夹 checkpoint 里面的
@zhanghongyong123456 @jinghehehe 你好,出现这个问题的原因很简单,运行此模型需要两个文件,一个是vgg_checkpoint, 此模型作用是提取content_feature和style_feature;另一个是训练的模型,model_checkpoint, 这个模型用于执行迁移的任务。 如果没有指定正确的model_checkpoint, 就无法生成。
解决方法:最简单的,就是训练一个模型,可以少迭代几次,迅速把模型存储下来,再用这个训练的模型去运行。
1.创建两个文件夹,分别放入style_imgs和content_imgs (这个文件夹中的图像文件名不确定名称是否要一致,我的两个文件夹里面名称是一致)
2.用mian.py代码中,把epoch和save_interval改小。
3.运行训练,存储对应的model_checkpoint (代码中会自动存)
4.这个时候运行test.py,指定到对应的生成的model_checkpoint即可。