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

pip安装python包:

pip install yolov9pip

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

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

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)

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

pip install opencv-python-headless==4.8.0.74

相关推荐

  1. React

    2024-03-21 13:18:02       40 阅读
  2. 【实践】Filebeats的

    2024-03-21 13:18:02       5 阅读

最近更新

  1. TCP协议是安全的吗?

    2024-03-21 13:18:02       16 阅读
  2. 阿里云服务器执行yum,一直下载docker-ce-stable失败

    2024-03-21 13:18:02       16 阅读
  3. 【Python教程】压缩PDF文件大小

    2024-03-21 13:18:02       15 阅读
  4. 通过文章id递归查询所有评论(xml)

    2024-03-21 13:18:02       18 阅读

热门阅读

  1. 二叉树遍历144、94、145

    2024-03-21 13:18:02       19 阅读
  2. Python基础算法解析:决策树

    2024-03-21 13:18:02       16 阅读
  3. css第一个元素first-child匹配失败原因

    2024-03-21 13:18:02       18 阅读
  4. 后端使用前端页面的很好的推荐Layui

    2024-03-21 13:18:02       18 阅读
  5. mysql 学习

    2024-03-21 13:18:02       20 阅读
  6. 初学者指南 | PostgreSQL中的加密机制如何运作?

    2024-03-21 13:18:02       19 阅读
  7. vue3自定义指令

    2024-03-21 13:18:02       16 阅读
  8. 5.2.6、【AI技术新纪元:Spring AI解码】Amazon Bedrock

    2024-03-21 13:18:02       19 阅读
  9. IDEA启动提示Downloading pre-built shared indexes

    2024-03-21 13:18:02       19 阅读