perler commited on
Commit
045f9a3
1 Parent(s): 50919d2

uuid and minor clean-up

Browse files
Files changed (1) hide show
  1. app.py +10 -13
app.py CHANGED
@@ -23,15 +23,14 @@ def run_on_gpu(input_point_cloud: gr.utils.NamedString,
23
  type(gen_subsample_manifold_iter), type(gen_refine_iter))
24
 
25
  sys.path.append(os.path.abspath('ppsurf'))
26
- # from ppsurf.pps import cli_main
27
  import subprocess
28
- import random
29
 
30
  in_file = '{}'.format(input_point_cloud.name)
31
 
32
  # append 'rec' to the input file name
33
  # splitext_result = os.path.splitext(in_file)
34
- rand_hash = random.getrandbits(128)
35
  out_dir = '/tmp/outputs/{}'.format(rand_hash)
36
  # out_file = os.path.join(out_dir, in_file, in_file + '.ply')
37
  out_file_basename = os.path.basename(in_file) + '.ply'
@@ -56,15 +55,13 @@ def run_on_gpu(input_point_cloud: gr.utils.NamedString,
56
  ]
57
 
58
  sys.argv = args
59
- subprocess.run(['python', 'ppsurf/pps.py'] + args[1:])
60
- # cli_main()
61
  print('Finished inference at {}'.format(datetime.datetime.now()))
62
 
63
  result_3d_model = out_file
64
- output_file = out_file
65
  progress_text = 'done'
66
 
67
- return result_3d_model, output_file, progress_text
68
 
69
 
70
  def main():
@@ -155,11 +152,11 @@ def main():
155
  minimum=3, maximum=30, value=10, step=1)
156
  with gr.Column():
157
  progress_text = gr.Text(label='Progress')
158
- with gr.Tabs():
159
- with gr.TabItem(label='Reconstructed 3D model'):
160
- result_3d_model = gr.Model3D(show_label=False)
161
- with gr.TabItem(label='Output mesh file'):
162
- output_file = gr.File(show_label=False)
163
  # with gr.Row():
164
  # examples = [
165
  # ['shapes/dragon1.obj', 'a photo of a dragon', 0, 7.5],
@@ -194,7 +191,7 @@ def main():
194
  ],
195
  outputs=[
196
  result_3d_model,
197
- output_file,
198
  progress_text,
199
  ])
200
 
 
23
  type(gen_subsample_manifold_iter), type(gen_refine_iter))
24
 
25
  sys.path.append(os.path.abspath('ppsurf'))
 
26
  import subprocess
27
+ import uuid
28
 
29
  in_file = '{}'.format(input_point_cloud.name)
30
 
31
  # append 'rec' to the input file name
32
  # splitext_result = os.path.splitext(in_file)
33
+ rand_hash = uuid.uuid4().hex
34
  out_dir = '/tmp/outputs/{}'.format(rand_hash)
35
  # out_file = os.path.join(out_dir, in_file, in_file + '.ply')
36
  out_file_basename = os.path.basename(in_file) + '.ply'
 
55
  ]
56
 
57
  sys.argv = args
58
+ subprocess.run(['python', 'ppsurf/pps.py'] + args[1:]) # need subprocess to spawn workers
 
59
  print('Finished inference at {}'.format(datetime.datetime.now()))
60
 
61
  result_3d_model = out_file
 
62
  progress_text = 'done'
63
 
64
+ return result_3d_model, progress_text
65
 
66
 
67
  def main():
 
152
  minimum=3, maximum=30, value=10, step=1)
153
  with gr.Column():
154
  progress_text = gr.Text(label='Progress')
155
+ # with gr.Tabs():
156
+ # with gr.TabItem(label='Reconstructed 3D model'):
157
+ result_3d_model = gr.Model3D(show_label=False)
158
+ # with gr.TabItem(label='Output mesh file'):
159
+ # output_file = gr.File(show_label=False)
160
  # with gr.Row():
161
  # examples = [
162
  # ['shapes/dragon1.obj', 'a photo of a dragon', 0, 7.5],
 
191
  ],
192
  outputs=[
193
  result_3d_model,
194
+ # output_file,
195
  progress_text,
196
  ])
197