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

Modernize Python 2 code to get ready for Python 3 #1

Closed
wants to merge 1 commit into from

Conversation

cclauss
Copy link

@cclauss cclauss commented Dec 13, 2017

Make the minimal, safe changes required to convert the repo's code to be syntax compatible with both Python 2 and Python 3. There might be other changes required to complete a port to Python 3 but this PR is a minimal, safe first step.

Run: futurize --stage1 -w **/*.py

See Stage 1: "safe" fixes http://python-future.org/automatic_conversion.html#stage-1-safe-fixes

@xingyizhou xingyizhou mentioned this pull request Apr 20, 2018
@bilawal-mahmood
Copy link

'ascii' codec can't decode byte 0xc3 in position 13: ordinal not in range(128)
I am still getting this error. can someone help me solve this. I am using windows and python 2 does not have pytorch.

@tobiascz
Copy link

tobiascz commented Aug 20, 2018

I solved the ascii codec cant decode byte 0xc3 using this response:
CSAILVision/places365#25 (comment)

from functools import partial
import pickle
pickle.load = partial(pickle.load, encoding="latin1")
pickle.Unpickler = partial(pickle.Unpickler, encoding="latin1")
model = torch.load(model_file, map_location=lambda storage, loc: storage, pickle_module=pickle)

I just added the .cuda() option after load

model = torch.load('src/models/hgreg-3d.pth', map_location=lambda storage, loc: storage, pickle_module=pickle).cuda()

I hope this helps!

@cclauss cclauss closed this Sep 22, 2019
@cclauss cclauss deleted the modernize-python2-code branch September 22, 2019 16:49
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

Successfully merging this pull request may close these issues.

3 participants