懒得推gitee,记录一下
import os import time import shutil os.getcwd() # arrange an instance segmentation model for test from sahi.utils.yolov8 import ( download_yolov8s_model, ) import cv2 from sahi import AutoDetectionModel from sahi.utils.cv import read_image from sahi.utils.file import download_from_url from sahi.predict import get_prediction, get_sliced_prediction, predict from IPython.display import Image detection_model = AutoDetectionModel.from_pretrained( model_type='yolov8', # YOLOv8模型的路径 model_path="/home/hxzh/PycharmProjects/SAHI_YOLOv8/best.pt", # YOLOv8模型的路径 confidence_threshold=0.3, # 设备类型。 # 如果您的计算机配备 NVIDIA GPU,则可以通过将 'device' 标志更改为'cuda:0'来启用 CUDA 加速;否则,将其保留为'cpu' device="cuda:0", # or 'cuda:0' ) start_time=time.time() images_path="/media/hxzh/D/Dataset/plean_test/0926" for i in os.listdir(im