, mc_resolution
Browse files
app.py
CHANGED
@@ -69,15 +69,16 @@ def preprocess(input_image, do_remove_background, foreground_ratio):
|
|
69 |
return image
|
70 |
|
71 |
|
72 |
-
def generate(image, mc_resolution):
|
73 |
scene_codes = model(image, device=device)
|
74 |
mesh = model.extract_mesh(scene_codes, resolution=mc_resolution)[0]
|
75 |
mesh = to_gradio_3d_orientation(mesh)
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
|
|
81 |
|
82 |
def run_example(image_pil):
|
83 |
preprocessed = preprocess(image_pil, False, 0.9)
|
@@ -112,7 +113,7 @@ with gr.Blocks() as demo:
|
|
112 |
mc_resolution = gr.Slider(
|
113 |
label="Marching Cubes Resolution",
|
114 |
minimum=32,
|
115 |
-
maximum=
|
116 |
value=256,
|
117 |
step=32
|
118 |
)
|
@@ -147,7 +148,7 @@ with gr.Blocks() as demo:
|
|
147 |
outputs=[processed_image],
|
148 |
).success(
|
149 |
fn=generate,
|
150 |
-
inputs=[processed_image],
|
151 |
outputs=[output_model, output_model2],
|
152 |
)
|
153 |
|
|
|
69 |
return image
|
70 |
|
71 |
|
72 |
+
def generate(image, mc_resolution, formats=["obj", "glb"]):
|
73 |
scene_codes = model(image, device=device)
|
74 |
mesh = model.extract_mesh(scene_codes, resolution=mc_resolution)[0]
|
75 |
mesh = to_gradio_3d_orientation(mesh)
|
76 |
+
rv = []
|
77 |
+
for format in formats:
|
78 |
+
mesh_path = tempfile.NamedTemporaryFile(suffix=f".{format}", delete=False)
|
79 |
+
mesh.export(mesh_path.name)
|
80 |
+
rv.append(mesh_path.name)
|
81 |
+
return rv
|
82 |
|
83 |
def run_example(image_pil):
|
84 |
preprocessed = preprocess(image_pil, False, 0.9)
|
|
|
113 |
mc_resolution = gr.Slider(
|
114 |
label="Marching Cubes Resolution",
|
115 |
minimum=32,
|
116 |
+
maximum=1024,
|
117 |
value=256,
|
118 |
step=32
|
119 |
)
|
|
|
148 |
outputs=[processed_image],
|
149 |
).success(
|
150 |
fn=generate,
|
151 |
+
inputs=[processed_image, mc_resolution],
|
152 |
outputs=[output_model, output_model2],
|
153 |
)
|
154 |
|