Spaces:
Sleeping
Sleeping
TakashiKAWAMOTO-TTS commited on
Commit ·
dea5ada
1
Parent(s): 0f772ca
give filepath not file-object
Browse files
app.py
CHANGED
|
@@ -5,11 +5,19 @@ import matplotlib.pyplot as plt
|
|
| 5 |
import tempfile
|
| 6 |
import os
|
| 7 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 8 |
def process_point_cloud(file_obj):
|
| 9 |
# Save uploaded file temporarily
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
|
|
|
|
|
|
|
|
|
| 13 |
|
| 14 |
# Load point cloud using Open3D
|
| 15 |
pcd = o3d.io.read_point_cloud(temp_path)
|
|
@@ -42,4 +50,16 @@ iface = gr.Interface(
|
|
| 42 |
)
|
| 43 |
|
| 44 |
if __name__ == "__main__":
|
| 45 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 5 |
import tempfile
|
| 6 |
import os
|
| 7 |
|
| 8 |
+
from types import SimpleNamespace
|
| 9 |
+
|
| 10 |
+
DEBUG = False # True: skip gradio and execute in main function
|
| 11 |
+
DEBUG_LOG = True
|
| 12 |
+
|
| 13 |
def process_point_cloud(file_obj):
|
| 14 |
# Save uploaded file temporarily
|
| 15 |
+
if DEBUG:
|
| 16 |
+
temp_path = os.path.join(tempfile.gettempdir(), file_obj.name)
|
| 17 |
+
with open(temp_path, "wb") as f:
|
| 18 |
+
f.write(file_obj.read())
|
| 19 |
+
else:
|
| 20 |
+
temp_path = file_obj.name
|
| 21 |
|
| 22 |
# Load point cloud using Open3D
|
| 23 |
pcd = o3d.io.read_point_cloud(temp_path)
|
|
|
|
| 50 |
)
|
| 51 |
|
| 52 |
if __name__ == "__main__":
|
| 53 |
+
if DEBUG:
|
| 54 |
+
test_file_path = "./samples/bunny.ply"
|
| 55 |
+
with open(test_file_path, "rb") as f:
|
| 56 |
+
dummy = SimpleNamespace()
|
| 57 |
+
dummy.name = os.path.basename(test_file_path)
|
| 58 |
+
dummy.read = lambda: f.read()
|
| 59 |
+
result_img = process_point_cloud(dummy)
|
| 60 |
+
process_point_cloud(dummy)
|
| 61 |
+
out_path = os.path.join("temporal", "debug_render.png")
|
| 62 |
+
plt.imsave(out_path, result_img)
|
| 63 |
+
print(f"[DEBUG] Rendered image saved at: {out_path}")
|
| 64 |
+
else:
|
| 65 |
+
iface.launch()
|