test_model.py 470 B

123456789101112
  1. from ultralytics import YOLO
  2. import cv2
  3. # 1. Load your newly trained model
  4. model = YOLO('best.pt')
  5. # 2. Run prediction on an image from your 'test' folder
  6. # Change 'path/to/your/test/image.jpg' to a real path
  7. results = model.predict(source='datasets/test/images/TestRipe-1-_jpg.rf.1d329242e7510efbc0c6a2c94bc43edb.jpg', save=True, conf=0.5)
  8. # 3. Check your 'runs/detect/predict' folder for the result image!
  9. print("Check runs/detect/predict for the annotated image.")