Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TypeError: expected str, bytes or os.PathLike object, not NoneType #12

Open
NazarovAV opened this issue Feb 10, 2020 · 7 comments
Open

Comments

@NazarovAV
Copy link

NazarovAV commented Feb 10, 2020

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
net = caffe.Net('tracker.prototxt', caffe.TEST, weights = 'tracker.caffemodel')
File "/media/veracrypt1/work/examples/trackers/caffemodel2pytorch-master/caffemodel2pytorch.py", line 71, in init
self.net_param = initialize(caffe_proto).NetParameter()
File "/media/veracrypt1/work/examples/trackers/caffemodel2pytorch-master/caffemodel2pytorch.py", line 33, in initialize
local_caffe_proto = os.path.join(codegen_dir, os.path.basename(caffe_proto))
File "/usr/local/lib/python3.7/posixpath.py", line 146, in basename
p = os.fspath(p)
TypeError: expected str, bytes or os.PathLike object, not NoneType

@vadimkantorov
Copy link
Owner

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?

@NazarovAV
Copy link
Author

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
blobs_out = net.forward(data = np.zeros((8, 3, 224, 224), dtype = np.float32))
File "/media/veracrypt1/work/examples/trackers/caffemodel2pytorch-master/caffemodel2pytorch.py", line 119, in forward
assert name in variables, 'Variable [{}] does not exist. Pass it as a keyword argument or provide a layer which produces it.'.format(name)
AssertionError: Variable [target] does not exist. Pass it as a keyword argument or provide a layer which produces it."

@vadimkantorov
Copy link
Owner

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

@vadimkantorov
Copy link
Owner

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

@vadimkantorov
Copy link
Owner

If you do, please don't hesitate to send a PR - the codebase would improve from some porting to Python3 and more modern PyTorch

@abhisheksambyal
Copy link
Contributor

  1. Line #139: Comment or remove e.message
  2. 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

@vadimkantorov
Copy link
Owner

@abhisheksambyal Please send a PR, I'll merge these

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants