From f245d972c23ff6c5551e8aec5975404bf7f4ad41 Mon Sep 17 00:00:00 2001 From: yooooger <761181201@qq.com> Date: Mon, 9 Mar 2026 10:58:41 +0800 Subject: [PATCH] =?UTF-8?q?=E5=B7=B2=E6=B7=BB=E5=8A=A0=E5=9D=90=E6=A0=87cl?= =?UTF-8?q?amp=EF=BC=8C=E7=A1=AE=E4=BF=9D=E5=BD=92=E4=B8=80=E5=8C=96?= =?UTF-8?q?=E5=90=8E=E7=9A=84x=E5=92=8Cy=E4=B8=A5=E6=A0=BC=E5=9C=A80.0?= =?UTF-8?q?=E5=88=B01.0=E4=B9=8B=E9=97=B4=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- predict/predict_yolo11seg.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/predict/predict_yolo11seg.py b/predict/predict_yolo11seg.py index 71685b3..da34098 100644 --- a/predict/predict_yolo11seg.py +++ b/predict/predict_yolo11seg.py @@ -462,13 +462,13 @@ class YOLOSegmentationInference: h, w = mask.shape points = [] for point in approx: - x = point[0][0] / w - y = point[0][1] / h + x = max(0.0, min(1.0, point[0][0] / w)) + y = max(0.0, min(1.0, point[0][1] / h)) points.extend([x, y]) # 写入标签文件 if len(points) >= 6: # 至少3个点 - line = f"{class_id} {' '.join(map(lambda x: f'{x:.6f}', points))} {score:.6f}\n" + line = f"{class_id} {' '.join(map(lambda x: f'{x:.6f}', points))}\n" f.write(line) print(f"标签文件已保存: {label_path}") @@ -1027,4 +1027,8 @@ def predict_images_share_dir(task_id, pt_name, zip_url, user_name, pwd, output_d else : print(f"错误: 输入 {zip_url} 不是有效的文件或目录") - return standardized_path(f"{target_path}_识别/{task_id}/{current_time}/{task_id}.zip"), "success" \ No newline at end of file + return standardized_path(f"{target_path}_识别/{task_id}/{current_time}/{task_id}.zip"), "success" + +if __name__ == '__main__': + predict_images + #predict_images_share_dir(1, "road_crack", "smb://192.168.1.100/share/ai_train_platform/train.zip", "admin", "admin.123", "predictions", 0.25, True) \ No newline at end of file