From b4468c78088fe19be601d51203f37cb7189a9e95 Mon Sep 17 00:00:00 2001 From: fly6516 Date: Thu, 29 May 2025 20:00:55 +0800 Subject: [PATCH] =?UTF-8?q?feat(datasets):=20=E6=B7=BB=E5=8A=A0=E6=96=B0?= =?UTF-8?q?=E7=9A=84=E8=AE=AD=E7=BB=83=E6=95=B0=E6=8D=AE=E6=A0=87=E7=AD=BE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 在 datasets/train/labels 目录下新增了多个标签文件 - 文件命名格式为:视频ID-帧序号.jpg.rf.哈希值.txt -标签内容包括物体类别和位置信息,用于训练目标检测模型 --- test.py | 29 +++++++++++++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-) diff --git a/test.py b/test.py index f550a13..a6ee093 100644 --- a/test.py +++ b/test.py @@ -1,4 +1,29 @@ from ultralytics import YOLO +import os -model = YOLO("yolov12s.yaml") -print("Model loaded successfully!") + +def main(): + # 加载训练后的模型 + model = YOLO("runs/detect/final_model3/weights/best.pt") + + # 在验证集上评估模型性能(添加 workers=0 参数) + results2 = model.val(data="data.yaml", workers=0) + + # 推理指定图像或目录(添加 workers=0 参数) + results = model.predict( + source="datasets/test/images/3383011008094_mp4-19_jpg.rf.377dffeb92226013b2abf60eb66473a7.jpg", + imgsz=640, + conf=0.25, + save=True, + #device=0, + workers=0 # 关键参数 + ) + + # 遍历并打印预测结果 + for result in results: + print(result.names) + print(result.boxes) + + +if __name__ == '__main__': + main() # Windows必须的入口保护