From 358bba1b8c6643f516a92fac9a9970504f93b962 Mon Sep 17 00:00:00 2001 From: haotian <2421912570@qq.com> Date: Thu, 26 Jun 2025 10:32:24 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0--=E6=B7=BB=E5=8A=A0=E6=89=BE?= =?UTF-8?q?=E5=87=BA=E5=B8=A6=E6=9C=89=E6=8C=87=E5=AE=9A=E6=B3=A8=E9=87=8A?= =?UTF-8?q?=E7=9A=84=E5=9B=BE=E7=89=87=E8=84=9A=E6=9C=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- 036找出带有指定注释的图片.py | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 036找出带有指定注释的图片.py diff --git a/036找出带有指定注释的图片.py b/036找出带有指定注释的图片.py new file mode 100644 index 0000000..54345a2 --- /dev/null +++ b/036找出带有指定注释的图片.py @@ -0,0 +1,29 @@ + +from ultralytics import YOLO + +import os +import shutil + + +model_path = '/home/admin-root/haotian/python哈汽锻8安全帽识别/HelmetHeadBAC/trainHardHatsV1HelmetHeadShoe2/weights/best.pt' +image_path = '/home/admin-root/haotian/锻8/tensorrtx/yolov8/images_20250624105811' +output_path = '/home/admin-root/haotian/python哈汽锻8安全帽识别/export/duan8_11/images' + +image_names = os.listdir(image_path) +target_list = [1] + +model = YOLO(model_path) + +all_image_path = [os.path.join(image_path, t) for t in image_names] + +for i in range(len(all_image_path)): + results = model(all_image_path[i], conf=0.3, device=0) + if len(results[0].boxes.cls) > 0: + for c in results[0].boxes.cls: + if c.item() in target_list: + print(all_image_path[i]) + shutil.copy(all_image_path[i], os.path.join(output_path, image_names[i])) + break + + +# \ No newline at end of file