Safemotion Lib
Loading...
Searching...
No Matches
smdetect
runner
yolov8_runner.py
Go to the documentation of this file.
1
from
ultralytics
import
YOLO
2
3
class
YoloV8Runner
(object):
4
"""
5
YOLO 모델을 동작시키기 위한 클래스
6
args:
7
checkpoint (str): 모델 파라미터 저장 경로, engine 파일(TensorRT 모델) 또는 pt 파일(torch 모델)
8
kwargs (str): 모델 동작을 위한 기타 파라미터
9
"""
10
def
__init__
(self, checkpoint, **kwargs):
11
self.
model
= YOLO(checkpoint)
12
self.
kwargs
= kwargs
13
14
def
run_detector
(self, image):
15
"""
16
객체 검출기를 동작시키는 기능
17
args:
18
image (np.ndarray): RGB? BGR? 이미지
19
"""
20
21
results = self.
model
.predict(source=image, **self.
kwargs
)
22
23
data = {}
24
data[
'det_bboxes'
] = results[0].boxes.data.cpu()[:, :5]
25
data[
'det_labels'
] = results[0].boxes.cls.cpu()
26
27
return
data
28
yolov8_runner.YoloV8Runner
Definition
yolov8_runner.py:3
yolov8_runner.YoloV8Runner.model
model
Definition
yolov8_runner.py:11
yolov8_runner.YoloV8Runner.__init__
__init__(self, checkpoint, **kwargs)
Definition
yolov8_runner.py:10
yolov8_runner.YoloV8Runner.kwargs
kwargs
Definition
yolov8_runner.py:12
yolov8_runner.YoloV8Runner.run_detector
run_detector(self, image)
Definition
yolov8_runner.py:14
Generated by
1.10.0