|
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
报错内容
Traceback (most recent call last):
File "2.py", line 22, in <module>
File "cvzone\HandTrackingModule.py", line 36, in __init__
File "mediapipe\python\solutions\hands.py", line 114, in __init__
File "mediapipe\python\solution_base.py", line 234, in __init__
FileNotFoundError: The path does not exist: C:\Users\Administrator\Downloads\dist\22\_internal\mediapipe/modules/hand_landmark/hand_landmark_tracking_cpu.binarypb
https://fishc.com.cn/thread-226531-1-1.html
https://fishc.com.cn/thread-226531-1-1.html
https://fishc.com.cn/thread-226531-1-1.html这个链接里面的
,将输出的路径中的__init__.py替换为模型文件的路径,并在代码中添加这个路径。
这个是要怎么操作,我是小白,研究了好半天没懂
解决MediaPipe模型路径问题的步骤:
1. 找到模型文件位置:
打开Python安装目录,找到:
Lib\site-packages\mediapipe\modules\hand_landmark
复制其中的 hand_landmark_tracking_cpu.binarypb 文件
2. 修改代码路径:
在调用 Hands() 的地方添加模型路径参数:
- from mediapipe.python.solutions import hands
- hands.Hands(
- model_path=r'mediapipe/modules/hand_landmark/hand_landmark_tracking_cpu.binarypb',
- # 其他参数保持不变...
- )
复制代码
3. 打包时添加资源文件(以pyinstaller为例):
创建spec文件时添加:
- a = Analysis(
- ...
- datas=[
- ('源文件路径\\hand_landmark_tracking_cpu.binarypb', 'mediapipe/modules/hand_landmark')
- ],
- ...
- )
复制代码
4. 推荐目录结构:
- dist/
- └── your_exe/
- ├── mediapipe/
- │ └── modules/
- │ └── hand_landmark/
- │ └── hand_landmark_tracking_cpu.binarypb
- └── your_exe.exe
5. 终极解决方案:
如果仍然报错,直接将模型文件复制到报错提示的路径:
C:\Users\...\dist\22\_internal\mediapipe\modules\hand_landmark\
建议使用虚拟环境打包,避免路径污染。如果仍不成功,可以尝试更新mediapipe到最新版本
以上回复来自 FishC AI 小助理,如未能正确解答您的问题,请继续追问。
|
|