detect.py 757 B

123456789101112131415161718
  1. import os
  2. import os
  3. from ultralytics import YOLO
  4. # model = YOLO("data.yaml")
  5. model = YOLO("runs/train-seg2/weights/last.pt")
  6. # success = model.export(format="onnx", half=False, dynamic=True, opset=17)
  7. success = model.export(format="onnx")
  8. print("export model well.")
  9. exit(1)
  10. data_file = "D:\DeepLearning\pytorch-gpu117\yolov8_study\\train-seg\data.yaml"
  11. model_file = "D:\DeepLearning\pytorch-gpu117\yolov8_study\\train-seg\yolov8-seg.yaml"
  12. model = YOLO(model_file)
  13. results = model.train(data=data_file, epochs=1000, batch=4)
  14. # ret = os.system("yolo task=detect mode=predict model=best.pt source=D:/DeepLearning/Dataset/car/car_201.jpg imgsz=640 show=True save=True")
  15. # # yolo mode=export model=best.pt format=onnx dynamic=False #simplify=True
  16. # print(ret)