xingyizhou / pytorch-pose-hg-3d

PyTorch implementation for 3D human pose estimation
GNU General Public License v3.0
615 stars 141 forks source link

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

Closed cclauss closed 5 years ago

cclauss commented 6 years ago

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
bilawal-mahmood commented 6 years ago

'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 commented 6 years ago

I solved the ascii codec cant decode byte 0xc3 using this response: https://github.com/CSAILVision/places365/issues/25#issuecomment-333871990

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!