python - AttributeError:模块“cv2”没有属性“dnn_DetectionModel”
问题描述
当我尝试运行此代码时,为什么会收到错误 `AttributeError: module 'cv2' has no attribute 'dnn_DetectionModel':
# get the weight configurations
configPath =
'/Users/Rodne/MyComputerVision/Folder3/ssd_mobilenet_v3_large_coco_2020_01_14.pbtxt'
weightsPath = '/Users/Rodne/MyComputerVision/Folder3/frozen_inference_graph.pb'
# setting the bounding box
net = cv2.dnn_DetectionModel(weightsPath, configPath)
net.setInputSize(320, 320)
错误
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
<ipython-input-6-355122b5b70e> in <module>()
1 # setting the bounding box
----> 2 net = cv2.dnn_DetectionModel(weightsPath, configPath)
3 net.setInputSize(320, 320)
AttributeError: module 'cv2' has no attribute 'dnn_DetectionModel'
我通过在终端中输入以下内容来升级我的开放式简历:pip install opencv-python --upgrade
这就是结果
Collecting opencv-python
Downloading opencv_python-4.4.0.42-cp37-cp37m-win_amd64.whl (33.5 MB)
|████████████████████████████████| 33.5 MB 54 kB/s
Requirement already satisfied, skipping upgrade: numpy>=1.14.5 in d:\anaconda\lib\site-packages (from opencv-python) (1.18.5)
Installing collected packages: opencv-python
Successfully installed opencv-python-4.4.0.42
解决方案
您也可以尝试更新一次 opencv 模块。在我将我的 opencv 模块更新为 opencv 4 之后,它在我的情况下有效。尝试运行此命令,看看它是否有效:
pip install --upgrade opencv-python
推荐阅读
- ios - 如何在 iOS 12 上后台运行 iOS 应用程序
- python - csv 文本句子中的逗号在 python pandas read 的输出中不可读
- react-native - React Native Webview - 与 Expo - 不显示来自 s3 存储桶的图像
- sql-server - 在 T-SQL 中使用 Top
- php - 更新数组中的表值
- ruby - 使用 selenium chromedriver 创建登录到我的帐户的会话时出现错误
- php - 如何创建 php 表单并集成链接到 Telegram 或 Whatsapp 的推送通知系统?
- cordova - 错误:标头值必须是字符串错误:高级http:标头值必须是字符串离子
- javascript - 使用 GitLab 持续部署 NodeJS
- r - R shinydashboard:各种菜单子项的动态和静态tabItems的混合