-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Description
Prerequisite
- I have searched Issues and Discussions but cannot get the expected help.
- The bug has not been fixed in the latest version(https://github.com/open-mmlab/mmpose).
Environment
这是我的代码 现在“result = next(result_generator)” 在这一步 消耗0.5-1s的时间 如果是一个连续的视频,这个转换速度太慢,如何解决这个问题,期待您的回复
Reproduces the problem - code sample
import torch
import numpy as np
#环境需要 必须要
✅ 第2行:添加白名单(关键!)
torch.serialization.add_safe_globals([np.core.multiarray._reconstruct])
✅ 第3行:忽略无关警告
import warnings
warnings.filterwarnings("ignore", category=UserWarning, module="pkg_resources")
#显示图片
import matplotlib
matplotlib.use('TkAgg') # 使用 Tk 后端显示图像
from PIL import Image
from matplotlib import pyplot as plt
from tqdm import tqdm
from mmengine import Config
from pycocotools.coco import COCO
from IPython import display
from mmpose.apis import MMPoseInferencer
import mmcv
import time
img_path = 'E:/pythonTest/Selenium/mmposezip/demo/picture/1232.jpg'
✅ 配置路径(确保文件存在)
det_model = 'E:/pythonTest/Selenium/mmposezip/checkpoint/rtmdet_l_8xb32-300e_coco.py'
det_weights = 'E:/pythonTest/Selenium/mmposezip/checkpoint/rtmdet_l_8xb32-300e_coco_20230719-2c8950f6.pth' # 你需要这个文件
pose_model = 'E:/pythonTest/Selenium/mmposezip/configs/body_2d_keypoint/rtmpose/ap10k/rtmpose-m_8xb256-420e_ap10k-256x256.py'
pose_weights = 'E:/pythonTest/Selenium/mmposezip/checkpoint/rtmpose-m_simcc-ap10k_pt-aic-coco_210e-256x256-7a041aa1_20230206.pth'
✅ 创建 inferencer
使用模型别名创建推断器
inferencer = MMPoseInferencer(
# det_model=det_model,
# det_weights=det_weights,
pose2d="human",
det_model="rtmdet-s",
# pose2d_weights=pose_weights,
device='cpu'
)
result_generator = inferencer(img_path, out_dir = 'outputs', show=False)
begin_time = time.time()
result = next(result_generator)
print(time.time() - begin_time)
display.clear_output()
img_og = mmcv.imread(img_path)
img_fuse = mmcv.imread('outputs/visualizations/1232.jpg')
fig, axes = plt.subplots(1, 2, figsize=(15, 10))
axes[0].imshow(mmcv.bgr2rgb(img_og))
axes[0].set_title('Original Image')
axes[0].axis('off')
axes[1].imshow(mmcv.bgr2rgb(img_fuse))
axes[1].set_title('Keypoint Image')
axes[1].axis('off')
plt.show()
Reproduces the problem - command or script
Python
Reproduces the problem - error message
11
Additional information
No response