当前位置:   article > 正文

YOLOv9尝鲜测试五分钟极简配置_yolov9测试

yolov9测试

pip安装python包:

pip install yolov9pip
  • 1

https://github.com/WongKinYiu/yolov9/tree/main中下载好权重文件yolov9-c.pt。
运行下面代码:

import yolov9

model = yolov9.load("yolov9-c.pt", device="cpu") # load pretrained or custom model
model.conf = 0.25 # NMS confidence threshold
model.iou = 0.45 # NMS IoU threshold
model.classes = None # (optional list) filter by class
results = model("zidane.jpg") # perform inference
predictions = results.pred[0] # parse results
boxes = predictions[:, :4] # x1, y1, x2, y2
scores = predictions[:, 4]
categories = predictions[:, 5]
results.show() # show detection bounding boxes on image
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12

结果显示:
在这里插入图片描述
如果报错:

Showing images is not supported in this environment: OpenCV(4.9.0) :-1: error: (-5:Bad argument) in function 'rectangle'
> Overload resolution failed:
>  - img marked as output argument, but provided NumPy array marked as readonly
>  - Expected Ptr<cv::UMat> for argument 'img'
>  - argument for rectangle() given by name ('thickness') and position (4)
>  - argument for rectangle() given by name ('thickness') and position (4)
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6

说明opencv-python-headless版本不支持,运行下面pip命令则可以解决:

pip install opencv-python-headless==4.8.0.74
  • 1
声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/小丑西瓜9/article/detail/391114
推荐阅读
相关标签
  

闽ICP备14008679号