Views
No views yet

1# Load libraries
2import cv2
3from ultralytics import YOLO
4from pathlib import Path
5import matplotlib.pyplot as plt
6from huggingface_hub import hf_hub_download
7
8
9# Download model
10model_path = hf_hub_download(repo_id="Daniil-Domino/yolo11x-dialectic", filename="model.pt")
11
12# Load model
13model = YOLO(model_path)
14
15# Inference
16image_path = "/path/to/image"
17image = cv2.imread(image_path).copy()
18output = model.predict(image, conf=0.3)
19
20# Draw bounding boxes
21out_image = cv2.cvtColor(image, cv2.COLOR_BGR2RGB)
22for data in output[0].boxes.data.tolist():
23 xmin, ymin, xmax, ymax, _, _ = map(int, data)
24 cv2.rectangle(out_image, (xmin, ymin), (xmax, ymax), color=(0, 0, 255), thickness=3)
25
26# Display result
27plt.figure(figsize=(15, 10))
28plt.imshow(out_image)
29plt.axis('off')
30plt.show()
31