perler commited on
Commit
3d5c410
1 Parent(s): d19c7d3

maybe fixes for converting input

Browse files
Files changed (1) hide show
  1. app.py +15 -15
app.py CHANGED
@@ -31,7 +31,8 @@ def run_on_gpu(input_point_cloud_viewer,
31
  '--gen_subsample_manifold_iter', str(gen_subsample_manifold_iter),
32
  '--gen_refine_iter', str(gen_refine_iter),
33
  ]
34
- res = subprocess.check_output(call_base + call_args)
 
35
  print('Finished inference at {}'.format(datetime.datetime.now()))
36
 
37
  return res
@@ -53,20 +54,18 @@ def main():
53
  Inference takes about 2 minutes.
54
  '''
55
 
56
- def convert_to_ply(input_point_cloud_upload: str):
57
 
58
  # add absolute path to import dirs
59
  import sys
60
  import os
61
  sys.path.append(os.path.abspath('ppsurf'))
62
 
63
- print('before\n', subprocess.check_output('ls'))
64
  import os
65
  os.chdir('ppsurf')
66
- print('after\n', subprocess.check_output('ls'))
67
 
68
  print('Inputs:', input_point_cloud_upload)
69
- input_shape = input_point_cloud_upload
70
  if not input_shape.endswith('.ply'):
71
  # load file
72
  from ppsurf.source.occupancy_data_module import OccupancyDataModule
@@ -78,6 +77,8 @@ def main():
78
  input_shape = input_shape + '.ply'
79
  mesh.export(input_shape)
80
 
 
 
81
  # show in viewer
82
  print(input_tabs)
83
  print(input_point_cloud_viewer)
@@ -99,14 +100,14 @@ def main():
99
  with gr.TabItem(label='Input Point Cloud Upload', id='pc_upload'):
100
  input_point_cloud_upload = gr.File(
101
  show_label=False, file_count='single')
102
- input_point_cloud_upload.upload(fn=convert_to_ply,
103
- inputs=[
104
- input_point_cloud_upload,
105
- ],
106
- outputs=[
107
- # input_point_cloud_viewer, # not available here
108
- ])
109
- # input_point_cloud_upload.attach_load_event(convert_to_ply, every=None)
110
  with gr.TabItem(label='Input Point Cloud Viewer', id='pc_viewer'):
111
  input_point_cloud_viewer = gr.Model3D(show_label=False)
112
  gen_resolution_global = gr.Slider(
@@ -121,7 +122,6 @@ def main():
121
  gen_refine_iter = gr.Slider(
122
  label='Edge Refinement Iterations (larger for more details)',
123
  minimum=3, maximum=30, value=10, step=1)
124
- # run_button = gr.Button('Run')
125
  with gr.Column():
126
  progress_text = gr.Text(label='Progress')
127
  with gr.Tabs():
@@ -151,7 +151,7 @@ def main():
151
  # cache_examples=False)
152
 
153
  with gr.Row():
154
- run_button = gr.Button('=> Run PPSurf =>')
155
 
156
  run_button.click(fn=run_on_gpu,
157
  inputs=[
 
31
  '--gen_subsample_manifold_iter', str(gen_subsample_manifold_iter),
32
  '--gen_refine_iter', str(gen_refine_iter),
33
  ]
34
+ # res = subprocess.check_output(call_base + call_args)
35
+ res = subprocess.run(call_base + call_args)
36
  print('Finished inference at {}'.format(datetime.datetime.now()))
37
 
38
  return res
 
54
  Inference takes about 2 minutes.
55
  '''
56
 
57
+ def convert_to_ply(): # input_point_cloud_upload: str):
58
 
59
  # add absolute path to import dirs
60
  import sys
61
  import os
62
  sys.path.append(os.path.abspath('ppsurf'))
63
 
 
64
  import os
65
  os.chdir('ppsurf')
 
66
 
67
  print('Inputs:', input_point_cloud_upload)
68
+ input_shape = str(input_point_cloud_upload)
69
  if not input_shape.endswith('.ply'):
70
  # load file
71
  from ppsurf.source.occupancy_data_module import OccupancyDataModule
 
77
  input_shape = input_shape + '.ply'
78
  mesh.export(input_shape)
79
 
80
+ print('ls\n', subprocess.check_output(['ls', os.path.dirname(input_shape)]))
81
+
82
  # show in viewer
83
  print(input_tabs)
84
  print(input_point_cloud_viewer)
 
100
  with gr.TabItem(label='Input Point Cloud Upload', id='pc_upload'):
101
  input_point_cloud_upload = gr.File(
102
  show_label=False, file_count='single')
103
+ input_point_cloud_upload.upload(
104
+ fn=convert_to_ply,
105
+ inputs=[
106
+ # input_point_cloud_upload,
107
+ ],
108
+ outputs=[
109
+ # input_point_cloud_viewer, # not available here
110
+ ])
111
  with gr.TabItem(label='Input Point Cloud Viewer', id='pc_viewer'):
112
  input_point_cloud_viewer = gr.Model3D(show_label=False)
113
  gen_resolution_global = gr.Slider(
 
122
  gen_refine_iter = gr.Slider(
123
  label='Edge Refinement Iterations (larger for more details)',
124
  minimum=3, maximum=30, value=10, step=1)
 
125
  with gr.Column():
126
  progress_text = gr.Text(label='Progress')
127
  with gr.Tabs():
 
151
  # cache_examples=False)
152
 
153
  with gr.Row():
154
+ run_button = gr.Button('Reconstruct with PPSurf')
155
 
156
  run_button.click(fn=run_on_gpu,
157
  inputs=[