shin0624 commited on
Commit
2ff7c61
·
verified ·
1 Parent(s): 83fa021

yolo추론 스크립트

Browse files
Files changed (1) hide show
  1. detect.py +6 -6
detect.py CHANGED
@@ -1,18 +1,18 @@
1
  from ultralytics import YOLO
2
  import cv2
3
 
4
- # 감지할 클래스 매핑 (YOLO COCO 클래스 기준)
5
  TARGET_CLASSES = {
6
  0: 'person',
7
- 2: 'car', # forklift 대체 (fine-tuned 모델에서 forklift 사용 가능)
8
- 39: 'screwdriver', # machine 임시 대체
9
- 67: 'cell phone' # conveyor belt 임시 대체
10
  }
11
 
12
  def run_detection(image, model):
13
  results = model(image)[0]
14
  detections = []
15
-
16
  for box in results.boxes:
17
  cls_id = int(box.cls.item())
18
  if cls_id in TARGET_CLASSES:
@@ -20,4 +20,4 @@ def run_detection(image, model):
20
  x, y = box.xywh[0][:2].tolist()
21
  detections.append((name, (x, y)))
22
 
23
- return detections
 
1
  from ultralytics import YOLO
2
  import cv2
3
 
4
+ # 클래스 매핑 (YOLOv8 COCO 기준)
5
  TARGET_CLASSES = {
6
  0: 'person',
7
+ 2: 'forklift', # car로 대체 (fine-tune 필요)
8
+ 39: 'machine', # screwdriver → 기계 대체
9
+ 67: 'conveyor_belt' # cell phone → 벨트 대체
10
  }
11
 
12
  def run_detection(image, model):
13
  results = model(image)[0]
14
  detections = []
15
+
16
  for box in results.boxes:
17
  cls_id = int(box.cls.item())
18
  if cls_id in TARGET_CLASSES:
 
20
  x, y = box.xywh[0][:2].tolist()
21
  detections.append((name, (x, y)))
22
 
23
+ return detections