cocktailpeanut
commited on
Commit
•
fbbd4eb
1
Parent(s):
1837f83
glb
Browse files
app.py
CHANGED
@@ -74,13 +74,15 @@ def generate(image):
|
|
74 |
mesh = model.extract_mesh(scene_codes)[0]
|
75 |
mesh = to_gradio_3d_orientation(mesh)
|
76 |
mesh_path = tempfile.NamedTemporaryFile(suffix=".obj", delete=False)
|
|
|
77 |
mesh.export(mesh_path.name)
|
78 |
-
|
|
|
79 |
|
80 |
def run_example(image_pil):
|
81 |
preprocessed = preprocess(image_pil, False, 0.9)
|
82 |
-
mesh_name = generate(preprocessed)
|
83 |
-
return preprocessed, mesh_name
|
84 |
|
85 |
with gr.Blocks() as demo:
|
86 |
gr.Markdown(HEADER)
|
@@ -110,18 +112,23 @@ with gr.Blocks() as demo:
|
|
110 |
with gr.Row():
|
111 |
submit = gr.Button("Generate", elem_id="generate", variant="primary")
|
112 |
with gr.Column():
|
113 |
-
with gr.Tab("
|
114 |
output_model = gr.Model3D(
|
115 |
label="Output Model",
|
116 |
interactive=False,
|
117 |
)
|
|
|
|
|
|
|
|
|
|
|
118 |
with gr.Row(variant="panel"):
|
119 |
gr.Examples(
|
120 |
examples=[
|
121 |
os.path.join("examples", img_name) for img_name in sorted(os.listdir("examples"))
|
122 |
],
|
123 |
inputs=[input_image],
|
124 |
-
outputs=[processed_image, output_model],
|
125 |
#cache_examples=True,
|
126 |
fn=partial(run_example),
|
127 |
label="Examples",
|
@@ -134,7 +141,7 @@ with gr.Blocks() as demo:
|
|
134 |
).success(
|
135 |
fn=generate,
|
136 |
inputs=[processed_image],
|
137 |
-
outputs=[output_model],
|
138 |
)
|
139 |
|
140 |
demo.queue(max_size=10)
|
|
|
74 |
mesh = model.extract_mesh(scene_codes)[0]
|
75 |
mesh = to_gradio_3d_orientation(mesh)
|
76 |
mesh_path = tempfile.NamedTemporaryFile(suffix=".obj", delete=False)
|
77 |
+
mesh_path2 = tempfile.NamedTemporaryFile(suffix=".glb", delete=False)
|
78 |
mesh.export(mesh_path.name)
|
79 |
+
mesh.export(mesh_path2.name)
|
80 |
+
return mesh_path.name, mesh_path2.name
|
81 |
|
82 |
def run_example(image_pil):
|
83 |
preprocessed = preprocess(image_pil, False, 0.9)
|
84 |
+
mesh_name, mesn_name2 = generate(preprocessed)
|
85 |
+
return preprocessed, mesh_name, mesh_name2
|
86 |
|
87 |
with gr.Blocks() as demo:
|
88 |
gr.Markdown(HEADER)
|
|
|
112 |
with gr.Row():
|
113 |
submit = gr.Button("Generate", elem_id="generate", variant="primary")
|
114 |
with gr.Column():
|
115 |
+
with gr.Tab("obj"):
|
116 |
output_model = gr.Model3D(
|
117 |
label="Output Model",
|
118 |
interactive=False,
|
119 |
)
|
120 |
+
with gr.Tab("glb"):
|
121 |
+
output_model2 = gr.Model3D(
|
122 |
+
label="Output Model",
|
123 |
+
interactive=False,
|
124 |
+
)
|
125 |
with gr.Row(variant="panel"):
|
126 |
gr.Examples(
|
127 |
examples=[
|
128 |
os.path.join("examples", img_name) for img_name in sorted(os.listdir("examples"))
|
129 |
],
|
130 |
inputs=[input_image],
|
131 |
+
outputs=[processed_image, output_model, output_model2],
|
132 |
#cache_examples=True,
|
133 |
fn=partial(run_example),
|
134 |
label="Examples",
|
|
|
141 |
).success(
|
142 |
fn=generate,
|
143 |
inputs=[processed_image],
|
144 |
+
outputs=[output_model, output_model2],
|
145 |
)
|
146 |
|
147 |
demo.queue(max_size=10)
|