目录
1.26.3版本执行正常:
python 1.26.3版本读取正常:
1.23.0结果错误:
1.26.3版本执行正常:
# coding=utf-8
import sys
import os
import torch;
import smplx;
smplx.create(r'./deps/smpl_models', model_type='smpl', gender='neutral', ext='pkl', batch_size=16).to(torch.device('cuda:0'))
current_dir = os.path.dirname(os.path.abspath(__file__))
current_dir_p = os.path.dirname(current_dir)
os.chdir(current_dir)
print('current_dir', current_dir)
paths = [current_dir, current_dir_p]
paths.append(os.path.join(current_dir, 'src'))
for path in paths:
sys.path.insert(0, path)
os.environ['PYTHONPATH'] = (os.environ.get('PYTHONPATH', '') + ':' + path).strip(':')
import pickle
import numpy as np
print('np.__version', np.__version__)
full_gmm_fn = './deps/smpl_models/gmm_08.pkl'
with open(full_gmm_fn, 'rb') as f:
gmm = pickle.load(f, encoding='latin1')
for idx, c in enumerate(gmm['covars']):
print(idx, 'c_max', c.max(), 'c_min', c.min())
for idx, c in enumerate(gmm['covars']):
det = np.linalg.det(c)
sign, logdet = torch.linalg.slogdet(torch.from_numpy(c))
det_c = sign * torch.exp(logdet)
if det <= 0:
print(f"行列式无效,索引 {idx}: {det}")
print(idx, det, det_c)
正常结果:
0 c_max 0.49236168172193373 c_min -0.23544843915864178
1 c_max 0.15270572127155504 c_min -0.06636943058983386
2 c_max 0.35990567884254776 c_min -0.29855782001291553
3 c_max 0.4957880359987742 c_min -0.3858436205513697
4 c_max 0.05040274081742145 c_min -0.03188406942138507
5 c_max 0.46604796151822325 c_min -0.345167503372072
6 c_max 0.26849724766175587 c_min -0.17093035395496226
7 c_max 0.30493624129949704 c_min -0.18225043837061095
0 3.2749372845849096e-136
1 3.440107744796712e-172
2 1.166091530520843e-150
3 1.9858711756979963e-141
4 1.0041491620837882e-171
5 1.3613105970495381e-154
6 2.0844686480611028e-151
7 6.733864433947538e-156
python 1.26.3版本读取正常:
python -c "import numpy as np;print(np.__version__)"
1.23.0结果错误:
1.23.2 结果错误
np.__version 1.23.0
0 c_max 0.49236168172193373 c_min -0.23544843915864178
1 c_max 0.15270572127155504 c_min -0.06636943058983386
2 c_max 0.35990567884254776 c_min -0.29855782001291553
3 c_max 0.4957880359987742 c_min -0.3858436205513697
4 c_max 0.05040274081742145 c_min -0.03188406942138507
5 c_max 0.46604796151822325 c_min -0.345167503372072
6 c_max 0.26849724766175587 c_min -0.17093035395496226
7 c_max 0.30493624129949704 c_min -0.18225043837061095
0 2.087005568661045e-59
1 2.1974185088440894e-136
2 2.2291399048498e-81
3 1.73275426665969e-65
4 2.249272139603713e-119
5 1.7713026716136105e-84
6 2.139139009462087e-74
行列式无效,索引 7: -1.6656293716672904e-83
7 -1.6656293716672904e-83