import os.path

from ultralytics import YOLO

'''
    注意修改配置文件中的文件夹路径
'''


model = YOLO('/home/admin-root/haotian/康达瑞贝斯机器狗/YoloV8Obj/dataset_20250819/train2/weights/best.pt')

images_path = '/home/admin-root/haotian/康达瑞贝斯机器狗/YoloV8Obj/dataset_20250819/train/images'
save_path = '/home/admin-root/haotian/康达瑞贝斯机器狗/output'

all_images = [os.path.join(images_path, t) for  t in os.listdir(images_path)]


for i in range(len(all_images)):

    # conf 置信度在.
    results = model(all_images[i],
                    conf = 0.2, device=0)

    # # Process results list
    #  = 0
    # for result in results:
    #     boxes = result.boxes  # Boxes object for bounding box outputs
    #     # masks = result.masks  # Masks object for segmentation masks outputs
    #     # keypoints = result.keypoints  # Keypoints object for pose outputs

    #     # 属于这个类的置信度
    #     probs = result.probs  # Probs object for classification outputs
    #     # obb = result.obb  # Oriented boxes object for OBB outputs
    #     print(boxes,' ',probs)
    #     # result.show()  # display to screen
    results[0].save(filename=f"{save_path}/result_{i}.jpg")  # save to disk
        # i += 1
        
    if i == 20:
        break