Views
No views yet
1from ultralytics import YOLO
2import cv2
3# Download the model file from Link, mentioned in "Model Files" Section.
4# Load trained model
5model = YOLO("weapon_detector.pt")
6
7# Load image
8image_path = "test.jpg"
9img = cv2.imread(image_path)
10
11# Run detection
12results = model(image_path)
13
14# Show results
15results[0].show()
16
17# Optional: save output image
18results[0].save("output.jpg")
19
20