Skip to content

使用vscode 的 debug 调试 使用openvino推理可能会出现问题.使用.pt推理没问题 #533

@wnark

Description

@wnark

最小复现代码

import cv2
from ultralytics import YOLOv10

# 读取并调整图像尺寸
img = cv2.imread("test.jpg")
img = cv2.resize(img, (640, 640))

ov_model = YOLOv10("best_openvino_model/")

result = ov_model.predict(source=img, imgsz=640, conf=0.7, save=False)
print(result[0].boxes.xywhn)
result = ov_model.predict(source=img, imgsz=640, conf=0.7, save=False)
print(result[0].boxes.xywhn)

pt_model = YOLOv10("best.pt")
result = pt_model.predict(source=img, imgsz=640, conf=0.7, save=False)
print(result[0].boxes.xywhn)
result = pt_model.predict(source=img, imgsz=640, conf=0.7, save=False)
print(result[0].boxes.xywhn)

在每个print的位置打断点,依次运行
可以观察到打印

WARNING ⚠️ Unable to automatically guess model task, assuming 'task=detect'. Explicitly define task for your model, i.e. 'task=detect', 'segment', 'classify','pose' or 'obb'.
Loading best_openvino_model for OpenVINO inference...
Using OpenVINO LATENCY mode for batch=1 inference...

0: 640x640 1 Conehead Zombie, 3 Zombies, 61.0ms
Speed: 8.6ms preprocess, 61.0ms inference, 1.0ms postprocess per image at shape (1, 3, 640, 640)
Backend qtagg is interactive backend. Turning interactive mode on.
tensor([[0.6655, 0.3269, 0.0894, 0.2034],
        [0.2181, 0.6775, 0.1150, 0.1995],
        [0.6413, 0.1660, 0.1052, 0.1714],
        [0.4406, 0.8378, 0.1043, 0.1980]])

0: 640x640 (no detections), 33.0ms
Speed: 3.6ms preprocess, 33.0ms inference, 0.0ms postprocess per image at shape (1, 3, 640, 640)
tensor([], size=(0, 4))

0: 640x640 1 Conehead Zombie, 3 Zombies, 149.1ms
Speed: 3.0ms preprocess, 149.1ms inference, 1.0ms postprocess per image at shape (1, 3, 640, 640)
tensor([[0.6655, 0.3269, 0.0894, 0.2034],
        [0.2181, 0.6775, 0.1150, 0.1995],
        [0.6413, 0.1660, 0.1052, 0.1714],
        [0.4406, 0.8378, 0.1043, 0.1980]])

0: 640x640 1 Conehead Zombie, 3 Zombies, 123.4ms
Speed: 2.0ms preprocess, 123.4ms inference, 1.0ms postprocess per image at shape (1, 3, 640, 640)
tensor([[0.6655, 0.3269, 0.0894, 0.2034],
        [0.2181, 0.6775, 0.1150, 0.1995],
        [0.6413, 0.1660, 0.1052, 0.1714],
        [0.4406, 0.8378, 0.1043, 0.1980]])

即使用openvino推理的时候,第二次推理获取不到结果,而pt推理是正常的

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions