caffemodel2pytorch
caffemodel2pytorch copied to clipboard
TypeError: expected str, bytes or os.PathLike object, not NoneType
Hi! I'm trying to run your example "Imitate pycaffe interface to help in porting", but an error pops up
Traceback (most recent call last):
File "py.py", line 9, in
It seems that either codegen_dir or caffe_proto are None. Could you please put in a print(codegen_dir, caffe_proto)
before the local_caffe_proto = ...
line and paste in here what it prints?
Yes, caffe_proto was None.
I've added flag "caffe_proto = 'https://raw.githubusercontent.com/BVLC/caffe/master/src/caffe/proto/caffe.proto'" and fixed a couple of mistakes "AttributeError: 'OSError' object has no attribute 'message'" and "UnicodeDecodeError: 'utf-8' codec can't decode byte 0xa2 in position 31: invalid start byte".
Now i get the message:
"Skipping layer [concat, Concat, Concat]: not found in caffemodel2pytorch.modules dict
Skipping layer [neg, Power, Power]: not found in caffemodel2pytorch.modules dict
Skipping layer [flatten, Flatten, Flatten]: not found in caffemodel2pytorch.modules dict
Skipping layer [abssum, Reduction, Reduction]: not found in caffemodel2pytorch.modules dict
caffemodel2pytorch: loading model from [tracker.caffemodel] in HDF5 format failed [], falling back to caffemodel format
caffemodel2pytorch: loaded model from [tracker.caffemodel] in caffemodel format
Traceback (most recent call last):
File "py.py", line 13, in
AssertionError: Variable [target] does not exist. Pass it as a keyword argument or provide a layer which produces it."
basically this is it. It seems that your model wants to compute some loss with ground truth "target" - either you should write some code that would modify the network prior to forward pass or you should provide it with some (dummy?) target variables
You should also decide if you want to provide pytorch equivalents of these modules:
"Skipping layer [concat, Concat, Concat]: not found in caffemodel2pytorch.modules dict
Skipping layer [neg, Power, Power]: not found in caffemodel2pytorch.modules dict
Skipping layer [flatten, Flatten, Flatten]: not found in caffemodel2pytorch.modules dict
Skipping layer [abssum, Reduction, Reduction]: not found in caffemodel2pytorch.modules dict
If you do, please don't hesitate to send a PR - the codebase would improve from some porting to Python3 and more modern PyTorch
- Line #139: Comment or remove e.message
- Line #140: Change to bytes_weights = open(weights, 'rb').read()
These two change worked for me. Env: Pytorch: 1.5, Python: 3.6.9, Google Colab
@abhisheksambyal Please send a PR, I'll merge these