gmm_08.pkl 解析 读取

目录

1.26.3版本执行正常:

[python 1.26.3版本读取正常:](#python 1.26.3版本读取正常:)

1.23.0结果错误:


1.26.3版本执行正常:

python 复制代码
# 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)

正常结果:

bash 复制代码
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

相关推荐
kishu_iOS&AI2 分钟前
机器学习 —— 线性回归(实例)
人工智能·python·机器学习·线性回归
架构师老Y14 分钟前
007、微服务架构设计与服务拆分策略
python·微服务·架构
skilllite作者33 分钟前
SkillLite 多入口架构实战:CLI / Python SDK / MCP / Desktop / Swarm 一页理清
开发语言·人工智能·python·安全·架构·rust·agentskills
ZC跨境爬虫1 小时前
批量爬取小说章节并优化排版(附完整可运行脚本)
前端·爬虫·python·自动化
ths5121 小时前
Python 正则表达式实战指南:从入门到精通(12 个高频案例)(三)
python·正则表达式
ZC跨境爬虫1 小时前
海南大学交友平台登录页开发实战day4(解决python传输并读取登录信息的问题)
开发语言·前端·python·flask·html
Wyawsl1 小时前
Python操作MySQL数据库
数据库·python·mysql
SuperEugene1 小时前
Python 异步 async/await:为什么 AI 框架大量使用?| 基础篇
开发语言·人工智能·python
SMF19191 小时前
【uv】Python包管理器uv安装和应用
开发语言·python·uv
gergul1 小时前
在llama-cpp-python中使用自己编译的llama.cpp,解决pip install llama-cpp-python报错
python·llama·llama.cpp·llamacpppython