存在的问题:
-
因为centernet保存的模型中包含有dict_keys([‘epoch’, ‘state_dict’, ‘optimizer’]),其中epoch和optimizer是多余的信息,所以在load .pth文件之后应该过滤多余的两个key
torch_model = torch.load(pthfile) model.load_state_dict(torch_model['state_dict'])
-
因为网络的末端包含有字典,会报错Only tuples, lists and Variables supported as JIT inputs, but got dict,参考链接后解决方案解决问题
修改网络中的
ret = {}
for head in self.heads:
ret[head] = self.__getattr__(head)(out)
为
# ret = []
# for head in self.heads:
# ret.append(self.__getattr__(head)(out))
问题解决
把生成好的onnx模型放入网页onnx模型可视化即可显示模型结构