shin0624 commited on
Commit
ad79e29
ยท
verified ยท
1 Parent(s): 7eed2c3

Update detector/yolo_pipeline.py

Browse files
Files changed (1) hide show
  1. detector/yolo_pipeline.py +9 -9
detector/yolo_pipeline.py CHANGED
@@ -1,4 +1,3 @@
1
- from spaces import GPU
2
  import os
3
  import cv2
4
  import numpy as np
@@ -6,8 +5,7 @@ import trimesh
6
  from ultralytics import YOLO
7
  from utils.pointcloud_tools import PointCloudProcessor
8
 
9
-
10
- # ์ „์—ญ ๋ชจ๋ธ ์ธ์Šคํ„ด์Šค ์ดˆ๊ธฐํ™”
11
  _MODEL = None
12
 
13
  def get_yolo_model():
@@ -21,11 +19,13 @@ class YOLO3DReconstructor:
21
  self.model = get_yolo_model()
22
  self.class_mapping = {
23
  0: 'person',
24
- 7: 'forklift',
25
- 63: 'conveyor'
 
 
26
  }
27
- # GPU ํ™˜๊ฒฝ์—์„œ ์‹คํ–‰
28
- @GPU()
29
  def process_frames(self, frame_paths):
30
  point_cloud = []
31
  detections = {v: 0 for v in self.class_mapping.values()}
@@ -38,7 +38,7 @@ class YOLO3DReconstructor:
38
  results = self.model(img)[0]
39
 
40
  # ๊ฐ์ง€ ๊ฒฐ๊ณผ๊ฐ€ ์—†๋Š” ๊ฒฝ์šฐ ๊ฑด๋„ˆ๋›ฐ๊ธฐ
41
- if results.boxes.xywh.numel() == 0 or results.boxes.cls.numel() == 0:
42
  continue
43
 
44
  boxes_xywh = results.boxes.xywh.cpu().numpy()
@@ -60,4 +60,4 @@ class YOLO3DReconstructor:
60
  points = PointCloudProcessor.filter_outliers(points)
61
  points = PointCloudProcessor.normalize_points(points)
62
 
63
- return (trimesh.points.PointCloud(points), detections)
 
 
1
  import os
2
  import cv2
3
  import numpy as np
 
5
  from ultralytics import YOLO
6
  from utils.pointcloud_tools import PointCloudProcessor
7
 
8
+ # YOLO ๋ชจ๋ธ ์ธ์Šคํ„ด์Šค ์ดˆ๊ธฐํ™”
 
9
  _MODEL = None
10
 
11
  def get_yolo_model():
 
19
  self.model = get_yolo_model()
20
  self.class_mapping = {
21
  0: 'person',
22
+ 7: 'truck', # ํŠธ๋Ÿญ์ด ํฌํฌ๋ฆฌํ”„ํŠธ์— ๊ฐ€์žฅ ๊ฐ€๊นŒ์šด COCO ํด๋ž˜์Šค
23
+ 24: 'backpack', # ๊ธฐํƒ€ ๊ณต์žฅ ์žฅ๋น„๋กœ ํ™œ์šฉ ๊ฐ€๋Šฅํ•œ ๋Œ€์ฒด ํด๋ž˜์Šค
24
+ 41: 'cup', # ๊ธฐํƒ€ ๊ณต์žฅ ์žฅ๋น„๋กœ ํ™œ์šฉ ๊ฐ€๋Šฅํ•œ ๋Œ€์ฒด ํด๋ž˜์Šค
25
+ 73: 'laptop' # ๊ธฐํƒ€ ๊ณต์žฅ ์žฅ๋น„๋กœ ํ™œ์šฉ ๊ฐ€๋Šฅํ•œ ๋Œ€์ฒด ํด๋ž˜์Šค
26
  }
27
+ # ์›๋ณธ ์ฝ”๋“œ์˜ 'forklift'์™€ 'conveyor' ํด๋ž˜์Šค๊ฐ€ COCO ๋ฐ์ดํ„ฐ์…‹์— ์—†์–ด์„œ ์œ ์‚ฌํ•œ ํด๋ž˜์Šค๋กœ ๋Œ€์ฒด
28
+ @GPU
29
  def process_frames(self, frame_paths):
30
  point_cloud = []
31
  detections = {v: 0 for v in self.class_mapping.values()}
 
38
  results = self.model(img)[0]
39
 
40
  # ๊ฐ์ง€ ๊ฒฐ๊ณผ๊ฐ€ ์—†๋Š” ๊ฒฝ์šฐ ๊ฑด๋„ˆ๋›ฐ๊ธฐ
41
+ if len(results.boxes) == 0:
42
  continue
43
 
44
  boxes_xywh = results.boxes.xywh.cpu().numpy()
 
60
  points = PointCloudProcessor.filter_outliers(points)
61
  points = PointCloudProcessor.normalize_points(points)
62
 
63
+ return (trimesh.points.PointCloud(points), detections)