Skip to content

Commit

Permalink
Merge pull request HongwenZhang#3 from HongwenZhang/py3.7
Browse files Browse the repository at this point in the history
add support for python==3.7 torch==1.4.0
  • Loading branch information
tinatiansjz authored Mar 24, 2020
2 parents e1863fa + af2c938 commit 19aaf12
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 14 deletions.
4 changes: 2 additions & 2 deletions lib/modeling/danet.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ def infer_net(self, image):
part_iuv_map = None
part_index_map = None

if uv_return_dict.has_key('part_featmaps'):
if 'part_featmaps' in uv_return_dict:
part_feat_map = uv_return_dict['part_featmaps']
else:
part_feat_map = None
Expand Down Expand Up @@ -360,7 +360,7 @@ def __init__(self):

if cfg.DANET.USE_LEARNED_RATIO:
with open(os.path.join('./data/pretrained_model', 'learned_ratio.pkl'), 'rb') as f:
pretrain_ratio = pickle.load(f)
pretrain_ratio = pickle.load(f, encoding='iso-8859-1')

if cfg.DANET.INPUT_MODE in ['iuv_gt']:
self.learned_ratio = nn.Parameter(torch.FloatTensor(pretrain_ratio['ratio']))
Expand Down
2 changes: 1 addition & 1 deletion lib/modeling/hr_module.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import logging

from lib.core.config import cfg
from res_module import BasicBlock, Bottleneck, IUV_predict_layer
from .res_module import BasicBlock, Bottleneck, IUV_predict_layer

BN_MOMENTUM = 0.1
logger = logging.getLogger(__name__)
Expand Down
4 changes: 2 additions & 2 deletions lib/modeling/smpl_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def __init__(self, model_type=None, joint_type='cocoplus', obj_saveable=False, m
smpl_model_path = './data/SMPL_data/basicModel_f_lbs_10_207_0_v1.0.0.pkl'

with open(smpl_model_path, 'rb') as f:
model = pickle.load(f)
model = pickle.load(f, encoding='iso-8859-1')

if obj_saveable:
self.faces = model['f']
Expand All @@ -62,7 +62,7 @@ def __init__(self, model_type=None, joint_type='cocoplus', obj_saveable=False, m
self.parents = model['kintree_table'][0].astype(np.int32)

with open(os.path.join('./data/pretrained_model', 'joint_regressor.pkl'), 'rb') as f:
np_joint_regressor = pickle.load(f)
np_joint_regressor = pickle.load(f, encoding='iso-8859-1')

if joint_type == 'lsp':
self.register_buffer('joint_regressor', torch.from_numpy(np_joint_regressor[:, :14]).float())
Expand Down
12 changes: 11 additions & 1 deletion lib/nn/parallel/scatter_gather.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,18 @@
from torch.autograd import Variable
from ._functions import Scatter, Gather
from torch._six import string_classes, int_classes
from torch.utils.data.dataloader import numpy_type_map
# from torch.utils.data.dataloader import numpy_type_map

numpy_type_map = {
'float64': torch.DoubleTensor,
'float32': torch.FloatTensor,
'float16': torch.HalfTensor,
'int64': torch.LongTensor,
'int32': torch.IntTensor,
'int16': torch.ShortTensor,
'int8': torch.CharTensor,
'uint8': torch.ByteTensor,
}

def scatter(inputs, target_gpus, dim=0):
r"""
Expand Down
2 changes: 1 addition & 1 deletion lib/utils/opendr_render.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from opendr.renderer import ColoredRenderer
from opendr.lighting import LambertianPointLight
from opendr.camera import ProjectPoints
from smpl_webuser.serialization import load_model
from .smpl_webuser.serialization import load_model
from skimage.transform import resize


Expand Down
14 changes: 7 additions & 7 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
torch==1.0.1
torchvision==0.2.2
torch==1.4.0
torchvision==0.5.0
easydict==1.9
neural_renderer_pytorch==1.1.3
packaging==20.1
PyYAML==5.3
h5py==2.10.0
opencv-python==4.1.2.30
chumpy==0.69
packaging==20.3
PyYAML==5.3.1
h5py==2.8.0
opencv==3.4.2
chumpy==0.69

0 comments on commit 19aaf12

Please sign in to comment.