From 0db3481d945e73509bbac5d3a255804a2568f084 Mon Sep 17 00:00:00 2001 From: songbingle <1696321477@qq.com> Date: Fri, 6 Jun 2025 14:08:13 +0800 Subject: [PATCH] =?UTF-8?q?[MF]=E4=BF=AE=E6=94=B9=E6=96=87=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/show.py | 42 ------------------------------------------ src/train.py | 2 +- 2 files changed, 1 insertion(+), 43 deletions(-) delete mode 100644 src/show.py diff --git a/src/show.py b/src/show.py deleted file mode 100644 index 561f4a0..0000000 --- a/src/show.py +++ /dev/null @@ -1,42 +0,0 @@ -import cv2 -from PIL import Image -import os - -folder_path = 'C:/workspace/le-yolo/data/images/train' -for filename in os.listdir(folder_path): - if filename.lower().endswith(('.png', '.jpg', '.jpeg', '.bmp', '.gif')): - img_path = os.path.join(folder_path, filename) - img = cv2.imread(img_path) - height, width, _ = img.shape - - -file_path = 'C:/workspace/le-yolo/data/labels/aut' -txt_files = os.listdir(file_path) -for txt_file in txt_files: - file_path = os.path.join(folder_path, txt_file) - with open(file_path, "r", ) as f: - lines = f.readlines() - for line in lines: - # 解析标注信息 - parts = line.strip().split() - category_id = int(parts[0]) - category_name = 'person' - x_center = float(parts[1]) - y_center = float(parts[2]) - w = float(parts[3]) - h = float(parts[4]) - # 转换为绝对坐标 - x1 = int((x_center - w / 2) * width) - y1 = int((y_center - h / 2) * height) - x2 = int((x_center + w / 2) * width) - y2 = int((y_center + h / 2) * height) - # 在图片上绘制矩形框 - cv2.rectangle(img, (x1, y1), (x2, y2), (255, 0, 0), 2) - # 在图片上绘制标注类别 - cv2.putText(img, category_name, (x1, y1 - 10), cv2.FONT_HERSHEY_SIMPLEX, 0.9, (255, 0, 0), 2) - -cv2.imshow('Annotated Image', img) -cv2.waitKey(0) -cv2.destroyAllWindows() - -cv2.imwrite('annotated_image.jpg', img) \ No newline at end of file diff --git a/src/train.py b/src/train.py index 34d9b42..15f5608 100644 --- a/src/train.py +++ b/src/train.py @@ -1,5 +1,5 @@ from ultralytics import YOLO -model = YOLO(r"C:\workspace\le-yolo\runs\detect\train35\weights\last.pt") +model = YOLO(r"C:\workspace\le-yolo\runs\detect\train36\weights\last.pt") model.train(data="data.yaml", epochs=100, batch=8, device='cpu', imgsz=640) model.val() print('训练完成') \ No newline at end of file