当我尝试运行这段代码时,为什么会出现“AttributeError: module 'cv2' has no attribute 'dnn_DetectionModel'”错误?
这是我所拥有的唯一cv2.dnn:
# 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'
我通过在终端中输入以下命令来升级我的openCV: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
这是我所拥有的唯一cv2.dnn:
![在这里输入图片描述](https://istack.dev59.com/Caz3z.webp)