Views
No views yet
pip install git+https://github.com/nazarkohut/tomato_ripeness_enhancement.gitbest_yolov8_ghost_qwa.pt from this repository. You can also download an example image for inference, or use your own.
1from ultralytics import YOLO
2import matplotlib.pyplot as plt
3
4image_path = "/path/to/local/image.png"
5yolov8_ghost_qwa = YOLO("models/best_yolov8_ghost_qwa.pt")
6results = yolov8_ghost_qwa.predict(image_path, conf=0.4, verbose=False)
7annotated_bgr = results[0].plot(boxes=True)
8annotated_rgb = annotated_bgr[:, :, ::-1] # flip channels
9
10plt.figure(figsize=(10,6))
11plt.axis("off")
12plt.imshow(annotated_rgb)
13plt.show()1import cv2
2from ultralytics import YOLO
3
4model = YOLO("models/best_yolov8_ghost_qwa.pt")
5
6image_path = "/path/to/local/image.png"
7img_bgr = cv2.imread(image_path)
8results = model.predict(source=img_bgr, conf=0.25, verbose=False)
9annotated_bgr = results[0].plot(boxes=True)
10annotated_rgb = annotated_bgr[:, :, ::-1]
11
12plt.imshow(annotated_rgb)
13plt.axis("off")
14plt.show()
15print("boxes:", len(results[0].boxes))