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: '<' not supported between instances of 'NoneType' and 'str' #56

Open
flukefer1243 opened this issue Aug 9, 2022 · 2 comments

Comments

@flukefer1243
Copy link

hi, I need to convert model VGG_FACEt.7 (This model, I download form this link: https://www.robots.ox.ac.uk/~vgg/software/vgg_face/) to Pytorch model. When I run command "python convert_torch.py -m VGGFACE.t7", I obtain the error follow as below.


Traceback (most recent call last):
File "convert_torch.py", line 314, in
torch_to_pytorch(args.model,args.output)
File "convert_torch.py", line 259, in torch_to_pytorch
model = load_lua(t7_filename,unknown_classes=True)
File "C:\Users\User\anaconda3\envs\env_pytorch\lib\site-packages\torch\utils\serialization\read_lua_file.py", line 608, in load_lua
return reader.read()
File "C:\Users\User\anaconda3\envs\env_pytorch\lib\site-packages\torch\utils\serialization\read_lua_file.py", line 593, in read
return self.read_object()
File "C:\Users\User\anaconda3\envs\env_pytorch\lib\site-packages\torch\utils\serialization\read_lua_file.py", line 523, in wrapper
result = fn(self, *args, **kwargs)
File "C:\Users\User\anaconda3\envs\env_pytorch\lib\site-packages\torch\utils\serialization\read_lua_file.py", line 546, in read_object
return reader_registry[cls_name](self, version)
File "C:\Users\User\anaconda3\envs\env_pytorch\lib\site-packages\torch\utils\serialization\read_lua_file.py", line 245, in read_nn_class
_load_backend(obj)
File "C:\Users\User\anaconda3\envs\env_pytorch\lib\site-packages\torch\utils\serialization\read_lua_file.py", line 220, in _load_backend
for key in dir(obj):
TypeError: '<' not supported between instances of 'NoneType' and 'str'


@10peta-cat
Copy link

10peta-cat commented Nov 16, 2022

I encounted the same problem too.
To solve this, you need to edit convert_torch.py two times.
First, to solve TypeError: '<' not supported between instances of 'NoneType' and 'str', change line 261 like this:

model = load_lua(t7_filename,unknown_classes=True,long_size=8)

After that, you may encount RuntimeError: The expanded size of the tensor (3) must match the existing size (27) at non-singleton dimension 3.
Then, change line 44 like this:

if m.weight is not None: 
        m.weight.data = m.weight.view(n.weight.size())
        n.weight.data.copy_(m.weight)

This solution is based on here:
pytorch/pytorch#9816
#35

@Aelisa
Copy link

Aelisa commented Dec 17, 2022

you are right!THANKS!!!

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