Skip to content

Commit 2e07831

Browse files
committed
Add assertion to check that path exists
1 parent b50b13d commit 2e07831

File tree

2 files changed

+15
-9
lines changed

2 files changed

+15
-9
lines changed

setup.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
2828
AUTHOR = 'Vassilis Choutas'
2929
REQUIRES_PYTHON = '>=3.6.0'
30-
VERSION = '0.1.10'
30+
VERSION = '0.1.11'
3131

3232
here = os.path.abspath(os.path.dirname(__file__))
3333

smplx/body_models.py

+14-8
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,8 @@ def __init__(self, model_path, data_struct=None,
181181
smpl_path = os.path.join(model_path, model_fn)
182182
else:
183183
smpl_path = model_path
184+
assert osp.exists(smpl_path), 'Path {} does not exist!'.format(
185+
smpl_path)
184186

185187
with open(smpl_path, 'rb') as smpl_file:
186188
data_struct = Struct(**pickle.load(smpl_file,
@@ -457,15 +459,17 @@ def __init__(self, model_path,
457459
# model folder
458460
if data_struct is None:
459461
# Load the model
460-
if osp.isfile(model_path):
461-
smplh_path = model_path
462-
elif osp.isdir(model_path):
462+
if osp.isdir(model_path):
463463
model_fn = 'SMPLH_{}.{ext}'.format(gender.upper(), ext=ext)
464464
smplh_path = os.path.join(model_path, model_fn)
465+
else:
466+
smplh_path = model_path
467+
assert osp.exists(smplh_path), 'Path {} does not exist!'.format(
468+
smplh_path)
465469

466470
if ext == 'pkl':
467-
with open(smplh_path, 'rb') as smplx_file:
468-
model_data = pickle.load(smplx_file, encoding='latin1')
471+
with open(smplh_path, 'rb') as smplh_file:
472+
model_data = pickle.load(smplh_file, encoding='latin1')
469473
elif ext == 'npz':
470474
model_data = np.load(smplh_path, allow_pickle=True)
471475
else:
@@ -690,11 +694,13 @@ def __init__(self, model_path,
690694
'''
691695

692696
# Load the model
693-
if osp.isfile(model_path):
694-
smplx_path = model_path
695-
elif osp.isdir(model_path):
697+
if osp.isdir(model_path):
696698
model_fn = 'SMPLX_{}.{ext}'.format(gender.upper(), ext=ext)
697699
smplx_path = os.path.join(model_path, model_fn)
700+
else:
701+
smplx_path = model_path
702+
assert osp.exists(smplx_path), 'Path {} does not exist!'.format(
703+
smplx_path)
698704

699705
if ext == 'pkl':
700706
with open(smplx_path, 'rb') as smplx_file:

0 commit comments

Comments
 (0)