z1069614715 / pytorch-classifier

image classifier implement in pytoch.
MIT License
97 stars 17 forks source link

预测出错 #6

Open lkcode1314 opened 8 months ago

lkcode1314 commented 8 months ago

魔导,预测时候的label_path [是干啥的,权重文件路径怎么没有,一直预测错误。 RuntimeError: Error(s) in loading state_dict for ResNet: Unexpected key(s) in state_dict: "total_ops", "total_params", "layer1.0.total_ops", "layer1.0.total_params", "layer1.1.total_ops", "layer1.1.total_params", "layer1.2.total_ops", "layer1.2.total_params", "layer2.0.total_ops", "layer2.0.total_params", "layer2.1.total_ops", "layer2.1.total_params", "layer2.2.total_ops", "layer2.2.total_params", "layer2.3.total_ops", "layer2.3.total_params", "layer3.0.total_ops", "layer3.0.total_params", "layer3.1.total_ops", "layer3.1.total_params", "layer3.2.total_ops", "layer3.2.total_params", "layer3.3.total_ops", "layer3.3.total_params", "layer3.4.total_ops", "layer3.4.total_params", "layer3.5.total_ops", "layer3.5.total_params", "layer4.0.total_ops", "layer4.0.total_params", "layer4.1.total_ops", "layer4.1.total_params", "layer4.2.total_ops", "layer4.2.total_params". size mismatch for fc.1.weight: copying a param with shape torch.Size([5, 2048]) from checkpoint, the shape in current model is torch.Size([3674, 2048]). size mismatch for fc.1.bias: copying a param with shape torch.Size([5]) from checkpoint, the shape in current model is torch.Size([3674]).

parser = argparse.ArgumentParser() parser.add_argument('--model_name', type=str, default='resnet50', help='model name') parser.add_argument('--pretrained', action="store_false", help='using pretrain weight') parser.add_argument('--weight', type=str, default='', help='loading weight path') parser.add_argument('--config', type=str, default='config/config.py', help='config path') parser.add_argument('--device', type=str, default='', help='cuda device, i.e. 0 or 0,1,2,3 or cpu')

parser.add_argument('--train_path', type=str, default=r'E:\alunwen\zhongyaoneirong\code\fenlei\flower_data\train', help='train data path')
parser.add_argument('--val_path', type=str, default=r'E:\alunwen\zhongyaoneirong\code\fenlei\flower_data\val', help='val data path')
parser.add_argument('--test_path', type=str, default=r'E:\alunwen\zhongyaoneirong\code\fenlei\flower_data\test', help='test data path')
parser.add_argument('--label_path', type=str, default=r'E:\alunwen\zhongyaoneirong\code\fenlei\flower_data\flower_photos\label.txt', help='label path')
loganzhang4 commented 8 months ago

哥们,你有这个报错吗 AttributeError: 'collections.OrderedDict' object has no attribute 'state_dict'

174326Jl commented 5 months ago

runs模型下载的链接过期了,可以重新分享一下吗?求求了