Updates
This commit is contained in:
@@ -1,11 +1,14 @@
|
||||
from ultralytics import YOLO
|
||||
from paths import * # make sure model_path is defined here
|
||||
import cv2
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
||||
corner_model_path = "../assets/models/corner.pt"
|
||||
pieces_model_path = "../assets/models/unified-nano-refined.pt"
|
||||
|
||||
print("Initializing model...")
|
||||
model = YOLO(model_path)
|
||||
corner_model = YOLO(corner_model_path)
|
||||
pieces_model = YOLO(pieces_model_path)
|
||||
|
||||
print("Initializing camera...")
|
||||
cap = cv2.VideoCapture(0)
|
||||
@@ -29,11 +32,13 @@ if __name__ == "__main__":
|
||||
# Optional: resize frame to improve YOLO performance
|
||||
# frame = cv2.resize(frame, (416, 416))
|
||||
|
||||
results = model.predict(source=frame, conf=0.5)
|
||||
corner_result = corner_model.predict(source=frame, conf=0.6)
|
||||
pieces_result = pieces_model.predict(source=frame, conf=0.6)
|
||||
|
||||
annotated_frame = results[0].plot() # annotated frame as NumPy array
|
||||
corner_annotated_frame = corner_result[0].plot()
|
||||
pieces_annotated_frame = pieces_result[0].plot(img=corner_annotated_frame)
|
||||
|
||||
cv2.imshow("Predictions", annotated_frame)
|
||||
cv2.imshow("Predictions", pieces_annotated_frame)
|
||||
cv2.resizeWindow("Predictions", 640, 640)
|
||||
if cv2.waitKey(1) & 0xFF == ord('q'):
|
||||
break
|
||||
|
||||
Reference in New Issue
Block a user