如何将caffe模型和重量转换为pytorch

2024-10-01 09:22:23 发布

您现在位置:Python中文网/ 问答频道 /正文

你好,我需要帮助转换重量和型号的咖啡馆到pytorch。我尝试过使用github,大多数其他帖子都建议使用这个github,但是当我使用它时,我遇到了很多问题,因为它使用了Python2,而目前我正在使用Python3。我已经尝试删除github没有覆盖的某个层,手动将旧语法更改为新语法,但是pytorch对nn模块的最后一个错误引用,我不知道如何修复

Traceback (most recent call last):
  File "caffe2pytorch.py", line 30, in <module>
    pytorch_blobs, pytorch_models = forward_pytorch(protofile, weightfile)
  File "caffe2pytorch.py", line 17, in forward_pytorch
    net = caffenet.CaffeNet(protofile)
  File "/home/cgal/reference/SfSNet/caffe2pytorch/caffenet.py", line 384, in __init__
    self.add_module(name, model)
  File "/home/cgal/anaconda3/envs/pytorch/lib/python3.7/site-packages/torch/nn/modules/module.py", line 186, in add_module
    raise KeyError("module name can't contain \".\"")
KeyError: 'module name can\'t contain "."'

那么,对于如何将caffe的重量和型号转换为pytorch,有什么建议吗

这是我想要转换的caffe模型download here


Tags: nameinpygithubline语法nnpytorch