Skip to content

feat: 姿态检测和羽毛球检测自动识别 Apple Silicon MPS 加速 - #14

Open
LoicHmh wants to merge 1 commit into
yo-WASSUP:mainfrom
LoicHmh:feat/mps-acceleration
Open

feat: 姿态检测和羽毛球检测自动识别 Apple Silicon MPS 加速#14
LoicHmh wants to merge 1 commit into
yo-WASSUP:mainfrom
LoicHmh:feat/mps-acceleration

Conversation

@LoicHmh

@LoicHmh LoicHmh commented Jul 31, 2026

Copy link
Copy Markdown

Summary

  • 设备自动检测(yolo_pose.py / shuttlecock.py / rtmpose.py)此前只判断 torch.cuda.is_available(),在没有 NVIDIA 显卡的 Mac 上永远回退到 CPU,没有利用 Apple Silicon 的 MPS/CoreML 加速
  • CUDA 不可用时,现在会依次检测 MPS:
    • yolo_pose.py / shuttlecock.pytorch.backends.mps.is_available() 为真时 device 设为 "mps",Ultralytics YOLO 原生支持该 device 字符串
    • rtmpose.pydevice 设为 'mps'rtmlib 会据此选用 onnxruntime 的 CoreMLExecutionProviderrtmlib/tools/base.py 中已内置该映射)

Test plan

  • 在 Apple M3 Pro 上运行 yolo-pose 家族,日志确认 device: mps 被正确选中
  • 对比同一段视频:纯 CPU 处理速度比约 41x,启用 MPS 后降到约 12x(数字越低越快),约 3-4 倍提速
  • 输出视频、检测数据正常,无报错(仅有 Ultralytics 自身的 NMS time limit exceeded 性能提示,不影响结果)

🤖 Generated with Claude Code

https://claude.ai/code/session_01ThBPLRKmwxo3JTSSnk7zw3

设备自动检测此前只判断 torch.cuda.is_available(),在 Mac 上永远回退到 cpu,
没有利用 Apple Silicon 的 MPS/CoreML 加速。现在 CUDA 不可用时会依次检测 MPS:

- yolo_pose.py / shuttlecock.py:torch.backends.mps.is_available() 时
  device 设为 "mps",Ultralytics YOLO 原生支持该 device 字符串。
- rtmpose.py:device 设为 'mps',rtmlib 会据此选用 onnxruntime 的
  CoreMLExecutionProvider(rtmlib/tools/base.py 已内置该映射)。

在 M3 Pro 上实测:yolo-pose 家族处理速度比从纯 CPU 的约 41x 降到约 12x
(数字越低越快),约 3-4 倍提速。

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01ThBPLRKmwxo3JTSSnk7zw3
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants