|
|
|
|
|
from ultralytics import YOLO
|
|
|
import cv2
|
|
|
import os
|
|
|
|
|
|
|
|
|
model_path = 'runs/detect/train2/weights/best.pt'
|
|
|
|
|
|
if os.path.exists(model_path):
|
|
|
model = YOLO(model_path)
|
|
|
|
|
|
|
|
|
|
|
|
img_path = input("Enter image path (e.g., test/images/1.jpg): ")
|
|
|
|
|
|
if os.path.exists(img_path):
|
|
|
results = model(img_path)
|
|
|
|
|
|
for r in results:
|
|
|
im_array = r.plot()
|
|
|
cv2.imshow('Final Test', im_array)
|
|
|
cv2.waitKey(0)
|
|
|
cv2.destroyAllWindows()
|
|
|
else:
|
|
|
print("Image file nahi mili! Path check karein.")
|
|
|
else:
|
|
|
print("Model abhi tak train nahi hua. Training khatam hone ka intezar karein.") |