Spaces:
Sleeping
Sleeping
Delete gaussian_pipeline.py
Browse files- gaussian_pipeline.py +0 -37
gaussian_pipeline.py
DELETED
|
@@ -1,37 +0,0 @@
|
|
| 1 |
-
from spaces import GPU # Hugging Face Spaces์์ GPU ์ฌ์ฉ
|
| 2 |
-
from ultralytics import YOLO
|
| 3 |
-
import numpy as np
|
| 4 |
-
import cv2
|
| 5 |
-
import os
|
| 6 |
-
import trimesh
|
| 7 |
-
|
| 8 |
-
@GPU()
|
| 9 |
-
def reconstruct_3d_from_yolo(frames, output_dir, device="cuda"):
|
| 10 |
-
model = YOLO("yolov8n.pt") # ๊ฒฝ๋ ๋ชจ๋ธ ์ฌ์ฉ
|
| 11 |
-
|
| 12 |
-
points_3d = []
|
| 13 |
-
|
| 14 |
-
for idx, frame_path in enumerate(frames):
|
| 15 |
-
image = cv2.imread(frame_path)
|
| 16 |
-
if image is None:
|
| 17 |
-
continue
|
| 18 |
-
|
| 19 |
-
results = model(image)[0]
|
| 20 |
-
|
| 21 |
-
for box in results.boxes.xywh: # ์ค์ฌ ์ขํ (x_center, y_center, width, height)
|
| 22 |
-
x, y, w, h = box[:4].cpu().numpy()
|
| 23 |
-
z = idx * 10 # ํ๋ ์ ์์์ ๋ฐ๋ผ z๊ฐ ์ฆ๊ฐ์์ผ ๊ฐ์์ ๊น์ด ๋ถ์ฌ
|
| 24 |
-
points_3d.append([x, y, z])
|
| 25 |
-
|
| 26 |
-
if not points_3d:
|
| 27 |
-
raise ValueError("No valid YOLO 3D points were reconstructed.")
|
| 28 |
-
|
| 29 |
-
all_points = np.array(points_3d)
|
| 30 |
-
mesh = trimesh.points.PointCloud(all_points)
|
| 31 |
-
|
| 32 |
-
os.makedirs(output_dir, exist_ok=True)
|
| 33 |
-
output_model_path = os.path.join(output_dir, "yolo_3d_model.obj")
|
| 34 |
-
mesh.export(output_model_path)
|
| 35 |
-
|
| 36 |
-
return output_model_path
|
| 37 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|