-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathyolo_inference.py
More file actions
69 lines (49 loc) · 1.72 KB
/
Copy pathyolo_inference.py
File metadata and controls
69 lines (49 loc) · 1.72 KB
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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
"""
YOLOv11 Real-time Inference
Webcam'den canlı işaret tanıma
"""
from ultralytics import YOLO
import cv2
def run_inference(model_path='yolo_runs/turk_isaret_v1/weights/best.pt'):
"""Webcam'den real-time inference"""
print("=" * 70)
print("YOLOv11 - REAL-TIME İŞARET TANIMA")
print("=" * 70)
# Model yükle
print(f"\n📦 Model yükleniyor: {model_path}")
model = YOLO(model_path)
# Class names
class_names = model.names
print(f"🎯 Sınıflar ({len(class_names)}): {list(class_names.values())[:5]}...")
print("\n🎥 Kamera açılıyor...")
print("Kontroller: Q veya ESC - Çıkış\n")
print("=" * 70 + "\n")
# Kamera aç
cap = cv2.VideoCapture(0)
cap.set(cv2.CAP_PROP_FRAME_WIDTH, 1280)
cap.set(cv2.CAP_PROP_FRAME_HEIGHT, 720)
if not cap.isOpened():
print("❌ Kamera açılamadı!")
return
while cap.isOpened():
ret, frame = cap.read()
if not ret:
break
frame = cv2.flip(frame, 1)
# YOLO inference
results = model(frame, conf=0.5, verbose=False)
# Sonuçları çiz
annotated_frame = results[0].plot()
# FPS göster
cv2.putText(annotated_frame, "Q/ESC: Quit", (10, 30),
cv2.FONT_HERSHEY_SIMPLEX, 0.7, (0, 255, 0), 2)
cv2.imshow('YOLOv11 - Turk Isaret Dili', annotated_frame)
# Çıkış
key = cv2.waitKey(1) & 0xFF
if key == ord('q') or key == ord('Q') or key == 27:
break
cap.release()
cv2.destroyAllWindows()
print("\n✅ Inference tamamlandı!")
if __name__ == "__main__":
run_inference()