Isolators-Detection/test.py
fly6516 c33f35d0de feat(Isolators-Detection): 添加训练和验证集标签
- 在 train/labels 和 valid/labels目录下添加了多个标签文件
- 标签文件包含物体检测的坐标信息
- 此次添加的标签主要用于绝缘子检测任务
2025-03-25 10:26:19 +08:00

15 lines
544 B
Python
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

from ultralytics import YOLO
def main():
# 加载训练好的最佳模型假设保存在runs/detect/cable_detection/下)
model = YOLO("runs/detect/cable_detection35/weights/best.pt")
# 在验证集上评估模型性能
results = model.val(data="data.yaml")
# 对测试图像进行预测示例(选择第一张测试图片)
# 需要确保测试图片路径与data.yaml中的test路径一致
results = model.predict(source="../test/images/1.jpg", save=True, show=True)
if __name__ == "__main__":
main()