Open yvancham opened 1 year ago
请问您问题解决了吗?
把frcnn.py里面的model_path换成你刚刚训练好的存在logs目录里面的那个就行了,"model_path": 'logs/best_epoch_weights.pth'
把frcnn.py里面的model_path换成你刚刚训练好的存在logs目录里面的那个就行了,"model_path": 'logs/best_epoch_weights.pth'
PS C:\Users\Raj\Desktop\COD_RCNN_cod\src> python inference.py
C:\Users\Raj\AppData\Roaming\Python\Python312\site-packages\torchvision\models_utils.py:208: UserWarning: The parameter 'pretrained' is deprecated since 0.13 and may be removed in the future, please use 'weights' instead.
e 10, in
PS C:\Users\Raj\Desktop\COD_RCNN_cod\src>
您好,您能告诉我应该怎么做才能解决这个错误吗。 谢谢。
报错代码如下: D:\ProgramData\anaconda3\envs\pytorch\python.exe E:\02Detection\faster-rcnn-pytorch-master\predict.py Traceback (most recent call last): File "E:\02Detection\faster-rcnn-pytorch-master\predict.py", line 14, in
frcnn = FRCNN()
File "E:\02Detection\faster-rcnn-pytorch-master\frcnn.py", line 89, in init
self.generate()
File "E:\02Detection\faster-rcnn-pytorch-master\frcnn.py", line 102, in generate
self.net.load_state_dict(torch.load(self.model_path, map_location=device))
File "D:\ProgramData\anaconda3\envs\pytorch\lib\site-packages\torch\nn\modules\module.py", line 2041, in load_state_dict
raise RuntimeError('Error(s) in loading state_dict for {}:\n\t{}'.format(
RuntimeError: Error(s) in loading state_dict for FasterRCNN:
size mismatch for head.cls_loc.weight: copying a param with shape torch.Size([84, 2048]) from checkpoint, the shape in current model is torch.Size([8, 2048]).
size mismatch for head.cls_loc.bias: copying a param with shape torch.Size([84]) from checkpoint, the shape in current model is torch.Size([8]).
size mismatch for head.score.weight: copying a param with shape torch.Size([21, 2048]) from checkpoint, the shape in current model is torch.Size([2, 2048]).
size mismatch for head.score.bias: copying a param with shape torch.Size([21]) from checkpoint, the shape in current model is torch.Size([2]).
进程已结束,退出代码1