目录
简单推理代码:
yolov11 推理保存json
推理图片目录:
可以直接安装:pip install ultralytics
简单推理代码:
import os
import torch
import cv2
from ultralytics import YOLO
# 假设这是一个全局变量,需要根据实际情况修改
GIGA_MODELS_DIR = '.'
def detect_image_yolo(image):
yolo_model = YOLO(r'E:\project\detect\yolo11\ultralytics-main\yolo11x.pt', verbose=False).to('cuda:0')
with torch.no_grad():
results = yolo_model(image, verbose=False) # predict on an image
cls = results[0].boxes.cls.int().cpu()
indices = torch.where(cls &