Spaces:
Runtime error
Runtime error
support direct mesh visualizer
Browse files
app.py
CHANGED
|
@@ -113,17 +113,29 @@ def generate_mesh(image, source_size=512, render_size=384, mesh_size=512, export
|
|
| 113 |
mesh.export(mesh_path, 'obj')
|
| 114 |
return mesh_path
|
| 115 |
|
| 116 |
-
#
|
| 117 |
-
def
|
| 118 |
-
|
| 119 |
-
|
| 120 |
-
return mesh_file
|
| 121 |
|
|
|
|
|
|
|
|
|
|
| 122 |
|
| 123 |
-
gr.
|
| 124 |
-
|
| 125 |
-
|
| 126 |
-
|
| 127 |
-
|
| 128 |
-
|
| 129 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 113 |
mesh.export(mesh_path, 'obj')
|
| 114 |
return mesh_path
|
| 115 |
|
| 116 |
+
# we will convert image to mesh
|
| 117 |
+
def step_1_generate_obj(image):
|
| 118 |
+
mesh_path = generate_mesh(image)
|
| 119 |
+
return mesh_path
|
|
|
|
| 120 |
|
| 121 |
+
# we will convert mesh to 3d-image
|
| 122 |
+
def step_2_display_3d_model(mesh_file):
|
| 123 |
+
return mesh_file
|
| 124 |
|
| 125 |
+
with gr.Blocks() as demo:
|
| 126 |
+
with gr.Row():
|
| 127 |
+
with gr.Column():
|
| 128 |
+
img_input = gr.Image(type="pil", label="Input Image")
|
| 129 |
+
generate_button = gr.Button("Generate and Visualize 3D Model")
|
| 130 |
+
obj_file_output = gr.File(label="Download .obj File")
|
| 131 |
+
|
| 132 |
+
with gr.Column():
|
| 133 |
+
model_output = gr.Model3D(clear_color=[0.0, 0.0, 0.0, 0.0], label="3D Model Visualization")
|
| 134 |
+
|
| 135 |
+
def generate_and_visualize(image):
|
| 136 |
+
mesh_path = step_1_generate_obj(image)
|
| 137 |
+
return mesh_path, mesh_path
|
| 138 |
+
|
| 139 |
+
generate_button.click(generate_and_visualize, inputs=img_input, outputs=[obj_file_output, model_output])
|
| 140 |
+
|
| 141 |
+
demo.launch()
|