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

UnicodeDecodeError if .pth file presents #307

Closed
neur1n opened this issue Jun 5, 2020 · 2 comments
Closed

UnicodeDecodeError if .pth file presents #307

neur1n opened this issue Jun 5, 2020 · 2 comments

Comments

@neur1n
Copy link

neur1n commented Jun 5, 2020

So I'm trying to deploy a pytorch demo on an Android device, but whenever there is a pth file (you can treat it as a neural network model) in src/main/python folder, an UnicodeDecodeError exception will be raised even though the Python source code is not loading the file. This file is in binary format, which is not the same as test.pth in this repo.

The normal way to load the file (while running in PC) is

model = torch.load('foo.pth')

But if I load it with

model = torch.load(open('foo.pth', encoding='utf-8'))

The same UnicodeDecodeError raised. So I assume the exception occurs during Chaquopy sourcing the files?

@mhsmith
Copy link
Member

mhsmith commented Jun 5, 2020

As you've found, the .pth extension is also used for path configuration files. So you'll have to either rename it to have a different extension, or preferably put it in a package subdirectory rather than in the source code root.

For actually finding the file at runtime, see #144.

@neur1n
Copy link
Author

neur1n commented Jun 5, 2020

Oh I've never know it is a path configuration file. I thought that test.pth was a dummy file.

Thank you very much.

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

2 participants