-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.py
More file actions
26 lines (20 loc) · 696 Bytes
/
Copy pathtest.py
File metadata and controls
26 lines (20 loc) · 696 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
from ultralytics import YOLO
import cv2
# Load your trained model
model = YOLO("tsr_yolo26n.pt")
# Path to the image you want to test
image_path = "test_images/testing.jpg" # Change this to your test image
# Read and resize image to 640x640
image = cv2.imread(image_path)
image_resized = cv2.resize(image, (640, 640))
# Run prediction on resized image
results = model.predict(image_resized, conf=0.2,iou=0.5, agnostic_nms=True, max_det=1000)
# Show results
for result in results:
boxes = result.boxes
if len(boxes) == 0:
print("No Traffic Sign detected.")
else:
print(f"Detected {len(boxes)} Traffic Signs.")
# Show image with detections
result.show()