Isolators-Detection/test.py

15 lines
544 B
Python
Raw Normal View History

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()