detect.py 1.0 KB

1234567891011121314151617181920212223
  1. import warnings
  2. warnings.filterwarnings('ignore')
  3. from ultralytics import YOLO
  4. # 推理参数官方详解链接:https://docs.ultralytics.com/modes/predict/#inference-sources:~:text=of%20Results%20objects-,Inference%20Arguments,-model.predict()
  5. if __name__ == '__main__':
  6. model = YOLO('runs/train/exp/weights/best.pt') # select your model.pt path
  7. model.predict(source='dataset/images/test',
  8. imgsz=640,
  9. project='runs/detect',
  10. name='exp',
  11. save=True,
  12. # conf=0.2,
  13. # iou=0.7,
  14. # agnostic_nms=True,
  15. # visualize=True, # visualize model features maps
  16. # line_width=2, # line width of the bounding boxes
  17. # show_conf=False, # do not show prediction confidence
  18. # show_labels=False, # do not show prediction labels
  19. # save_txt=True, # save results as .txt file
  20. # save_crop=True, # save cropped images with results
  21. )