25 lines
No EOL
524 B
Python
25 lines
No EOL
524 B
Python
from ultralytics import YOLO
|
|
import cv2
|
|
|
|
model = YOLO("/Users/nguyenhongvan/recongnize/runs/detect/train/weights/best.pt")
|
|
|
|
image_path = "/Users/nguyenhongvan/recongnize/data/add/image9.jpg"
|
|
|
|
results = model(image_path)
|
|
|
|
image = cv2.imread(image_path)
|
|
|
|
for box in results[0].boxes.xyxy.cpu().numpy():
|
|
x1, y1, x2, y2 = map(int, box)
|
|
|
|
cv2.rectangle(
|
|
image,
|
|
(x1, y1),
|
|
(x2, y2),
|
|
(0, 255, 0),
|
|
2
|
|
)
|
|
|
|
cv2.imshow("Bounding Boxes Only", image)
|
|
cv2.waitKey(0)
|
|
cv2.destroyAllWindows() |