Update pipeline.py
Browse files- pipeline.py +10 -0
pipeline.py
CHANGED
@@ -2,6 +2,7 @@ from ultralytics import YOLO
|
|
2 |
from PIL import Image
|
3 |
import numpy as np
|
4 |
import cv2 as cv
|
|
|
5 |
|
6 |
|
7 |
class detectPipeline():
|
@@ -21,6 +22,7 @@ class detectPipeline():
|
|
21 |
for sign in detections.boxes.data.tolist():
|
22 |
x1, y1, x2, y2, score, class_id = sign
|
23 |
sign_detections.append([int(x1), int(y1), int(x2), int(y2), score, int(class_id)])
|
|
|
24 |
return sign_detections
|
25 |
|
26 |
def drawDetections2Image(self, img_path, detections):
|
@@ -33,3 +35,11 @@ class detectPipeline():
|
|
33 |
color=(0, 0, 255), lineType=cv.LINE_AA, thickness=10)
|
34 |
img_detections = np.array(img)
|
35 |
return img_detections
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2 |
from PIL import Image
|
3 |
import numpy as np
|
4 |
import cv2 as cv
|
5 |
+
import pandas as pd
|
6 |
|
7 |
|
8 |
class detectPipeline():
|
|
|
22 |
for sign in detections.boxes.data.tolist():
|
23 |
x1, y1, x2, y2, score, class_id = sign
|
24 |
sign_detections.append([int(x1), int(y1), int(x2), int(y2), score, int(class_id)])
|
25 |
+
print(sign_detections)
|
26 |
return sign_detections
|
27 |
|
28 |
def drawDetections2Image(self, img_path, detections):
|
|
|
35 |
color=(0, 0, 255), lineType=cv.LINE_AA, thickness=10)
|
36 |
img_detections = np.array(img)
|
37 |
return img_detections
|
38 |
+
|
39 |
+
# get sign_detetction
|
40 |
+
def extractTextResults(self, detections):
|
41 |
+
text_results = ''
|
42 |
+
for bbox in detections:
|
43 |
+
x1, y1, x2, y2, score, class_id = bbox
|
44 |
+
text_results += f'{self.class_names[class_id]} : {score}\n'
|
45 |
+
return text_results
|