afms-backend / src /test2.py
ShaikFayaz042
Added backend code: app.py, requirements.txt, models, etc.
70ebc90
Raw
History Blame Contribute Delete
891 Bytes
from ultralytics import YOLO
import cv2
# -------------------------------
# Paths (EDIT THESE)
# -------------------------------
MODEL_PATH = r"D:\Downloads\fastener_detection_run1 (1)\weights\best.pt"
IMAGE_PATH = r"C:\Users\HP\OneDrive\Desktop\screw\object_detection_dataset\test\images\screws_0430.jpg"
# -------------------------------
# Load model
# -------------------------------
model = YOLO(MODEL_PATH)
# -------------------------------
# Run inference
# -------------------------------
results = model(IMAGE_PATH, conf=0.25)
# -------------------------------
# Get annotated image
# -------------------------------
annotated_img = results[0].plot() # draws boxes, labels, confidence
# -------------------------------
# Show image in VS Code window
# -------------------------------
cv2.imshow("YOLOv8 Inference Result", annotated_img)
cv2.waitKey(0)
cv2.destroyAllWindows()