Spaces:
Runtime error
Runtime error
apparently can't render point clouds anyway, go right to reconstruction
Browse files
app.py
CHANGED
@@ -11,18 +11,22 @@ import spaces
|
|
11 |
|
12 |
|
13 |
@spaces.GPU(duration=60 * 3)
|
14 |
-
def run_on_gpu(
|
15 |
gen_resolution_global,
|
16 |
padding_factor,
|
17 |
gen_subsample_manifold_iter,
|
18 |
gen_refine_iter):
|
19 |
print('Started inference at {}'.format(datetime.datetime.now()))
|
|
|
|
|
|
|
|
|
20 |
|
21 |
import os
|
22 |
os.chdir(os.path.dirname('./ppsurf'))
|
23 |
|
24 |
-
in_file = 'data/{}'.format(
|
25 |
-
out_file = 'results/rec/{}'.format(
|
26 |
|
27 |
call_base = ['python', 'pps.py', 'rec']
|
28 |
call_args = [in_file,
|
@@ -58,36 +62,36 @@ def main():
|
|
58 |
Inference takes about 2 minutes.
|
59 |
'''
|
60 |
|
61 |
-
def convert_to_ply(input_point_cloud_upload: gr.utils.NamedString):
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
|
92 |
if (SPACE_ID := os.getenv('SPACE_ID')) is not None:
|
93 |
description += (f'\n<p>For faster inference without waiting in queue, '
|
@@ -100,20 +104,19 @@ def main():
|
|
100 |
gr.Markdown(description)
|
101 |
with gr.Row():
|
102 |
with gr.Column():
|
103 |
-
with gr.Tabs() as input_tabs:
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
input_point_cloud_viewer = gr.Model3D(show_label=False)
|
117 |
gen_resolution_global = gr.Slider(
|
118 |
label='Grid Resolution (larger for more details)',
|
119 |
minimum=17, maximum=513, value=129, step=2)
|
@@ -159,7 +162,7 @@ def main():
|
|
159 |
|
160 |
run_button.click(fn=run_on_gpu,
|
161 |
inputs=[
|
162 |
-
|
163 |
gen_resolution_global,
|
164 |
padding_factor,
|
165 |
gen_subsample_manifold_iter,
|
|
|
11 |
|
12 |
|
13 |
@spaces.GPU(duration=60 * 3)
|
14 |
+
def run_on_gpu(input_point_cloud: gr.utils.NamedString,
|
15 |
gen_resolution_global,
|
16 |
padding_factor,
|
17 |
gen_subsample_manifold_iter,
|
18 |
gen_refine_iter):
|
19 |
print('Started inference at {}'.format(datetime.datetime.now()))
|
20 |
+
print('Inputs:', input_point_cloud, gen_resolution_global, padding_factor,
|
21 |
+
gen_subsample_manifold_iter, gen_refine_iter)
|
22 |
+
print('Types:', type(input_point_cloud), type(gen_resolution_global), type(padding_factor),
|
23 |
+
type(gen_subsample_manifold_iter), type(gen_refine_iter))
|
24 |
|
25 |
import os
|
26 |
os.chdir(os.path.dirname('./ppsurf'))
|
27 |
|
28 |
+
in_file = 'data/{}'.format(input_point_cloud.name)
|
29 |
+
out_file = 'results/rec/{}'.format(input_point_cloud.name)
|
30 |
|
31 |
call_base = ['python', 'pps.py', 'rec']
|
32 |
call_args = [in_file,
|
|
|
62 |
Inference takes about 2 minutes.
|
63 |
'''
|
64 |
|
65 |
+
# def convert_to_ply(input_point_cloud_upload: gr.utils.NamedString):
|
66 |
+
#
|
67 |
+
# # add absolute path to import dirs
|
68 |
+
# import sys
|
69 |
+
# import os
|
70 |
+
# sys.path.append(os.path.abspath('ppsurf'))
|
71 |
+
#
|
72 |
+
# # import os
|
73 |
+
# # os.chdir('ppsurf')
|
74 |
+
#
|
75 |
+
# print('Inputs:', input_point_cloud_upload, type(input_point_cloud_upload))
|
76 |
+
# input_shape: str = input_point_cloud_upload.name
|
77 |
+
# if not input_shape.endswith('.ply'):
|
78 |
+
# # load file
|
79 |
+
# from ppsurf.source.occupancy_data_module import OccupancyDataModule
|
80 |
+
# pts_np = OccupancyDataModule.load_pts(input_shape)
|
81 |
+
#
|
82 |
+
# # convert to ply
|
83 |
+
# import trimesh
|
84 |
+
# mesh = trimesh.Trimesh(vertices=pts_np[:, :3])
|
85 |
+
# input_shape = input_shape + '.ply'
|
86 |
+
# mesh.export(input_shape)
|
87 |
+
#
|
88 |
+
# print('ls:\n', subprocess.run(['ls', os.path.dirname(input_shape)]))
|
89 |
+
#
|
90 |
+
# # show in viewer
|
91 |
+
# print(type(input_tabs))
|
92 |
+
# # print(type(input_point_cloud_viewer))
|
93 |
+
# # input_tabs.selected = 'pc_viewer'
|
94 |
+
# # input_point_cloud_viewer.value = input_shape
|
95 |
|
96 |
if (SPACE_ID := os.getenv('SPACE_ID')) is not None:
|
97 |
description += (f'\n<p>For faster inference without waiting in queue, '
|
|
|
104 |
gr.Markdown(description)
|
105 |
with gr.Row():
|
106 |
with gr.Column():
|
107 |
+
# with gr.Tabs() as input_tabs:
|
108 |
+
# with gr.TabItem(label='Input Point Cloud Upload', id='pc_upload'):
|
109 |
+
input_point_cloud_upload = gr.File(show_label=False, file_count='single')
|
110 |
+
# input_point_cloud_upload.upload(
|
111 |
+
# fn=convert_to_ply,
|
112 |
+
# inputs=[
|
113 |
+
# input_point_cloud_upload,
|
114 |
+
# ],
|
115 |
+
# outputs=[
|
116 |
+
# # input_point_cloud_viewer, # not available here
|
117 |
+
# ])
|
118 |
+
# with gr.TabItem(label='Input Point Cloud Viewer', id='pc_viewer'):
|
119 |
+
# input_point_cloud_viewer = gr.Model3D(show_label=False)
|
|
|
120 |
gen_resolution_global = gr.Slider(
|
121 |
label='Grid Resolution (larger for more details)',
|
122 |
minimum=17, maximum=513, value=129, step=2)
|
|
|
162 |
|
163 |
run_button.click(fn=run_on_gpu,
|
164 |
inputs=[
|
165 |
+
input_point_cloud_upload,
|
166 |
gen_resolution_global,
|
167 |
padding_factor,
|
168 |
gen_subsample_manifold_iter,
|