caffemodel2pytorch
caffemodel2pytorch copied to clipboard
AttributeError: module 'google.protobuf.descriptor' has no attribute '_message'
what is the version of the protobuf you use? I just copied
import torch
from caffemodel2pytorch import caffemodel2pytorch
model = caffemodel2pytorch.Net(
prototxt = 'mobilenet_deploy.prototxt',
weights = 'mobilenet.caffemodel',
caffe_proto = 'https://raw.githubusercontent.com/BVLC/caffe/master/src/caffe/proto/caffe.proto'
)
model.cuda()
model.eval()
torch.set_grad_enabled(False)
it just showed the error :
Traceback (most recent call last):
File "test_torch.py", line 7, in <module>
caffe_proto = 'https://raw.githubusercontent.com/BVLC/caffe/master/src/caffe
/proto/caffe.proto'
File "C:\LPR\MobileNet-Caffe\caffemodel2pytorch\caffemodel2pytorch.py", line 7
1, in __init__
self.net_param = initialize(caffe_proto).NetParameter()
File "C:\LPR\MobileNet-Caffe\caffemodel2pytorch\caffemodel2pytorch.py", line 4
1, in initialize
old_pool = google.protobuf.descriptor._message.default_pool
AttributeError: module 'google.protobuf.descriptor' has no attribute '_message'
I haven't used this code since a long time ago, so I can't find the good protobuf version unfortunately.
You may also comment all these backup/restore protobuf lines. They are needed only in some cases of integrating with existing caffe.python-using code. You may also check out protobuf commit history at github and find when this was changed (you may also lookup the dates when I created this repo).
I tried with protobuf version 3.7 it works
I had this problem, for me the python version I was using was too recent for the protobuf version. I solved this by creating a virtual environment with python 3.7 and protobuf version 3.14
Unfortunately, I even don't remember why I had to do those Protobuf hacks :( If someone solves the problems with recent python / protobuf, please feel free to send a pr. Maybe commenting out the old_*
-related lines actually does work
#24 I have solved the problem by discovering a logic redundency among line 41 43 44 46, which can avoid using _message. Please check and accept my pull request. I haved tested the code with one .caffeemodel file.