filapro commited on
Commit
420f5d5
1 Parent(s): 2c6473b

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +46 -48
app.py CHANGED
@@ -154,7 +154,6 @@ def py_string_to_mesh_file_safe(py_string, mesh_path):
154
  raise RuntimeError(queue.get())
155
 
156
 
157
- @spaces.GPU(duration=20)
158
  def run_gpu(model, input_ids, attention_mask, point_cloud, pad_token_id):
159
  if torch.cuda.is_available():
160
  model = model.cuda()
@@ -201,6 +200,7 @@ def run_test(in_mesh_path, seed, results):
201
  results.append(out_mesh_path)
202
 
203
 
 
204
  def run_test_safe(in_mesh_path, seed):
205
  results, log = list(), str()
206
  try:
@@ -210,53 +210,51 @@ def run_test_safe(in_mesh_path, seed):
210
  return results + [None] * (3 - len(results)) + [log]
211
 
212
 
213
- def run():
214
- with gr.Blocks() as demo:
215
- with gr.Row():
216
- gr.Markdown('## CAD-Recode Demo\n'
217
- 'Upload mesh or select from examples and press Run! Mesh ⇾ 256 points ⇾ Python code by CAD-Recode ⇾ CAD model.')
218
-
219
- with gr.Row(equal_height=True):
220
- in_model = gr.Model3D(label='1. Input Mesh', interactive=True)
221
- point_model = gr.Model3D(label='2. Sampled Point Cloud', display_mode='point_cloud', interactive=False)
222
- out_model = gr.Model3D(
223
- label='4. Result CAD Model', interactive=False
224
- )
225
-
226
- with gr.Row():
227
- with gr.Column():
228
- with gr.Row():
229
- seed_slider = gr.Slider(label='Random Seed', value=42, interactive=True)
230
- with gr.Row():
231
- _ = gr.Examples(
232
- examples=[
233
- ['./data/49215_5368e45e_0000.stl', 42],
234
- ['./data/00882236.stl', 6],
235
- ['./data/User Library-engrenage.stl', 18],
236
- ['./data/00010900.stl', 42],
237
- ['./data/21492_8bd34fc1_0008.stl', 42],
238
- ['./data/00375556.stl', 96],
239
- ['./data/49121_adb01620_0000.stl', 42]],
240
- example_labels=[
241
- 'fusion360_table1', 'deepcad_star', 'cc3d_gear', 'deepcad_barrels',
242
- 'fusion360_gear', 'deepcad_house', 'fusion360_table2'],
243
- inputs=[in_model, seed_slider],
244
- cache_examples=False)
245
- with gr.Row():
246
- run_button = gr.Button('Run')
247
- _ = gr.LoginButton()
248
-
249
- with gr.Column():
250
- out_code = gr.Code(language='python', label='3. Generated Python Code', wrap_lines=True, interactive=False)
251
-
252
- with gr.Column():
253
- log_textbox = gr.Textbox(label='Log', placeholder='Status: OK', interactive=False)
254
-
255
- run_button.click(
256
- run_test_safe, inputs=[in_model, seed_slider], outputs=[point_model, out_code, out_model, log_textbox])
257
 
258
- demo.launch()
259
 
 
 
 
 
260
 
261
- os.environ['TOKENIZERS_PARALLELISM'] = 'False'
262
- run()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
154
  raise RuntimeError(queue.get())
155
 
156
 
 
157
  def run_gpu(model, input_ids, attention_mask, point_cloud, pad_token_id):
158
  if torch.cuda.is_available():
159
  model = model.cuda()
 
200
  results.append(out_mesh_path)
201
 
202
 
203
+ @spaces.GPU(duration=20)
204
  def run_test_safe(in_mesh_path, seed):
205
  results, log = list(), str()
206
  try:
 
210
  return results + [None] * (3 - len(results)) + [log]
211
 
212
 
213
+ os.environ['TOKENIZERS_PARALLELISM'] = 'False'
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
214
 
 
215
 
216
+ with gr.Blocks() as demo:
217
+ with gr.Row():
218
+ gr.Markdown('## CAD-Recode Demo\n'
219
+ 'Upload mesh or select from examples and press Run! Mesh ⇾ 256 points ⇾ Python code by CAD-Recode ⇾ CAD model.')
220
 
221
+ with gr.Row(equal_height=True):
222
+ in_model = gr.Model3D(label='1. Input Mesh', interactive=True)
223
+ point_model = gr.Model3D(label='2. Sampled Point Cloud', display_mode='point_cloud', interactive=False)
224
+ out_model = gr.Model3D(
225
+ label='4. Result CAD Model', interactive=False
226
+ )
227
+
228
+ with gr.Row():
229
+ with gr.Column():
230
+ with gr.Row():
231
+ seed_slider = gr.Slider(label='Random Seed', value=42, interactive=True)
232
+ with gr.Row():
233
+ _ = gr.Examples(
234
+ examples=[
235
+ ['./data/49215_5368e45e_0000.stl', 42],
236
+ ['./data/00882236.stl', 6],
237
+ ['./data/User Library-engrenage.stl', 18],
238
+ ['./data/00010900.stl', 42],
239
+ ['./data/21492_8bd34fc1_0008.stl', 42],
240
+ ['./data/00375556.stl', 96],
241
+ ['./data/49121_adb01620_0000.stl', 42]],
242
+ example_labels=[
243
+ 'fusion360_table1', 'deepcad_star', 'cc3d_gear', 'deepcad_barrels',
244
+ 'fusion360_gear', 'deepcad_house', 'fusion360_table2'],
245
+ inputs=[in_model, seed_slider],
246
+ cache_examples=False)
247
+ with gr.Row():
248
+ run_button = gr.Button('Run')
249
+ _ = gr.LoginButton()
250
+
251
+ with gr.Column():
252
+ out_code = gr.Code(language='python', label='3. Generated Python Code', wrap_lines=True, interactive=False)
253
+
254
+ with gr.Column():
255
+ log_textbox = gr.Textbox(label='Log', placeholder='Status: OK', interactive=False)
256
+
257
+ run_button.click(
258
+ run_test_safe, inputs=[in_model, seed_slider], outputs=[point_model, out_code, out_model, log_textbox])
259
+
260
+ demo.launch()