Spaces:
Running
on
Zero
Running
on
Zero
Update app.py
Browse files
app.py
CHANGED
|
@@ -4,7 +4,6 @@ import trimesh
|
|
| 4 |
import traceback
|
| 5 |
import numpy as np
|
| 6 |
import gradio as gr
|
| 7 |
-
from functools import partial
|
| 8 |
from multiprocessing import Process, Queue
|
| 9 |
|
| 10 |
import torch
|
|
@@ -144,12 +143,12 @@ def py_string_to_mesh_file_safe(py_string, mesh_path):
|
|
| 144 |
target=py_string_to_mesh_file,
|
| 145 |
args=(py_string, mesh_path, queue))
|
| 146 |
process.start()
|
| 147 |
-
process.join(
|
| 148 |
|
| 149 |
if process.is_alive():
|
| 150 |
process.terminate()
|
| 151 |
process.join()
|
| 152 |
-
raise gr.Error('Process is alive after
|
| 153 |
|
| 154 |
if not queue.empty():
|
| 155 |
raise gr.Error(queue.get())
|
|
@@ -203,9 +202,20 @@ def run_mesh(py_string):
|
|
| 203 |
def run():
|
| 204 |
with gr.Blocks() as demo:
|
| 205 |
with gr.Row():
|
| 206 |
-
gr.
|
| 207 |
-
|
|
|
|
|
|
|
| 208 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 209 |
with gr.Row(equal_height=True):
|
| 210 |
in_model = gr.Model3D(label='1. Input Mesh', interactive=True)
|
| 211 |
point_model = gr.Model3D(label='2. Sampled Point Cloud', display_mode='point_cloud', interactive=False)
|
|
@@ -227,12 +237,23 @@ def run():
|
|
| 227 |
['./data/21492_8bd34fc1_0008.stl', 42],
|
| 228 |
['./data/00375556.stl', 96],
|
| 229 |
['./data/49121_adb01620_0000.stl', 42],
|
| 230 |
-
['./data/41473_c2137170_0023.stl', 42]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 231 |
example_labels=[
|
| 232 |
'fusion360_table1', 'deepcad_star', 'cc3d_gear', 'deepcad_barrels',
|
| 233 |
-
'fusion360_gear', 'deepcad_house', 'fusion360_table2', 'fusion360_omega'
|
|
|
|
|
|
|
| 234 |
inputs=[in_model, seed_slider],
|
| 235 |
-
cache_examples=False
|
|
|
|
| 236 |
with gr.Row():
|
| 237 |
run_button = gr.Button('Run')
|
| 238 |
|
|
@@ -270,4 +291,4 @@ cad_recode = CADRecode.from_pretrained(
|
|
| 270 |
attn_implementation='flash_attention_2').eval()
|
| 271 |
|
| 272 |
os.environ['TOKENIZERS_PARALLELISM'] = 'False'
|
| 273 |
-
run()
|
|
|
|
| 4 |
import traceback
|
| 5 |
import numpy as np
|
| 6 |
import gradio as gr
|
|
|
|
| 7 |
from multiprocessing import Process, Queue
|
| 8 |
|
| 9 |
import torch
|
|
|
|
| 143 |
target=py_string_to_mesh_file,
|
| 144 |
args=(py_string, mesh_path, queue))
|
| 145 |
process.start()
|
| 146 |
+
process.join(7)
|
| 147 |
|
| 148 |
if process.is_alive():
|
| 149 |
process.terminate()
|
| 150 |
process.join()
|
| 151 |
+
raise gr.Error('Process is alive after 7 seconds')
|
| 152 |
|
| 153 |
if not queue.empty():
|
| 154 |
raise gr.Error(queue.get())
|
|
|
|
| 202 |
def run():
|
| 203 |
with gr.Blocks() as demo:
|
| 204 |
with gr.Row():
|
| 205 |
+
with gr.Column(scale=2):
|
| 206 |
+
gr.Markdown(
|
| 207 |
+
'## CAD-Recode Demo\n'
|
| 208 |
+
'Upload mesh or select from examples and press Run! Mesh ⇾ 256 points ⇾ Python code by CAD-Recode ⇾ CAD model.')
|
| 209 |
|
| 210 |
+
with gr.Column(scale=1):
|
| 211 |
+
with gr.Row():
|
| 212 |
+
gr.Image('./logos/snt.png', height=30, min_width=90, show_label=False, show_download_button=False, show_fullscreen_button=False, show_share_button=False)
|
| 213 |
+
gr.Image('./logos/fnr.png', height=30, min_width=90, show_label=False, show_download_button=False, show_fullscreen_button=False, show_share_button=False)
|
| 214 |
+
gr.Image('./logos/a3d.png', height=30, min_width=90, show_label=False, show_download_button=False, show_fullscreen_button=False, show_share_button=False)
|
| 215 |
+
|
| 216 |
+
with gr.Row():
|
| 217 |
+
gr.Markdown('GitHub: [filaPro/cad-recode](https://github.com/filaPro/cad-recode), arXiv: [2412.14042](https://arxiv.org/abs/2412.14042)')
|
| 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)
|
|
|
|
| 237 |
['./data/21492_8bd34fc1_0008.stl', 42],
|
| 238 |
['./data/00375556.stl', 96],
|
| 239 |
['./data/49121_adb01620_0000.stl', 42],
|
| 240 |
+
['./data/41473_c2137170_0023.stl', 42],
|
| 241 |
+
['./data/22447_4062c6cb_0011.stl', 42],
|
| 242 |
+
['./data/27694_7801dc67_0017.stl', 45],
|
| 243 |
+
['./data/49562_6df35938_0005.stl', 44],
|
| 244 |
+
['./data/131709_8b86dfb6_0000.stl', 45],
|
| 245 |
+
['./data/00081523.stl', 44],
|
| 246 |
+
['./data/00614972.stl', 44],
|
| 247 |
+
['./data/User Library-Cople Ventosa V2.stl', 50],
|
| 248 |
+
['./data/User Library-Caster, Superior Brand, 600lb 2 EDIT.stl', 52]],
|
| 249 |
example_labels=[
|
| 250 |
'fusion360_table1', 'deepcad_star', 'cc3d_gear', 'deepcad_barrels',
|
| 251 |
+
'fusion360_gear', 'deepcad_house', 'fusion360_table2', 'fusion360_omega',
|
| 252 |
+
'fusion360_hat', 'fusion360_table3', 'fusion360_bolt', 'fusion360_clamp',
|
| 253 |
+
'deepcad_alpha', 'deepcad_pulley', 'cc3d_flange', 'cc3d_caster'],
|
| 254 |
inputs=[in_model, seed_slider],
|
| 255 |
+
cache_examples=False,
|
| 256 |
+
examples_per_page=20)
|
| 257 |
with gr.Row():
|
| 258 |
run_button = gr.Button('Run')
|
| 259 |
|
|
|
|
| 291 |
attn_implementation='flash_attention_2').eval()
|
| 292 |
|
| 293 |
os.environ['TOKENIZERS_PARALLELISM'] = 'False'
|
| 294 |
+
run()
|