zhenghao977 / FCOS-PyTorch-37.2AP

A pure torch implement of FCOS 37.2AP
164 stars 40 forks source link

执行detect出错。 #22

Open MasonZong opened 2 years ago

MasonZong commented 2 years ago

当我执行detect.py时,出现如下错误。使用的是voc训练权重.。 ` Traceback (most recent call last): File "detect.py", line 86, in model.load_state_dict(torch.load("./checkpoint/model_1.pth",map_location=torch.device('cpu')), strict=True) File "/home/zhangpan/anaconda3/envs/torch/lib/python3.7/site-packages/torch/nn/modules/module.py", line 1052, in load_state_dict self.class.name, "\n\t".join(error_msgs))) RuntimeError: Error(s) in loading state_dict for DataParallel: size mismatch for module.fcos_body.head.cls_logits.weight: copying a param with shape torch.Size([80, 256, 3, 3]) from checkpoint, the shape in current model is torch.Size([20, 256, 3, 3]). size mismatch for module.fcos_body.head.cls_logits.bias: copying a param with shape torch.Size([80]) from checkpoint, the shape in current model is torch.Size([20]).

`

zhenghao977 commented 2 years ago

@MasonZong config.py 默认是coco的80类,如有需要在voc上测试,更改这个配置文件中的类别数目即可。

liukangji commented 2 years ago

当我执行detect.py时,出现如下错误。使用voc训练 权 重 。 /checkpoint/model_1.pth",map_location=torch.device('cpu')), strict=True) 文件"/home/zhangpan/anaconda3/envs/torch/lib/python3.7/site-packages/torch/nn /modules/module.py”,第 1052 行,在 load_state_dict 中 。name , "\n\t".join(error_msgs))) RuntimeError: 为 DataParallel 加载 state_dict 时出错: module.fcos_body.head.cls_logits.weight 的大小不匹配:复制形状为 torch.Size([ 80, 256, 3, 3]) 从检查点开始,当前模型中的形状是 torch.Size([20, 256, 3, 3])。 module.fcos_body.head.cls_logits.bias 的大小不匹配:从检查点复制形状为 torch.Size([80]) 的参数,当前模型中的形状为 torch.Size([20])。

`你好,使用文件detect的时候,你会出现了很多乱框了吗?

blackbabyzz commented 2 years ago

是model下的config吗 我改了class_num 依然不对啊怎么回事